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
|
|
@ -97,8 +97,12 @@ func (m HazardPitsMap) SetupBoard(initialBoardState *rules.BoardState, settings
|
|||
return nil
|
||||
}
|
||||
|
||||
func (m HazardPitsMap) UpdateBoard(lastBoardState *rules.BoardState, settings rules.Settings, editor Editor) error {
|
||||
err := StandardMap{}.UpdateBoard(lastBoardState, settings, editor)
|
||||
func (m HazardPitsMap) PreUpdateBoard(lastBoardState *rules.BoardState, settings rules.Settings, editor Editor) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m HazardPitsMap) PostUpdateBoard(lastBoardState *rules.BoardState, settings rules.Settings, editor Editor) error {
|
||||
err := StandardMap{}.PostUpdateBoard(lastBoardState, settings, editor)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -109,9 +113,10 @@ func (m HazardPitsMap) UpdateBoard(lastBoardState *rules.BoardState, settings ru
|
|||
// Cycle 3 - 3 layers
|
||||
// Cycle 4-6 - 4 layers of hazards
|
||||
|
||||
if lastBoardState.Turn%settings.RoyaleSettings.ShrinkEveryNTurns == 0 {
|
||||
shrinkEveryNTurns := settings.Int(rules.ParamShrinkEveryNTurns, 0)
|
||||
if lastBoardState.Turn%shrinkEveryNTurns == 0 {
|
||||
// Is it time to update the hazards
|
||||
layers := (lastBoardState.Turn / settings.RoyaleSettings.ShrinkEveryNTurns) % 7
|
||||
layers := (lastBoardState.Turn / shrinkEveryNTurns) % 7
|
||||
if layers > 4 {
|
||||
layers = 4
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue