From 00b8f92e0c9776df2ac295b6486168cad0dc11e4 Mon Sep 17 00:00:00 2001 From: thibault perrier Date: Fri, 10 Dec 2021 19:52:55 +0100 Subject: [PATCH] bool wrapped -> wrapping + edit game copy add hist --- game.c | 9 +++++++-- game.h | 2 +- game_ext.c | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/game.c b/game.c index f65b0be..34c4e19 100644 --- a/game.c +++ b/game.c @@ -26,7 +26,7 @@ game game_new_empty(void) { exit(EXIT_FAILURE); } // set variable of struct - g->wrapped = false; + g->wrapping = false; g->height = DEFAULT_SIZE; g->width = DEFAULT_SIZE; g->hist = NULL; @@ -50,10 +50,15 @@ game game_new_empty(void) { } // TODO game game_copy(cgame g1) { - game g2 = game_new_empty(); + game g2 = game_new_empty_ext(g1->height, g1->width, g1->wrapping); for (int i = 0; i < g2->height; i++) { for (int j = 0; j < g2->width; j++) { + if (g1->tab_cell[i][j] == (S_BLANK | S_LIGHTBULB | S_MARK)){ + game_play_move(g2, i, j, g1->tab_cell[i][j]); + } + else { g2->tab_cell[i][j] = g1->tab_cell[i][j]; + } } } return g2; diff --git a/game.h b/game.h index fb82e34..f1c54d2 100644 --- a/game.h +++ b/game.h @@ -60,7 +60,7 @@ typedef enum { #include "history.h" struct game_s { square** tab_cell; - bool wrapped; + bool wrapping; uint height; // i in general uint width; // j in general history hist; diff --git a/game_ext.c b/game_ext.c index 39a7866..ee7854e 100644 --- a/game_ext.c +++ b/game_ext.c @@ -20,7 +20,7 @@ game game_new_empty_ext(uint nb_rows, uint nb_cols, bool wrapping) { exit(EXIT_FAILURE); } // set variable of struct - g->wrapped = wrapping; + g->wrapping = wrapping; g->height = nb_rows; g->width = nb_cols; g->hist = history_create_empty();