DEV 1676: Add maps helper functions (#111)

* add utility methods to Editor and BoardStateEditor

* add Meta.Validate

* allow setting Meta.MinPlayers to zero

* remove uints in map sizes

* use Meta.Validate in HazardPitsMap
This commit is contained in:
Rob O'Dwyer 2022-09-13 13:11:43 -07:00 committed by GitHub
parent c5810d8604
commit c4247945ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 701 additions and 83 deletions

View file

@ -21,8 +21,8 @@ func TestRiversAndBridgetsHazardsMap(t *testing.T) {
tests := []struct {
Map maps.GameMap
Width uint
Height uint
Width int
Height int
}{
{maps.RiverAndBridgesMediumHazardsMap{}, 11, 11},
{maps.RiverAndBridgesLargeHazardsMap{}, 19, 19},
@ -33,7 +33,7 @@ func TestRiversAndBridgetsHazardsMap(t *testing.T) {
// check all the supported sizes
for _, test := range tests {
state = rules.NewBoardState(int(test.Width), int(test.Height))
state = rules.NewBoardState(test.Width, test.Height)
state.Snakes = append(state.Snakes, rules.Snake{ID: "1", Body: []rules.Point{}})
editor = maps.NewBoardStateEditor(state)
require.Empty(t, state.Hazards)