DEV 1247: Add a new map generator interface (#71)
* reorganize code * first draft of map generator interfaces * add explicit random interface to board helpers * implement standard map * rename Generator to GameMap * allow initializing snakes separately from placing them * add random number generator to Settings * updates to GameMap interface * add helpers for creating and updating BoardState with maps
This commit is contained in:
parent
1c3f434841
commit
dab9178a55
16 changed files with 916 additions and 160 deletions
60
constants.go
Normal file
60
constants.go
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
package rules
|
||||
|
||||
type RulesetError string
|
||||
|
||||
func (err RulesetError) Error() string { return string(err) }
|
||||
|
||||
const (
|
||||
MoveUp = "up"
|
||||
MoveDown = "down"
|
||||
MoveRight = "right"
|
||||
MoveLeft = "left"
|
||||
|
||||
BoardSizeSmall = 7
|
||||
BoardSizeMedium = 11
|
||||
BoardSizeLarge = 19
|
||||
|
||||
SnakeMaxHealth = 100
|
||||
SnakeStartSize = 3
|
||||
|
||||
// Snake state constants
|
||||
NotEliminated = ""
|
||||
EliminatedByCollision = "snake-collision"
|
||||
EliminatedBySelfCollision = "snake-self-collision"
|
||||
EliminatedByOutOfHealth = "out-of-health"
|
||||
EliminatedByHeadToHeadCollision = "head-collision"
|
||||
EliminatedByOutOfBounds = "wall-collision"
|
||||
EliminatedBySquad = "squad-eliminated"
|
||||
|
||||
// Error constants
|
||||
ErrorTooManySnakes = RulesetError("too many snakes for fixed start positions")
|
||||
ErrorNoRoomForSnake = RulesetError("not enough space to place snake")
|
||||
ErrorNoRoomForFood = RulesetError("not enough space to place food")
|
||||
ErrorNoMoveFound = RulesetError("move not provided for snake")
|
||||
ErrorZeroLengthSnake = RulesetError("snake is length zero")
|
||||
ErrorEmptyRegistry = RulesetError("empty registry")
|
||||
ErrorNoStages = RulesetError("no stages")
|
||||
ErrorStageNotFound = RulesetError("stage not found")
|
||||
ErrorMapNotFound = RulesetError("map not found")
|
||||
|
||||
// Ruleset / game type names
|
||||
GameTypeConstrictor = "constrictor"
|
||||
GameTypeRoyale = "royale"
|
||||
GameTypeSolo = "solo"
|
||||
GameTypeSquad = "squad"
|
||||
GameTypeStandard = "standard"
|
||||
GameTypeWrapped = "wrapped"
|
||||
|
||||
// Game creation parameter names
|
||||
ParamGameType = "name"
|
||||
ParamFoodSpawnChance = "foodSpawnChance"
|
||||
ParamMinimumFood = "minimumFood"
|
||||
ParamHazardDamagePerTurn = "damagePerTurn"
|
||||
ParamHazardMap = "hazardMap"
|
||||
ParamHazardMapAuthor = "hazardMapAuthor"
|
||||
ParamShrinkEveryNTurns = "shrinkEveryNTurns"
|
||||
ParamAllowBodyCollisions = "allowBodyCollisions"
|
||||
ParamSharedElimination = "sharedElimination"
|
||||
ParamSharedHealth = "sharedHealth"
|
||||
ParamSharedLength = "sharedLength"
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue