Skip to content

Commit 1940f03

Browse files
committed
standard initial food spawn for snail mode
1 parent ef9c766 commit 1940f03

File tree

1 file changed

+2
-23
lines changed

1 file changed

+2
-23
lines changed

maps/snail_mode.go

+2-23
Original file line numberDiff line numberDiff line change
@@ -32,29 +32,8 @@ func (m SnailModeMap) Meta() Metadata {
3232

3333
// SetupBoard here is pretty 'standard' and doesn't do any special setup for this game mode
3434
func (m SnailModeMap) SetupBoard(initialBoardState *rules.BoardState, settings rules.Settings, editor Editor) error {
35-
rand := settings.GetRand(0)
36-
37-
if len(initialBoardState.Snakes) > int(m.Meta().MaxPlayers) {
38-
return rules.ErrorTooManySnakes
39-
}
40-
41-
snakeIDs := make([]string, 0, len(initialBoardState.Snakes))
42-
for _, snake := range initialBoardState.Snakes {
43-
snakeIDs = append(snakeIDs, snake.ID)
44-
}
45-
46-
tempBoardState := rules.NewBoardState(initialBoardState.Width, initialBoardState.Height)
47-
err := rules.PlaceSnakesAutomatically(rand, tempBoardState, snakeIDs)
48-
if err != nil {
49-
return err
50-
}
51-
52-
// Copy snakes from temp board state
53-
for _, snake := range tempBoardState.Snakes {
54-
editor.PlaceSnake(snake.ID, snake.Body, snake.Health)
55-
}
56-
57-
return nil
35+
// Use StandardMap to populate snakes and food
36+
return StandardMap{}.SetupBoard(initialBoardState, settings, editor)
5837
}
5938

6039
// storeTailLocation returns an offboard point that corresponds to the given point.

0 commit comments

Comments
 (0)