diff --git a/constants.go b/constants.go index 041f436..cd63c70 100644 --- a/constants.go +++ b/constants.go @@ -26,6 +26,7 @@ const ( EliminatedByOutOfHealth = "out-of-health" EliminatedByHeadToHeadCollision = "head-collision" EliminatedByOutOfBounds = "wall-collision" + EliminatedByHazard = "hazard" // Error constants ErrorTooManySnakes = RulesetError("too many snakes for fixed start positions") diff --git a/standard.go b/standard.go index 835cbeb..191c739 100644 --- a/standard.go +++ b/standard.go @@ -184,7 +184,7 @@ func DamageHazardsStandard(b *BoardState, settings Settings, moves []SnakeMove) snake.Health = SnakeMaxHealth } if snakeIsOutOfHealth(snake) { - EliminateSnake(snake, EliminatedByOutOfHealth, "", b.Turn+1) + EliminateSnake(snake, EliminatedByHazard, "", b.Turn+1) } } } diff --git a/standard_test.go b/standard_test.go index 86c0849..5ccd0da 100644 --- a/standard_test.go +++ b/standard_test.go @@ -1299,7 +1299,7 @@ func TestMaybeDamageHazards(t *testing.T) { { Snakes: []Snake{{Body: []Point{{0, 0}}}}, Hazards: []Point{{0, 0}}, - ExpectedEliminatedCauses: []string{EliminatedByOutOfHealth}, + ExpectedEliminatedCauses: []string{EliminatedByHazard}, ExpectedEliminatedByIDs: []string{""}, ExpectedEliminatedOnTurns: []int{42}, }, @@ -1334,7 +1334,7 @@ func TestMaybeDamageHazards(t *testing.T) { {Body: []Point{{3, 3}, {3, 4}, {3, 5}, {3, 6}}}, }, Hazards: []Point{{3, 3}}, - ExpectedEliminatedCauses: []string{NotEliminated, EliminatedByOutOfHealth}, + ExpectedEliminatedCauses: []string{NotEliminated, EliminatedByHazard}, ExpectedEliminatedByIDs: []string{"", ""}, ExpectedEliminatedOnTurns: []int{0, 42}, }, @@ -1370,15 +1370,15 @@ func TestHazardDamagePerTurn(t *testing.T) { {100, 99, true, 100, NotEliminated, nil}, {100, -1, false, 100, NotEliminated, nil}, {99, -2, false, 100, NotEliminated, nil}, - {100, 100, false, 0, EliminatedByOutOfHealth, nil}, - {100, 101, false, 0, EliminatedByOutOfHealth, nil}, - {100, 999, false, 0, EliminatedByOutOfHealth, nil}, + {100, 100, false, 0, EliminatedByHazard, nil}, + {100, 101, false, 0, EliminatedByHazard, nil}, + {100, 999, false, 0, EliminatedByHazard, nil}, {100, 100, true, 100, NotEliminated, nil}, {2, 1, false, 1, NotEliminated, nil}, - {1, 1, false, 0, EliminatedByOutOfHealth, nil}, - {1, 999, false, 0, EliminatedByOutOfHealth, nil}, - {0, 1, false, 0, EliminatedByOutOfHealth, nil}, - {0, 999, false, 0, EliminatedByOutOfHealth, nil}, + {1, 1, false, 0, EliminatedByHazard, nil}, + {1, 999, false, 0, EliminatedByHazard, nil}, + {0, 1, false, 0, EliminatedByHazard, nil}, + {0, 999, false, 0, EliminatedByHazard, nil}, } for _, test := range tests {