From 58abef31ecd7d26f9d0b4a2eb8cc960f0e16f6f5 Mon Sep 17 00:00:00 2001 From: Nathan Nunes Date: Wed, 1 Dec 2021 17:28:30 +0100 Subject: [PATCH] commit game_get_state / game_get_flags --- README.md | 4 ++-- game.c | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b0fc76f..fc98f24 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,8 @@ Projet Techno | [game_delete](./game.c#L64-72) | [void game_delete(game g);](./game.h#L108-113) | @thperrier | | | | [game_set_square](./game.c#L?) | [void game_set_square(game g, uint i, uint j, square s)](./game.h#L115-128) | @nnunes | | | | [game_get_square](./game.c#L78-80) | [square game_get_square(cgame g, uint i, uint j)](./game.h#L130-140) | @thoguet | | | -| [game_get_state](./game.c#L?) | [square game_get_state(cgame g, uint i, uint j)](./game.h#L142-153) | @nnunes | | | -| [game_get_flags](./game.c#L?) | [square game_get_flags(cgame g, uint i, uint j)](./game.h#L155-166) | @nnunes | | | +| [game_get_state](./game.c#L?) | [square game_get_state(cgame g, uint i, uint j)](./game.h#L142-153) | @nnunes | | | +| [game_get_flags](./game.c#L?) | [square game_get_flags(cgame g, uint i, uint j)](./game.h#L155-166) | @nnunes | | | | [game_is_blank](./game.c#L?) | [bool game_is_blank(cgame g, uint i, uint j)](./game.h#L168-178) | @thperrier | | | | [game_is_lightbulb](./game.c#L?) | [bool game_is_lightbulb(cgame g, uint i, uint j)](./game.h#L180-190) | @thperrier | | | | [game_is_black](./game.c#L98-102) | [bool game_is_black(cgame g, uint i, uint j)](./game.h#L192-202) | @thoguet | | | diff --git a/game.c b/game.c index 2f0eada..412a0f1 100644 --- a/game.c +++ b/game.c @@ -81,11 +81,27 @@ square game_get_square(cgame g, uint i, uint j) { } square game_get_state(cgame g, uint i, uint j) { - return 0; + if(g->tab_cell[i][j] >= F_ERROR) { + g->tab_cell[i][j] -= F_ERROR; + } + if(g->tab_cell[i][j] >= F_LIGHTED) { + g->tab_cell[i][j] -= F_LIGHTED; + } + return g->tab_cell[i][j]; } square game_get_flags(cgame g, uint i, uint j) { - return 0; + if (g->tab_cell[i][j] >= F_ERROR) { + g->tab_cell[i][j] -= F_ERROR; + if (g->tab_cell[i][j] >= F_LIGHTED) { + return (F_ERROR|F_LIGHTED); + } + return (F_ERROR); + } + if (g->tab_cell[i][j] >= F_LIGHTED) { + return (F_LIGHTED); + } + return (S_BLANK); } bool game_is_blank(cgame g, uint i, uint j) {