Project_2020  1.0
project for IUT student (2020--2021)
board.h
Go to the documentation of this file.
1 #ifndef _BOARD_H_
2 #define _BOARD_H_
3 
4 #include <stdbool.h>
5 
45 #define DIMENSION 6
46 
53 typedef struct board_s* board;
54 
61 enum sizes_e {
63  NONE,
64  ONE,
65  TWO,
67  };
68 typedef enum sizes_e size;
69 /*
70  * @brief the different sizes of pieces.
71  *
72  * This also includes a empty size for having a same type when there is no piece
73  * in a place.
74  */
75 //typedef enum sizes_e size;
76 
80 #define NB_SIZE 3
81 
88 enum players_e {NO_PLAYER, SOUTH_P, NORTH_P};
89 
90 typedef enum players_e player;
91 
92 
98 enum direction_e {GOAL, SOUTH, NORTH, EAST, WEST};
99 
100 typedef enum direction_e direction;
101 
105 #define NB_PLAYERS 2
106 
117 player next_player(player current_player);
118 
123 #define NB_INITIAL_PIECES 2
124 
131  OK,
136 /* /// invalid position on the board
137  POSITION,*/
140  };
141 typedef enum return_code_e return_code;
142 
143 
151 board new_game();
152 
158 board copy_game(board original_game);
159 
164 void destroy_game(board game);
165 
184 size get_piece_size(board game, int line, int column);
185 
194 player get_winner(board game);
195 
206 int southmost_occupied_line(board game);
207 
218 int northmost_occupied_line(board game);
219 
220 
230 player picked_piece_owner(board game);
231 
242 size picked_piece_size(board game);
243 
253 int picked_piece_line(board game);
254 
264 int picked_piece_column(board game);
265 
278 int movement_left(board game);
279 
300 int nb_pieces_available(board game, size piece, player player);
301 
317 return_code place_piece(board game, size piece, player player, int column);
318 
319 
320 
348 return_code pick_piece(board game, player current_player, int line, int column);
349 
365 bool is_move_possible(board game, direction direction);
366 
367 
388 return_code move_piece(board game, direction direction);
389 
407 return_code swap_piece(board game, int target_line, int target_column);
408 
421 return_code cancel_movement(board game);
422 
436 return_code cancel_step(board game);
437 
438 
441 #endif /*_BOARD_H_*/
forbidden request
Definition: board.h:135
player next_player(player current_player)
return the next player
int southmost_occupied_line(board game)
Returns the most southern line number which contains a piece.
int northmost_occupied_line(board game)
Returns the northmost line number which contains a piece.
return_code cancel_movement(board game)
cancels the current movement of the player, putting the piece back where it started.
return_code swap_piece(board game, int target_line, int target_column)
swap the current piece with the piece below it, and place the piece below at the given position...
direction_e
the different directions in the game. GOAL is legal only on the northmost line for south player...
Definition: board.h:98
player picked_piece_owner(board game)
returns the player whose piece is currently moving
return_code_e
error codes returned by the function
Definition: board.h:129
size get_piece_size(board game, int line, int column)
returns the size of the piece at the precised position on the board, if any.
given space should or should not be empty
Definition: board.h:133
size picked_piece_size(board game)
returns the size of the piece currently moving (if any)
return_code pick_piece(board game, player current_player, int line, int column)
Select a piece to start with.
success
Definition: board.h:131
size 3
Definition: board.h:66
return_code place_piece(board game, size piece, player player, int column)
places a piece on the board, during the initial setting up of the game.
bool is_move_possible(board game, direction direction)
Indicates whether a move is possible.
int movement_left(board game)
returns the number of movement units left to the current moving piece
no size, for representing no piece
Definition: board.h:63
int picked_piece_line(board game)
returns the line number of the piece currently moving (if any).
return_code move_piece(board game, direction direction)
Moves the current picked piece, if possible.
return_code cancel_step(board game)
cancels the last step of the current move.
The board of the game, define it as you wish.
Definition: modele_board.c:16
int nb_pieces_available(board game, size piece, player player)
Indicates whether the size of piece is still to be placed by the suggested player.
struct board_s * board
Pointer to the structure that holds the game.
Definition: board.h:53
size 1
Definition: board.h:64
player get_winner(board game)
Tells if the game has a winner.
void destroy_game(board game)
Delete the game and frees all required memory.
Definition: modele_board.c:27
int picked_piece_column(board game)
returns the column number of the piece currently moving (if any)
invalid parameter
Definition: board.h:139
size 2
Definition: board.h:65
board copy_game(board original_game)
Makes a deep copy of the game.
sizes_e
the different sizes of pieces.
Definition: board.h:61
board new_game()
Defines a new empty board for starting a game of gobblet-gobblers.
Definition: modele_board.c:20
players_e
the different players for further reference. NO_PLAYER is used when informing that a square is empty...
Definition: board.h:88