game_private to not change others .h
This commit is contained in:
1 parent
fb59382361
commit
3485b9ec68
11 files changed
+33
-17
No files matched your search
Vendored
+2
-1
@@ -1,7 +1,8 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"game_ext.h": "c",
|
||||
"game.h": "c"
|
||||
"game.h": "c",
|
||||
"game_private.h": "c"
|
||||
},
|
||||
"editor.formatOnSave": true,
|
||||
"C_Cpp.clang_format_path": "/usr/bin/clang-format"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "game_ext.h"
|
||||
#include "game_private.h"
|
||||
|
||||
int max(int a, int b) {
|
||||
if (a > b)
|
||||
@@ -50,7 +51,6 @@ game game_new_empty(void) {
|
||||
g->hist = history_insert_first(g->hist, F_ERROR, 0, 0);
|
||||
return g;
|
||||
}
|
||||
// TODO
|
||||
game game_copy(cgame g1) {
|
||||
game g2 = game_new_empty_ext(g1->height, g1->width, g1->wrapping);
|
||||
for (int i = 0; i < g2->height; i++) {
|
||||
|
||||
@@ -7,11 +7,12 @@
|
||||
|
||||
#ifndef __GAME_H__
|
||||
#define __GAME_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
/**
|
||||
* @brief Standard unsigned integer type.
|
||||
**/
|
||||
|
||||
typedef unsigned int uint;
|
||||
|
||||
/**
|
||||
@@ -57,15 +58,6 @@ typedef enum {
|
||||
/** square mask used in square enum */
|
||||
#define A_MASK 0xFF
|
||||
|
||||
#include "history.h"
|
||||
struct game_s {
|
||||
square** tab_cell;
|
||||
bool wrapping;
|
||||
uint height; // i in general
|
||||
uint width; // j in general
|
||||
history hist;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The structure pointer that stores the game state.
|
||||
**/
|
||||
@@ -217,6 +209,8 @@ bool game_is_black(cgame g, uint i, uint j);
|
||||
* @pre @p g must be a valid pointer toward a game structure.
|
||||
* @pre @p i < game height
|
||||
* @pre @p j < game width
|
||||
* @pre The square at position (i,j) must be a black wall (either numbered or
|
||||
* unumbered).
|
||||
* @return the back wall number, or -1 if it is unumbered
|
||||
**/
|
||||
int game_get_black_number(cgame g, uint i, uint j);
|
||||
@@ -319,4 +313,4 @@ bool game_is_over(cgame g);
|
||||
**/
|
||||
void game_restart(game g);
|
||||
|
||||
#endif // __GAME_H__
|
||||
#endif // __GAME_H__
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include "game.h"
|
||||
#include "game_private.h"
|
||||
|
||||
char charPrintCell(cgame g, uint i, uint j) {
|
||||
square sqState = game_get_state(g, i, j);
|
||||
|
||||
+2
-1
@@ -8,6 +8,7 @@
|
||||
#ifndef __GAME_AUX_H__
|
||||
#define __GAME_AUX_H__
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "game.h"
|
||||
|
||||
/**
|
||||
@@ -35,4 +36,4 @@ game game_default(void);
|
||||
**/
|
||||
game game_default_solution(void);
|
||||
|
||||
#endif // __GAME_AUX_H__
|
||||
#endif // __GAME_AUX_H__
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
#include "game_ext.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "game_private.h"
|
||||
|
||||
game game_new_ext(uint nb_rows, uint nb_cols, square* squares, bool wrapping) {
|
||||
game g = game_new_empty_ext(nb_rows, nb_cols, wrapping);
|
||||
@@ -37,7 +38,7 @@ game game_new_empty_ext(uint nb_rows, uint nb_cols, bool wrapping) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
g->hist = history_insert_first(g->hist,F_ERROR,0,0);
|
||||
g->hist = history_insert_first(g->hist, F_ERROR, 0, 0);
|
||||
return g;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
#ifndef __GAME_PRIVATE_H__
|
||||
#define __GAME_PRIVATE_H__
|
||||
#include "history.h"
|
||||
|
||||
struct game_s {
|
||||
square** tab_cell;
|
||||
bool wrapping;
|
||||
uint height; // i in general
|
||||
uint width; // j in general
|
||||
history hist;
|
||||
};
|
||||
|
||||
#endif
|
||||
+2
-1
@@ -6,6 +6,7 @@
|
||||
#include "game.h"
|
||||
#include "game_aux.h"
|
||||
#include "game_ext.h"
|
||||
#include "game_private.h"
|
||||
|
||||
bool test_dummy(void) {
|
||||
return true;
|
||||
@@ -410,7 +411,7 @@ int main(int argc, char* argv[]) {
|
||||
} else if (strcmp("game_nb_cols", argv[1]) == 0) {
|
||||
success = test_game_nb_cols();
|
||||
} else if (strcmp("game_is_wrapping", argv[1]) == 0) {
|
||||
success = test_game_is_wrapping();
|
||||
success = test_game_is_wrapping();
|
||||
} else {
|
||||
fprintf(stderr, "Error: test \"%s\" not found!\n", argv[1]);
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "game.h"
|
||||
#include "game_aux.h"
|
||||
#include "game_ext.h"
|
||||
#include "game_private.h"
|
||||
|
||||
typedef unsigned int uint;
|
||||
|
||||
/* ********** DUMMY ********** */
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "game.h"
|
||||
#include "game_aux.h"
|
||||
#include "game_ext.h"
|
||||
#include "game_private.h"
|
||||
|
||||
/* ********** DUMMY ********** */
|
||||
bool test_dummy() {
|
||||
|
||||
+2
-1
@@ -4,6 +4,7 @@
|
||||
#include "game.h"
|
||||
#include "game_aux.h"
|
||||
#include "game_ext.h"
|
||||
#include "game_private.h"
|
||||
|
||||
bool checkerr(cgame g, char taberr[]) {
|
||||
if (taberr == NULL || g == NULL) {
|
||||
@@ -78,7 +79,7 @@ int main(int argc, char* argv[]) {
|
||||
printf("Entrez une commande (h pour afficher l'aide): ");
|
||||
if (scanf(" %c", &c)) {
|
||||
if (c == 'h') {
|
||||
printhelp();
|
||||
printhelp();
|
||||
} else if (c == 'r') {
|
||||
game_restart(g);
|
||||
printf("Partie réinitialisé avec succes !\n");
|
||||
|
||||
Reference in new issue
Block a user