Skip to content

Commit

Permalink
use Meta.Validate in HazardPitsMap
Browse files Browse the repository at this point in the history
  • Loading branch information
robbles committed Sep 13, 2022
1 parent 0ba438f commit 29af042
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions maps/hazard_pits.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ func (m HazardPitsMap) Meta() Metadata {
Description: "A map that that fills in grid-like pattern of squares with pits filled with hazard sauce. Every N turns the pits will fill with another layer of sauce up to a maximum of 4 layers which last a few cycles, then the pits drain and the pattern repeats",
Author: "Battlesnake",
Version: 1,
MinPlayers: 1,
MaxPlayers: 4,
MinPlayers: 0,
MaxPlayers: len(hazardPitStartPositions),
BoardSizes: FixedSizes(Dimensions{11, 11}),
Tags: []string{TAG_FOOD_PLACEMENT, TAG_HAZARD_PLACEMENT, TAG_SNAKE_PLACEMENT},
}
Expand All @@ -47,12 +47,8 @@ func (m HazardPitsMap) AddHazardPits(board *rules.BoardState, settings rules.Set
}

func (m HazardPitsMap) SetupBoard(initialBoardState *rules.BoardState, settings rules.Settings, editor Editor) error {
if !m.Meta().BoardSizes.IsAllowable(initialBoardState.Width, initialBoardState.Height) {
return rules.RulesetError("This map can only be played on a 11x11 board")
}

if len(initialBoardState.Snakes) > len(hazardPitStartPositions) {
return rules.ErrorTooManySnakes
if err := m.Meta().Validate(initialBoardState); err != nil {
return err
}

rand := settings.GetRand(0)
Expand Down

0 comments on commit 29af042

Please sign in to comment.