Rivers and Bridges map refactor (#103)
* Separated out rivers and bridges into its own file with three map variants * fixing tags * removed extra 4 starting positions from the medium map since it only supports 8 players * update GetUnoccupiedPoints to consider hazards with a flag * use new utility method to fine unoccupied points and enforce map sizes * changed up casting to make IsAllowable() more usable
This commit is contained in:
parent
7d769b01b6
commit
f82cfe5309
10 changed files with 484 additions and 347 deletions
42
maps/rivers_and_bridges_test.go
Normal file
42
maps/rivers_and_bridges_test.go
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
package maps_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/BattlesnakeOfficial/rules"
|
||||
"github.com/BattlesnakeOfficial/rules/maps"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestRiversAndBridgetsHazardsMap(t *testing.T) {
|
||||
// check error handling
|
||||
m := maps.RiverAndBridgesMediumHazardsMap{}
|
||||
settings := rules.Settings{}
|
||||
|
||||
// check error for unsupported board sizes
|
||||
state := rules.NewBoardState(9, 9)
|
||||
editor := maps.NewBoardStateEditor(state)
|
||||
err := m.SetupBoard(state, settings, editor)
|
||||
require.Error(t, err)
|
||||
|
||||
tests := []struct {
|
||||
Map maps.GameMap
|
||||
Width uint
|
||||
Height uint
|
||||
}{
|
||||
{maps.RiverAndBridgesMediumHazardsMap{}, 11, 11},
|
||||
{maps.RiverAndBridgesLargeHazardsMap{}, 19, 19},
|
||||
{maps.RiverAndBridgesExtraLargeHazardsMap{}, 25, 25},
|
||||
}
|
||||
|
||||
// check all the supported sizes
|
||||
for _, test := range tests {
|
||||
state = rules.NewBoardState(int(test.Width), int(test.Height))
|
||||
state.Snakes = append(state.Snakes, rules.Snake{ID: "1", Body: []rules.Point{}})
|
||||
editor = maps.NewBoardStateEditor(state)
|
||||
require.Empty(t, state.Hazards)
|
||||
err = test.Map.SetupBoard(state, settings, editor)
|
||||
require.NoError(t, err)
|
||||
require.NotEmpty(t, state.Hazards)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue