bool wrapped -> wrapping + edit game copy add hist
This commit is contained in:
1 parent
e85b0f1777
commit
00b8f92e0c
3 files changed
+9
-4
No files matched your search
@@ -26,7 +26,7 @@ game game_new_empty(void) {
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
// set variable of struct
|
// set variable of struct
|
||||||
g->wrapped = false;
|
g->wrapping = false;
|
||||||
g->height = DEFAULT_SIZE;
|
g->height = DEFAULT_SIZE;
|
||||||
g->width = DEFAULT_SIZE;
|
g->width = DEFAULT_SIZE;
|
||||||
g->hist = NULL;
|
g->hist = NULL;
|
||||||
@@ -50,12 +50,17 @@ game game_new_empty(void) {
|
|||||||
}
|
}
|
||||||
// TODO
|
// TODO
|
||||||
game game_copy(cgame g1) {
|
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 i = 0; i < g2->height; i++) {
|
||||||
for (int j = 0; j < g2->width; j++) {
|
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];
|
g2->tab_cell[i][j] = g1->tab_cell[i][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return g2;
|
return g2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ typedef enum {
|
|||||||
#include "history.h"
|
#include "history.h"
|
||||||
struct game_s {
|
struct game_s {
|
||||||
square** tab_cell;
|
square** tab_cell;
|
||||||
bool wrapped;
|
bool wrapping;
|
||||||
uint height; // i in general
|
uint height; // i in general
|
||||||
uint width; // j in general
|
uint width; // j in general
|
||||||
history hist;
|
history hist;
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ game game_new_empty_ext(uint nb_rows, uint nb_cols, bool wrapping) {
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
// set variable of struct
|
// set variable of struct
|
||||||
g->wrapped = wrapping;
|
g->wrapping = wrapping;
|
||||||
g->height = nb_rows;
|
g->height = nb_rows;
|
||||||
g->width = nb_cols;
|
g->width = nb_cols;
|
||||||
g->hist = history_create_empty();
|
g->hist = history_create_empty();
|
||||||
|
|||||||
Reference in new issue
Block a user