Game.
More...
|
| std::optional< std::chrono::milliseconds > | get_current_timer () |
| | Get the current value of the timer.
|
| const Board & | get_board () |
| | Get the board.
|
| void | uncover_cell (std::uint32_t x, std::uint32_t y) |
| | Uncover a cell.
|
| void | mark_cell (std::uint32_t x, std::uint32_t y) |
| | Place a mark on a cell.
|
| void | flag_cell (std::uint32_t x, std::uint32_t y) |
| | Place a flag on a cell.
|
| void | reset_cell (std::uint32_t x, std::uint32_t y) |
| | Reset flag or mark placed on a cell.
|
| bool | is_lost () |
| | Get whether the game was lost.
|
| bool | is_won () |
| | Get whether the game was won.
|
| void | new_board (std::uint32_t width, std::uint32_t height, std::uint32_t mines) |
| | Set up a new board.
|
| void | set_player_name (std::string player_name) |
| | Set the player name.
|
|
| static Game | create (std::uint32_t width, std::uint32_t height, std::uint32_t mines, std::string player_name, std::string save_path) |
| | Construct a game.
|
Game.
Contains high level game logic without a coupled user interface. Typically used with the user interface GameView.
◆ create()
| Game Game::create |
( |
std::uint32_t | width, |
|
|
std::uint32_t | height, |
|
|
std::uint32_t | mines, |
|
|
std::string | player_name, |
|
|
std::string | save_path ) |
|
inlinestatic |
Construct a game.
- Parameters
-
| width | Width of the board. |
| height | Height of the board. |
| mines | Number of mines. |
| player_name | Player name. |
- Returns
- New game.
- Exceptions
-
| TooManyMines | The number of mines is more than what is possible given the size of the minefield. |
| InvalidSaveData | Save data that was attempted to be deserialized is invalid. |
◆ flag_cell()
| void Game::flag_cell |
( |
std::uint32_t | x, |
|
|
std::uint32_t | y ) |
|
inline |
Place a flag on a cell.
Does nothing if the game ended, or the cell is uncovered or already flagged.
- Parameters
-
| x | Cell X position. |
| y | Cell Y position. |
◆ get_board()
| const Board & Game::get_board |
( |
| ) |
|
|
inline |
Get the board.
- Returns
- Board.
◆ get_current_timer()
| std::optional< std::chrono::milliseconds > Game::get_current_timer |
( |
| ) |
|
|
inline |
Get the current value of the timer.
- Returns
- Current value of the timer, if the game has started, or no value if the game has not started.
◆ is_lost()
Get whether the game was lost.
- Returns
- Whether the game was lost.
◆ is_won()
Get whether the game was won.
- Returns
- Whether the game was won.
◆ mark_cell()
| void Game::mark_cell |
( |
std::uint32_t | x, |
|
|
std::uint32_t | y ) |
|
inline |
Place a mark on a cell.
Does nothing if the game ended, or the cell is uncovered or already marked.
- Parameters
-
| x | Cell X position. |
| y | Cell Y position. |
◆ new_board()
| void Game::new_board |
( |
std::uint32_t | width, |
|
|
std::uint32_t | height, |
|
|
std::uint32_t | mines ) |
|
inline |
Set up a new board.
Resets the game to it's initial state.
- Parameters
-
| width | Width of the new board. |
| height | Height of the new board. |
| mines | Number of mines. |
◆ reset_cell()
| void Game::reset_cell |
( |
std::uint32_t | x, |
|
|
std::uint32_t | y ) |
|
inline |
Reset flag or mark placed on a cell.
Does nothing if the game ended, or the cell is not marked nor flagged.
- Parameters
-
| x | Cell X position. |
| y | Cell Y position. |
◆ set_player_name()
| void Game::set_player_name |
( |
std::string | player_name | ) |
|
|
inline |
Set the player name.
- Parameters
-
| player_name | New player name. |
◆ uncover_cell()
| void Game::uncover_cell |
( |
std::uint32_t | x, |
|
|
std::uint32_t | y ) |
|
inline |
Uncover a cell.
If this is the first time a cell is uncovered during a game, the minefield is generated with the guarantee that this cell is not a mine.
Causes a game over if the cell is a mine. Does nothing if the game ended, or the cell is flagged or already uncovered.
- Parameters
-
| x | Cell X position. |
| y | Cell Y position. |
The documentation for this class was generated from the following file: