DEV-1761: New rules API (#118)
* DEV-1761: Clean up Ruleset interface (#115) * remove legacy ruleset types and simplify ruleset interface * remove unnecessary settings argument from Ruleset interface * decouple rules.Settings from client API and store settings as strings * DEV 1761: Add new BoardState and Point fields (#117) * add Point.TTL, Point.Value, GameState and PointState to BoardState * allow maps to access BoardState.GameState,PointState * add PreUpdateBoard and refactor snail_mode with it * fix bug where an extra turn was printed to the console * fix formatting * fix lint errors Co-authored-by: JonathanArns <jonathan.arns@googlemail.com>
This commit is contained in:
parent
639362ef46
commit
82e1999126
50 changed files with 1349 additions and 1610 deletions
|
|
@ -135,18 +135,16 @@ func TestBoardStateEditor(t *testing.T) {
|
|||
editor.PlaceSnake("existing_snake", []rules.Point{{X: 5, Y: 2}, {X: 5, Y: 1}, {X: 5, Y: 0}}, 99)
|
||||
editor.PlaceSnake("new_snake", []rules.Point{{X: 0, Y: 0}, {X: 1, Y: 0}, {X: 1, Y: 1}}, 98)
|
||||
|
||||
require.Equal(t, &rules.BoardState{
|
||||
Width: 11,
|
||||
Height: 11,
|
||||
Food: []rules.Point{
|
||||
expected := rules.NewBoardState(11, 11).
|
||||
WithFood([]rules.Point{
|
||||
{X: 1, Y: 3},
|
||||
{X: 3, Y: 7},
|
||||
},
|
||||
Hazards: []rules.Point{
|
||||
}).
|
||||
WithHazards([]rules.Point{
|
||||
{X: 1, Y: 3},
|
||||
{X: 3, Y: 7},
|
||||
},
|
||||
Snakes: []rules.Snake{
|
||||
}).
|
||||
WithSnakes([]rules.Snake{
|
||||
{
|
||||
ID: "existing_snake",
|
||||
Health: 99,
|
||||
|
|
@ -157,8 +155,8 @@ func TestBoardStateEditor(t *testing.T) {
|
|||
Health: 98,
|
||||
Body: []rules.Point{{X: 0, Y: 0}, {X: 1, Y: 0}, {X: 1, Y: 1}},
|
||||
},
|
||||
},
|
||||
}, boardState)
|
||||
})
|
||||
require.Equal(t, expected, boardState)
|
||||
|
||||
require.Equal(t, []rules.Point{
|
||||
{X: 1, Y: 3},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue