Haunted-Mirror
The game that is 2017-18's project for UE projet Techno
|
This files describes the programming interface of a puzzle game, named 'Haunted Mirror'. More...
#include <stdbool.h>
Go to the source code of this file.
Macros | |
#define | NB_POSSIBLE_FILLINGS 6 |
#define | NB_DIR 4 |
Typedefs | |
typedef enum content_e | content |
possible contents of a square on the board. MIRROR stands for a mirror at +45 degrees (/), ANTIMIRROR at -45 degrees (\) (mnemonic is slash and antislash). | |
typedef enum direction_e | direction |
the fourth cardinal directions | |
typedef struct game_s * | game |
The structure pointer that stores the game. | |
typedef const struct game_s * | cgame |
The structure constant pointer that stores the game That means that it is not possible to modify the game using this pointer. See also: http://www.geeksforgeeks.org/const-qualifier-in-c/ See also this more technical discussion: http://stackoverflow.com/questions/8504411/typedef-pointer-const-weirdness. | |
Enumerations | |
enum | content_e { EMPTY, MIRROR, ANTIMIRROR, VAMPIRE, GHOST, ZOMBIE } |
possible contents of a square on the board. MIRROR stands for a mirror at +45 degrees (/), ANTIMIRROR at -45 degrees (\) (mnemonic is slash and antislash). | |
enum | direction_e { N, S, E, W } |
the fourth cardinal directions | |
Functions | |
Version 1 of Game API | |
game | new_game () |
creates an empty game with all squares set to empty, all labels and the number of required monsters set to 0. More... | |
game | setup_new_game (int *labels[NB_DIR], content *board, int required_nb_ghosts, int required_nb_vampires, int required_nb_zombies) |
creates a game from a board description. It uses a given board possibly with its mirrors, and a list of labels. More... | |
void | add_mirror (game game, int dir, int col, int line) |
adds a mirror on the game board More... | |
void | set_required_nb_seen (game game, direction side, int pos, int value) |
sets the label of a game More... | |
void | set_required_nb_monsters (game game, content monster, int value) |
modifies the aimed number of a given monster on the board More... | |
game | copy_game (cgame g_src) |
Clone the game g_src. More... | |
void | delete_game (game g) |
Destroy the game and free allocated memory. More... | |
int | required_nb_seen (cgame game, direction side, int pos) |
return the label on the side of the board More... | |
content | get_content (cgame game, int col, int line) |
get the content of a square in the board More... | |
int | required_nb_monsters (cgame game, content monster) |
indicates the aimed number of a given monster on the board More... | |
bool | is_game_over (cgame g) |
Test if the game is over (that is the grid is filled according to the requirements). More... | |
void | restart_game (game g) |
Restart a game by cleaning monsters from the board. | |
bool | add_monster (game game, content monster, int col, int line) |
adds a monster on the game board. Can also be used to remove any monster by adding EMPTY. This function does not have effect on mirrors so it can be used safely in the course of the game. More... | |
int | current_nb_seen (cgame game, direction side, int pos) |
says how many monsters can be seen on the current game board More... | |
int | current_nb_monsters (cgame game, content monster) |
counts the current number of monsters of a given type More... | |
This files describes the programming interface of a puzzle game, named 'Haunted Mirror'.
void add_mirror | ( | game | game, |
int | dir, | ||
int | col, | ||
int | line | ||
) |
adds a mirror on the game board
game | the game board where to add the mirror |
dir | the direction on which to add the mirror: 0 for +45 degrees (/), 1 for -45 degrees (\) |
col | which column to insert the mirror on (0<=col<4) |
line | which line to insert the mirror on (0<=line<4) |
adds a monster on the game board. Can also be used to remove any monster by adding EMPTY. This function does not have effect on mirrors so it can be used safely in the course of the game.
game | the game board where to add the monster |
monster | the type of monster to add |
col | the column where to insert the monster |
line | and the line where to insert the monster |
Clone the game g_src.
g_src | the game to clone |
counts the current number of monsters of a given type
game | the game board |
monster | the type of monster |
says how many monsters can be seen on the current game board
game | the game board to look at |
side | the side of the board we consider (N, S, W, or E) |
pos | the coordinate on that side (from S to N or from W to E) |
void delete_game | ( | game | g | ) |
Destroy the game and free allocated memory.
g | the game to destroy |
get the content of a square in the board
game | the game we consider |
col | the column of the square |
line | the line of the square |
bool is_game_over | ( | cgame | g | ) |
Test if the game is over (that is the grid is filled according to the requirements).
game new_game | ( | ) |
creates an empty game with all squares set to empty, all labels and the number of required monsters set to 0.
indicates the aimed number of a given monster on the board
game | the game that you want to collect the information about |
monster | the type of monster (should be GHOST, VAMPIRE or ZOMBIE) |
return the label on the side of the board
game | the game we consider |
side | the side of the board we want the label from |
pos | the position of the label you want (from S to N or from W to E) |
modifies the aimed number of a given monster on the board
game | the game that you want to modify the information about |
monster | the type of monster (should be GHOST, VAMPIRE or ZOMBIE) |
value | the value you want to set to the parameter. |
sets the label of a game
game | the game to modify |
side | the side of the game where the label should be modified |
pos | the position that the label should be modified (from S to N or from W to E) |
value | the new value to give to the label |
game setup_new_game | ( | int * | labels[NB_DIR], |
content * | board, | ||
int | required_nb_ghosts, | ||
int | required_nb_vampires, | ||
int | required_nb_zombies | ||
) |
creates a game from a board description. It uses a given board possibly with its mirrors, and a list of labels.
labels | an array of four pointers towards array of labels (namely, labels[N], labels[S], labels[E], labels[W]). The labels are given according to increasing coordinate value (from S to N or from W to E) |
board | an array of all the board squares, stored sequentially line by line starting from coordinate (0,0) |
required_nb_ghosts | the number of ghosts required in the game. |
required_nb_vampires | the number of vampires required in the game. |
required_nb_zombies | the number of zombies required in the game. |