Add decay logic to healing pools (#97)

* adding logic to remove healing pools periodically to prevent extended length games

* Fix for the case where ShrinkEveryNTurns is not set
This commit is contained in:
Chris Hoefgen 2022-08-08 14:57:34 -07:00 committed by GitHub
parent 215a0ea998
commit 91106aec09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 2 deletions

View file

@ -41,8 +41,9 @@ func TestHealingPoolsMap(t *testing.T) {
m := maps.HealingPoolsMap{}
state := rules.NewBoardState(tc.boardSize, tc.boardSize)
settings := rules.Settings{}
settings.RoyaleSettings.ShrinkEveryNTurns = 10
// ensure the ring of hazards is added to the board at setup
// ensure the hazards are added to the board at setup
editor := maps.NewBoardStateEditor(state)
require.Empty(t, state.Hazards)
err := m.SetupBoard(state, settings, editor)
@ -53,6 +54,16 @@ func TestHealingPoolsMap(t *testing.T) {
for _, p := range state.Hazards {
require.Contains(t, tc.allowableHazards, p)
}
// ensure the hazards are removed
totalTurns := settings.RoyaleSettings.ShrinkEveryNTurns*tc.expectedHazards + 1
for i := 0; i < totalTurns; i++ {
state.Turn = i
err = m.UpdateBoard(state, settings, editor)
require.NoError(t, err)
}
require.Equal(t, 0, len(state.Hazards))
})
}
}