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:
Chris Hoefgen 2022-08-19 10:09:04 -07:00 committed by GitHub
parent 7d769b01b6
commit f82cfe5309
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 484 additions and 347 deletions

View file

@ -89,29 +89,6 @@ func TestColumnsHazardsMap(t *testing.T) {
require.NotContains(t, state.Hazards, rules.Point{X: 1, Y: 0})
}
func TestRiversAndBridgetsHazardsMap(t *testing.T) {
// check error handling
m := maps.RiverAndBridgesHazardsMap{}
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)
// check all the supported sizes
for _, size := range []int{11, 19, 25} {
state = rules.NewBoardState(size, size)
state.Snakes = append(state.Snakes, rules.Snake{ID: "1", Body: []rules.Point{}})
editor = maps.NewBoardStateEditor(state)
require.Empty(t, state.Hazards)
err = m.SetupBoard(state, settings, editor)
require.NoError(t, err)
require.NotEmpty(t, state.Hazards)
}
}
func TestSpiralHazardsMap(t *testing.T) {
// check error handling
m := maps.SpiralHazardsMap{}