fix invalid request to /end when game ended in a draw

In `board.snakes` there would be `null` instead of `[]`.
This commit is contained in:
Demin Dmitriy 2022-03-21 02:37:56 +03:00
parent 397d925110
commit d7d888e326

View file

@ -392,7 +392,7 @@ func convertRulesSnake(snake rules.Snake, snakeState SnakeState) client.Snake {
} }
func convertRulesSnakes(snakes []rules.Snake, snakeStates map[string]SnakeState) []client.Snake { func convertRulesSnakes(snakes []rules.Snake, snakeStates map[string]SnakeState) []client.Snake {
var a []client.Snake a := make([]client.Snake, 0)
for _, snake := range snakes { for _, snake := range snakes {
if snake.EliminatedCause == rules.NotEliminated { if snake.EliminatedCause == rules.NotEliminated {
a = append(a, convertRulesSnake(snake, snakeStates[snake.ID])) a = append(a, convertRulesSnake(snake, snakeStates[snake.ID]))