diff --git a/go.sum b/go.sum index b1958f9..f861789 100644 --- a/go.sum +++ b/go.sum @@ -249,7 +249,6 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0 h1:HyfiK1WMnHj5FXFXatD+Qs1A/xC2Run6RzeW1SyHxpc= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 h1:xHms4gcpe1YE7A3yIllJXP16CMAGuqwO2lX1mTyyRRc= golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/maps/arcade_maze.go b/maps/arcade_maze.go index 5e7c248..5742fc4 100644 --- a/maps/arcade_maze.go +++ b/maps/arcade_maze.go @@ -19,6 +19,7 @@ func (m ArcadeMazeMap) Meta() Metadata { Name: "Arcade Maze", Description: "Generic arcade maze map with hazard walls", Author: "Battlesnake", + Version: 1, } } diff --git a/maps/empty.go b/maps/empty.go index ddd7ea1..80c0955 100644 --- a/maps/empty.go +++ b/maps/empty.go @@ -19,6 +19,7 @@ func (m EmptyMap) Meta() Metadata { Name: "Empty", Description: "Default snake placement with no food", Author: "Battlesnake", + Version: 1, } } diff --git a/maps/game_map.go b/maps/game_map.go index af6583b..9d3ec93 100644 --- a/maps/game_map.go +++ b/maps/game_map.go @@ -1,6 +1,8 @@ package maps -import "github.com/BattlesnakeOfficial/rules" +import ( + "github.com/BattlesnakeOfficial/rules" +) type GameMap interface { // Return a unique identifier for this map. @@ -20,6 +22,9 @@ type Metadata struct { Name string Author string Description string + // Version is the current version of the game map. + // Each time a map is changed, the version number should be incremented by 1. + Version uint } // Editor is used by GameMap implementations to modify the board state. diff --git a/maps/hazards.go b/maps/hazards.go index e745897..6a48a9c 100644 --- a/maps/hazards.go +++ b/maps/hazards.go @@ -29,6 +29,7 @@ func (m InnerBorderHazardsMap) Meta() Metadata { Name: "hz_inner_wall", Description: "Creates a static map on turn 0 that is a 1-square wall of hazard that is inset 2 squares from the edge of the board", Author: "Battlesnake", + Version: 1, } } @@ -65,6 +66,7 @@ func (m ConcentricRingsHazardsMap) Meta() Metadata { Name: "hz_rings", Description: "Creates a static map where there are rings of hazard sauce starting from the center with a 1 square space between the rings that has no sauce", Author: "Battlesnake", + Version: 1, } } @@ -102,6 +104,7 @@ func (m ColumnsHazardsMap) Meta() Metadata { Name: "hz_columns", Description: "Creates a static map on turn 0 that fills in odd squares, i.e. (1,1), (1,3), (3,3) ... with hazard sauce", Author: "Battlesnake", + Version: 1, } } @@ -136,7 +139,8 @@ func (m SpiralHazardsMap) Meta() Metadata { Name: "hz_spiral", Description: `Generates a dynamic hazard map that grows in a spiral pattern clockwise from a random point on the map. Each 2 turns a new hazard square is added to the map`, - Author: "altersaddle", + Author: "altersaddle", + Version: 1, } } @@ -225,6 +229,7 @@ func (m ScatterFillMap) Meta() Metadata { return Metadata{ Name: "hz_scatter", Description: `Fills the entire board with hazard squares that are set to appear on regular turn schedule. Each square is picked at random.`, + Version: 1, } } @@ -272,6 +277,7 @@ func (m DirectionalExpandingBoxMap) Meta() Metadata { return Metadata{ Name: "hz_grow_box", Description: `Creates an area of hazard that expands from a point with one random side growing on a turn schedule.`, + Version: 1, } } @@ -382,6 +388,7 @@ func (m ExpandingBoxMap) Meta() Metadata { return Metadata{ Name: "hz_expand_box", Description: `Generates an area of hazard that expands from a random point on the board outward in concentric rings on a periodic turn schedule.`, + Version: 1, } } @@ -453,6 +460,7 @@ func (m ExpandingScatterMap) Meta() Metadata { return Metadata{ Name: "hz_expand_scatter", Description: `Builds an expanding hazard area that grows from a central point in rings that are randomly filled in on a regular turn schedule.`, + Version: 1, } } @@ -530,7 +538,8 @@ func (m RiverAndBridgesHazardsMap) Meta() Metadata { Name: "hz_rivers_bridges", Description: `Creates fixed maps that have a lake of hazard in the middle with rivers going in the cardinal directions. Each river has one or two 1-square "bridges" over them`, - Author: "Battlesnake", + Author: "Battlesnake", + Version: 1, } } diff --git a/maps/registry_test.go b/maps/registry_test.go index 6016108..654072e 100644 --- a/maps/registry_test.go +++ b/maps/registry_test.go @@ -1,6 +1,7 @@ package maps import ( + "fmt" "testing" "github.com/BattlesnakeOfficial/rules" @@ -22,7 +23,7 @@ func TestRegisteredMaps(t *testing.T) { for mapName, gameMap := range globalRegistry { t.Run(mapName, func(t *testing.T) { require.Equalf(t, mapName, gameMap.ID(), "%#v game map doesn't return its own ID", mapName) - + require.True(t, gameMap.Meta().Version > 0, fmt.Sprintf("registered maps must have a valid version (>= 1) - '%d' is invalid", gameMap.Meta().Version)) var setupBoardState *rules.BoardState for width := 0; width < maxBoardWidth; width++ { diff --git a/maps/royale.go b/maps/royale.go index 59f1e66..b43618b 100644 --- a/maps/royale.go +++ b/maps/royale.go @@ -21,6 +21,7 @@ func (m RoyaleHazardsMap) Meta() Metadata { Name: "Royale", Description: "A map where hazards are generated every N turns", Author: "Battlesnake", + Version: 1, } } diff --git a/maps/standard.go b/maps/standard.go index 12d6dec..1814de9 100644 --- a/maps/standard.go +++ b/maps/standard.go @@ -19,6 +19,7 @@ func (m StandardMap) Meta() Metadata { Name: "Standard", Description: "Standard snake placement and food spawning", Author: "Battlesnake", + Version: 1, } }