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
|
|
@ -63,7 +63,7 @@ func (m ArcadeMazeMap) SetupBoard(initialBoardState *rules.BoardState, settings
|
|||
editor.AddHazard(hazard)
|
||||
}
|
||||
|
||||
if settings.MinimumFood > 0 {
|
||||
if settings.Int(rules.ParamMinimumFood, 0) > 0 {
|
||||
// Add food in center
|
||||
editor.AddFood(rules.Point{X: 9, Y: 11})
|
||||
}
|
||||
|
|
@ -71,11 +71,16 @@ func (m ArcadeMazeMap) SetupBoard(initialBoardState *rules.BoardState, settings
|
|||
return nil
|
||||
}
|
||||
|
||||
func (m ArcadeMazeMap) UpdateBoard(lastBoardState *rules.BoardState, settings rules.Settings, editor Editor) error {
|
||||
func (m ArcadeMazeMap) PreUpdateBoard(lastBoardState *rules.BoardState, settings rules.Settings, editor Editor) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m ArcadeMazeMap) PostUpdateBoard(lastBoardState *rules.BoardState, settings rules.Settings, editor Editor) error {
|
||||
rand := settings.GetRand(lastBoardState.Turn)
|
||||
|
||||
// Respect FoodSpawnChance setting
|
||||
if settings.FoodSpawnChance == 0 || rand.Intn(100) > settings.FoodSpawnChance {
|
||||
foodSpawnChance := settings.Int(rules.ParamFoodSpawnChance, 0)
|
||||
if foodSpawnChance == 0 || rand.Intn(100) > foodSpawnChance {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue