edit game_new & game_new_empty + edit README
This commit is contained in:
1 parent
9e16c4d4dd
commit
307be81bb9
2 files changed
+26
-17
No files matched your search
@@ -8,8 +8,8 @@ Projet Techno
|
||||
|
||||
| Fonction | REF | Assigned to | Notes | Finished |
|
||||
| ------------------------------------ | ---------------------------------------------------------------------------- | ----------- | ----- | :--------------------: |
|
||||
| [game_new](./game.c#L?) | [game game_new(square *squares)](./game.h#L73-81) | @thperrier | | <ul><li>[ ] </li></ul> |
|
||||
| [game_new_empty](./game.c#L?) | [game game_new_empty(void)](./game.h#L83-88) | @thperrier | | <ul><li>[ ] </li></ul> |
|
||||
| [game_new](./game.c#L9-17) | [game game_new(square *squares)](./game.h#L73-81) | @thperrier | | <ul><li>[x] </li></ul> |
|
||||
| [game_new_empty](./game.c#L?) | [game game_new_empty(void)](./game.h#L83-88) | @thperrier | | <ul><li>[x] </li></ul> |
|
||||
| [game_copy](./game.c#L?) | [game game_copy(cgame g)](./game.h#L90-96) | @thperrier | | <ul><li>[ ] </li></ul> |
|
||||
| [game_equal](./game.c#L?) | [bool game_equal(cgame g1, cgame g2)](./game.h#L98-106) | @thperrier | | <ul><li>[ ] </li></ul> |
|
||||
| [game_delete](./game.c#L?) | [void game_delete(game g);](./game.h#L108-113) | @thperrier | | <ul><li>[ ] </li></ul> |
|
||||
|
||||
@@ -7,28 +7,37 @@ struct game_s {
|
||||
};
|
||||
|
||||
game game_new(square* squares) {
|
||||
game g = (game)malloc(sizeof(game));
|
||||
if (g == NULL) {
|
||||
fprintf(stderr, "not enough memory\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
g->tab_cell = (square**)malloc(sizeof(square**) * DEFAULT_SIZE);
|
||||
if (g->tab_cell == NULL) {
|
||||
fprintf(stderr, "not enough memory\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
game g = game_new_empty();
|
||||
for (int i = 0; i < DEFAULT_SIZE; i++) {
|
||||
g->tab_cell[i] = (square*)malloc(sizeof(square*) * DEFAULT_SIZE);
|
||||
if (g->tab_cell[i] == NULL) {
|
||||
fprintf(stderr, "not enough memory\n");
|
||||
exit(EXIT_FAILURE);
|
||||
for (int j = 0; j < DEFAULT_SIZE; j++) {
|
||||
g->tab_cell[i][j] = squares[DEFAULT_SIZE * i + j];
|
||||
}
|
||||
}
|
||||
return g;
|
||||
}
|
||||
|
||||
game game_new_empty(void) {
|
||||
return NULL;
|
||||
game g = (game)malloc(sizeof(game));
|
||||
if (g == NULL) {
|
||||
fprintf(stderr, "not enough memory\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
g->tab_cell = (square**)malloc(sizeof(square*) * DEFAULT_SIZE);
|
||||
if (g->tab_cell == NULL) {
|
||||
fprintf(stderr, "not enough memory\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
for (int i = 0; i < DEFAULT_SIZE; i++) {
|
||||
g->tab_cell[i] = (square*)malloc(sizeof(square) * DEFAULT_SIZE);
|
||||
if (g->tab_cell[i] == NULL) {
|
||||
fprintf(stderr, "not enough memory\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
for (int j = 0; j < DEFAULT_SIZE; j++) {
|
||||
g->tab_cell[i][j] = S_BLANK;
|
||||
}
|
||||
}
|
||||
return g;
|
||||
}
|
||||
|
||||
game game_copy(cgame g) {
|
||||
|
||||
Reference in new issue
Block a user