prevent negative hazard damage from healing past max health (#91)

This commit is contained in:
Rob O'Dwyer 2022-06-30 12:10:30 -07:00 committed by GitHub
parent 61aeee31d6
commit 1c728faeca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View file

@ -180,6 +180,9 @@ func DamageHazardsStandard(b *BoardState, settings Settings, moves []SnakeMove)
if snake.Health < 0 {
snake.Health = 0
}
if snake.Health > SnakeMaxHealth {
snake.Health = SnakeMaxHealth
}
if snakeIsOutOfHealth(snake) {
snake.EliminatedCause = EliminatedByOutOfHealth
}