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
|
|
@ -10,14 +10,12 @@ import (
|
|||
|
||||
const maxBoardWidth, maxBoardHeight = 25, 25
|
||||
|
||||
var testSettings rules.Settings = rules.Settings{
|
||||
FoodSpawnChance: 25,
|
||||
MinimumFood: 1,
|
||||
HazardDamagePerTurn: 14,
|
||||
RoyaleSettings: rules.RoyaleSettings{
|
||||
ShrinkEveryNTurns: 1,
|
||||
},
|
||||
}
|
||||
var testSettings rules.Settings = rules.NewSettings(map[string]string{
|
||||
rules.ParamFoodSpawnChance: "25",
|
||||
rules.ParamMinimumFood: "1",
|
||||
rules.ParamHazardDamagePerTurn: "14",
|
||||
rules.ParamShrinkEveryNTurns: "1",
|
||||
})
|
||||
|
||||
func TestRegisteredMaps(t *testing.T) {
|
||||
for mapName, gameMap := range globalRegistry {
|
||||
|
|
@ -96,7 +94,7 @@ func TestRegisteredMaps(t *testing.T) {
|
|||
|
||||
passedBoardState := previousBoardState.Clone()
|
||||
tempBoardState := previousBoardState.Clone()
|
||||
err := gameMap.UpdateBoard(passedBoardState, testSettings, NewBoardStateEditor(tempBoardState))
|
||||
err := gameMap.PostUpdateBoard(passedBoardState, testSettings, NewBoardStateEditor(tempBoardState))
|
||||
require.NoError(t, err, "GameMap.UpdateBoard returned an error")
|
||||
require.Equal(t, previousBoardState, passedBoardState, "BoardState should not be modified directly by GameMap.UpdateBoard")
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue