bool wrapped -> wrapping + edit game copy add hist

This commit is contained in:
thibault perrier committed 2021-12-10 19:52:55 +01:00
1 parent e85b0f1777
commit 00b8f92e0c
3 files changed
+9 -4

No files matched your search

+7 -2
View File
@@ -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;
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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();