-
Notifications
You must be signed in to change notification settings - Fork 0
/
game_ext.h
92 lines (79 loc) · 2.64 KB
/
game_ext.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/**
* @file game_ext.h
* @brief Extended Game Functions.
* @details See @ref index for further details.
* @copyright University of Bordeaux. All rights reserved, 2021.
**/
#ifndef __GAME_EXT_H__
#define __GAME_EXT_H__
#include <stdbool.h>
#include "game.h"
/**
* @name Extended Functions
* @{
*/
/**
* @brief Creates a new game with extended options and initializes it.
* @details See description of game extensions on @ref index.
* @param nb_rows number of rows in game
* @param nb_cols number of columns in game
* @param squares an array describing the initial state of each square
* (row-major storage)
* @param wrapping wrapping option
* @return the created game
**/
game game_new_ext(uint nb_rows, uint nb_cols, square* squares, bool wrapping);
/**
* @brief Creates a new empty game with extended options.
* @details All squares are initialized with empty squares.
* @details See description of game extensions on @ref index.
* @param nb_rows number of rows in game
* @param nb_cols number of columns in game
* @param wrapping wrapping option
* @return the created game
**/
game game_new_empty_ext(uint nb_rows, uint nb_cols, bool wrapping);
/**
* @brief Gets the number of rows (or height).
* @param g the game
* @return the number of rows on this game
* @pre @p g is a valid pointer toward a cgame structure
**/
uint game_nb_rows(cgame g);
/**
* @brief Gets the number of columns (or width).
* @param g the game
* @return the the number of columns on this game
* @pre @p g is a valid pointer toward a cgame structure
**/
uint game_nb_cols(cgame g);
/**
* @brief Checks if the game has the wrapping option
* @return true, if wrapping, false otherwise
* @pre @p g is a valid pointer toward a cgame structure
**/
bool game_is_wrapping(cgame g);
/**
* @brief Undoes the last move.
* @details Searches in the history the last move played (by calling
* @ref game_play_move or @ref game_redo), and restores the state of the game
* before that move. If no moves have been played, this function does nothing.
* The @ref game_restart function clears the history.
* @param g the game
* @pre @p g is a valid pointer toward a cgame structure
**/
void game_undo(game g);
/**
* @brief Redoes the last move.
* @details Searches in the history the last cancelled move (by calling @ref
* game_undo), and replays it. If there are no more moves to be replayed, this
* function does nothing. After playing a new move with @ref game_play_move, it
* is no longer possible to redo an old cancelled move.
* @param g the game
* @pre @p g is a valid pointer toward a cgame structure
**/
void game_redo(game g);
/**
* @}
*/
#endif // __GAME_EXT_H__