diff --git a/.vscode/settings.json b/.vscode/settings.json index 604d63d..8431ee7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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" diff --git a/game.c b/game.c index 40543b7..7c2ac5c 100644 --- a/game.c +++ b/game.c @@ -2,6 +2,7 @@ #include #include #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++) { diff --git a/game.h b/game.h index f1c54d2..4c0ecb0 100644 --- a/game.h +++ b/game.h @@ -7,11 +7,12 @@ #ifndef __GAME_H__ #define __GAME_H__ + #include + /** * @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__ \ No newline at end of file diff --git a/game_aux.c b/game_aux.c index 76a4335..6dd606f 100644 --- a/game_aux.c +++ b/game_aux.c @@ -1,6 +1,7 @@ #include #include #include "game.h" +#include "game_private.h" char charPrintCell(cgame g, uint i, uint j) { square sqState = game_get_state(g, i, j); diff --git a/game_aux.h b/game_aux.h index 294f997..1e425a6 100644 --- a/game_aux.h +++ b/game_aux.h @@ -8,6 +8,7 @@ #ifndef __GAME_AUX_H__ #define __GAME_AUX_H__ #include + #include "game.h" /** @@ -35,4 +36,4 @@ game game_default(void); **/ game game_default_solution(void); -#endif // __GAME_AUX_H__ +#endif // __GAME_AUX_H__ \ No newline at end of file diff --git a/game_ext.c b/game_ext.c index 6dd5270..8f8e486 100644 --- a/game_ext.c +++ b/game_ext.c @@ -1,6 +1,7 @@ #include "game_ext.h" #include #include +#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; } diff --git a/game_private.h b/game_private.h new file mode 100644 index 0000000..462e29e --- /dev/null +++ b/game_private.h @@ -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 \ No newline at end of file diff --git a/game_test_nnunes.c b/game_test_nnunes.c index 8d313c1..ef72fec 100644 --- a/game_test_nnunes.c +++ b/game_test_nnunes.c @@ -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); diff --git a/game_test_thoguet.c b/game_test_thoguet.c index 46e9821..8534665 100644 --- a/game_test_thoguet.c +++ b/game_test_thoguet.c @@ -6,6 +6,8 @@ #include "game.h" #include "game_aux.h" #include "game_ext.h" +#include "game_private.h" + typedef unsigned int uint; /* ********** DUMMY ********** */ diff --git a/game_test_thperrier.c b/game_test_thperrier.c index 65ac3dd..50e4749 100644 --- a/game_test_thperrier.c +++ b/game_test_thperrier.c @@ -6,6 +6,7 @@ #include "game.h" #include "game_aux.h" #include "game_ext.h" +#include "game_private.h" /* ********** DUMMY ********** */ bool test_dummy() { diff --git a/game_text.c b/game_text.c index 8621ed1..3e66832 100644 --- a/game_text.c +++ b/game_text.c @@ -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");