Byte-snake-engine/maps/rivers_and_bridges_test.go
Chris Hoefgen f82cfe5309
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
2022-08-19 10:09:04 -07:00

42 lines
1.1 KiB
Go

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)
}
}