| Safe Haskell | Safe |
|---|
Game.Types
Synopsis
- data BoardCoordinate = BoardCoordinate {
- boardColumn :: Int
- boardRow :: Int
- data GameAction
- data GameState = GameState {
- gameConfig :: GameConfig
- previousState :: Maybe GameState
- cells :: CellStates
- globalGameState :: GlobalGameState
- undo :: GameState -> GameState
- data GameConfig = GameConfig {
- boardWidth :: Int
- boardHeight :: Int
- totalMines :: Int
- totalCells :: GameConfig -> Int
- data PlayState
- data GlobalGameState = GlobalGameState {
- remainingMines :: Int
- freeCells :: Int
- globalPlayState :: PlayState
- data InternalCellState
- data VisibleCellState
- = Unknown
- | Known
- | Flagged
- | Unsure
- | Labeled {
- totalLabel :: Int
- countdownLabel :: Int
- data CellState = CellState {}
- type CellStates = [[CellState]]
- isMine :: CellState -> Bool
- isSafe :: CellState -> Bool
- isUndefined :: CellState -> Bool
- isFlagged :: CellState -> Bool
- isKnown :: CellState -> Bool
- cellFromState :: BoardCoordinate -> CellStates -> CellState
- countCells :: (CellState -> Bool) -> [CellState] -> Int
- countInState :: (CellState -> Bool) -> CellStates -> Int
Documentation
data BoardCoordinate #
position of a cell on the board
Constructors
| BoardCoordinate | BoardCoordinate |
Fields
| |
data GameAction #
a move in the game played by the player
Constructors
| Reveal BoardCoordinate | reveal a single cell |
| RevealArea BoardCoordinate | reveal all adjacent safe cells if possible |
| ToggleFlag BoardCoordinate | toggle flag/unsure on cell |
| Undo | undo last |
represents the complete and consistent state of the game in a given point in time
Constructors
| GameState | GameState |
Fields
| |
undo :: GameState -> GameState #
return the previous game state to undo last reveal
if no previous state is available, the same state is returned
data GameConfig #
Board configuration for a new game
Constructors
| GameConfig | GameConfig |
Fields
| |
Instances
| Eq GameConfig # | |
Defined in Game.Types | |
totalCells :: GameConfig -> Int #
total number of cells for this GameConfig
current win/lose state of the game
data GlobalGameState #
global states of the game calculated from all cell states
Constructors
| GlobalGameState | GlobalGameState |
Fields
| |
Instances
| Eq GlobalGameState # | |
Defined in Game.Types Methods (==) :: GlobalGameState -> GlobalGameState -> Bool (/=) :: GlobalGameState -> GlobalGameState -> Bool | |
data InternalCellState #
internal (non-visible) state of a cell
Constructors
| Safe | the cell does not contain a mine |
| Mine | the cell does contain a mine |
| Undefined | it is not fixed yet whether this cell will contain a mine |
Instances
| Eq InternalCellState # | |
Defined in Game.Types Methods (==) :: InternalCellState -> InternalCellState -> Bool (/=) :: InternalCellState -> InternalCellState -> Bool | |
data VisibleCellState #
state of a cell visible to the player
Constructors
| Unknown | cell is still hidden |
| Known | cell is open (and contains a mine) |
| Flagged | cell was falgged by the player |
| Unsure | cell was flagged as unsure by the player |
| Labeled | cell was revealed and shows the number of adjacent mines |
Fields
| |
Instances
| Eq VisibleCellState # | |
Defined in Game.Types Methods (==) :: VisibleCellState -> VisibleCellState -> Bool (/=) :: VisibleCellState -> VisibleCellState -> Bool | |
the state of cell on the board
Constructors
| CellState | CellState |
Fields
| |
type CellStates = [[CellState]] #
rows and columns of cells representing the game board
isUndefined :: CellState -> Bool #
whether the content of the cell was not fixed yet
cellFromState :: BoardCoordinate -> CellStates -> CellState #
get cell on specific coordinate from cellStates
countCells :: (CellState -> Bool) -> [CellState] -> Int #
count cells in list matching the predicate
countInState :: (CellState -> Bool) -> CellStates -> Int #
count cells in cellStates matching the predicate