DEV-1313: Add additional map types (#76)
* add helper to draw a ring of hazards * refactor tests to not be internal tests * add "hz_inner_wall" map * add "hz_rings" map * fix map registry * fix: edge case bugs in drawRing * remove println * add "hz_columns" * add "hz_rivers_bridges" map * WIP: implementing spiral hazards map * finish basic testing of 'hz_spiral' * include first turn * add "hz_hazards" map * remove incorrect author * add "hz_grow_box" map * add "hz_expand_box" map * add "hz_expand_scatter" map * remove debug * document the new "Range" method * - use rules.RulesetError instead of generic error - use a rules.Point for map rivers and bridgets map key * use rules.RulesetError instead of errors.New * provide more detail about boundar conditions * fix documentation (max can be == min) * add unit tests
This commit is contained in:
parent
aa38bcd0eb
commit
f0dc0bcb38
8 changed files with 1129 additions and 24 deletions
|
|
@ -1,18 +1,19 @@
|
|||
package maps
|
||||
package maps_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/BattlesnakeOfficial/rules"
|
||||
"github.com/BattlesnakeOfficial/rules/maps"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestEmptyMapInterface(t *testing.T) {
|
||||
var _ GameMap = EmptyMap{}
|
||||
var _ maps.GameMap = maps.EmptyMap{}
|
||||
}
|
||||
|
||||
func TestEmptyMapSetupBoard(t *testing.T) {
|
||||
m := EmptyMap{}
|
||||
m := maps.EmptyMap{}
|
||||
settings := rules.Settings{}
|
||||
|
||||
tests := []struct {
|
||||
|
|
@ -122,7 +123,7 @@ func TestEmptyMapSetupBoard(t *testing.T) {
|
|||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
nextBoardState := rules.NewBoardState(test.initialBoardState.Width, test.initialBoardState.Height)
|
||||
editor := NewBoardStateEditor(nextBoardState)
|
||||
editor := maps.NewBoardStateEditor(nextBoardState)
|
||||
settings := settings.WithRand(test.rand)
|
||||
|
||||
err := m.SetupBoard(test.initialBoardState, settings, editor)
|
||||
|
|
@ -137,7 +138,7 @@ func TestEmptyMapSetupBoard(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestEmptyMapUpdateBoard(t *testing.T) {
|
||||
m := EmptyMap{}
|
||||
m := maps.EmptyMap{}
|
||||
initialBoardState := &rules.BoardState{
|
||||
Width: 2,
|
||||
Height: 2,
|
||||
|
|
@ -151,7 +152,7 @@ func TestEmptyMapUpdateBoard(t *testing.T) {
|
|||
}.WithRand(rules.MaxRand)
|
||||
nextBoardState := initialBoardState.Clone()
|
||||
|
||||
err := m.UpdateBoard(initialBoardState.Clone(), settings, NewBoardStateEditor(nextBoardState))
|
||||
err := m.UpdateBoard(initialBoardState.Clone(), settings, maps.NewBoardStateEditor(nextBoardState))
|
||||
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, &rules.BoardState{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue