Documentation ¶
Index ¶
Constants ¶
View Source
const ( GameMinRows = 3 GameMinCols = 3 GameMaxRows = 50 GameMaxCols = 50 GameStatusCreated = "created" GameStatusStarted = "started" GameStatusVictory = "victory" GameStatusDefeat = "defeat" GameClickTypeNormal = 1 GameClickTypeFlag = 2 GameClickTypeReveal = 3 )
Some default game parameters, if the user does not provide those.
Variables ¶
View Source
var ( ErrDefeat = errors.New("Defeat") ErrNotActive = errors.New("Game not active") )
Functions ¶
This section is empty.
Types ¶
type Field ¶
type Field struct { Mine bool `json:"mine"` Clicked bool `json:"clicked"` // indicated whether the field was clicked Flagged bool `json:"flagged"` // red flag in the field AdjCount int `json:"adjMines"` // count of adjacent mines Position Position `json:"position"` // position in the minefield ClickedBy string `json:"clickedBy"` // who clicked this field }
Field represents a square unit in the MineField
type Game ¶
type Game struct { ID string `json:"id"` Rows int `json:"rows"` Cols int `json:"cols"` Mines int `json:"mines"` Status GameStatus `json:"status"` MineField [][]Field `json:"mineField"` StartedAt *time.Time `json:"startedAt,omitempty"` FinishedAt *time.Time `json:"finishedAt,omitempty"` CreatedAt time.Time `json:"createdAt"` CreatedBy string `json:"createdBy"` // who created this game }
Game contains the structure of the game
type GameStatus ¶
type GameStatus string
Click to show internal directories.
Click to hide internal directories.