From 7aab9e03ce0779a461044f56bc3f478e1c8d2460 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 3 Jun 2017 17:27:36 +0200 Subject: [PATCH] Add WIP on the playable shots list displaying MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- Makefile | 5 ++--- lib/othello.c | 31 +++++++++++++++++++++++++++++++ src/main.c | 12 +++--------- 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 584ff34..6ff0b81 100644 --- a/Makefile +++ b/Makefile @@ -19,10 +19,9 @@ # http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/#tldr BINARY_NAME:=othello SRC_PATH:=src -# will add -lothello automagically linking flags -LIBRARY_NAME:=libothello +LIBRARY_NAME:=lib$(BINARY_NAME) LIBRARY_PATH:=lib -LDLIBS:=-lncurses -ltinfo +LDLIBS:=-l$(BINARY_NAME) -lncurses -ltinfo BUILD_TYPE:=debug #BUILD_TYPE:=release diff --git a/lib/othello.c b/lib/othello.c index 5d9970c..4f1b83e 100644 --- a/lib/othello.c +++ b/lib/othello.c @@ -253,3 +253,34 @@ unsigned int valid_shot(int y, int x, unsigned int current_player, unsigned int set_pawn(y, x, current_player, pawn_array); return nb_pawns_reversed; } + +struct shots_list_s build_playable_shots_list(int y, int x, unsigned int current_player, unsigned int pawn_array[board_size][board_size]) { + + for (unsigned int i = 0; i <= board_size; i++) { + for (unsigned int j = 0; j <= board_size; j++) { + if (is_legal_shot(y, x, current_player, pawn_array)) { + + } + } + } +} + +void create_shots_list_cell(struct shots_list_s* shots_list_cell) { + +} + +static void set_shots_list_coordinates(int y, int x, struct shots_list_s* shots_list) { + + if (is_valid_coordinates(y, x)) { + shots_list->y = y; + shots_list->x = x; + } +} + +void set_shots_lists_cell(int y, int x, unsigned int type, struct shots_list_s* shots_list) { + + if (type > 0 && type < 5) { + set_shots_list_coordinates(y, x, shots_list); + shots_list->type = type; + } +} diff --git a/src/main.c b/src/main.c index ce7c8a6..b0bf5b9 100644 --- a/src/main.c +++ b/src/main.c @@ -23,15 +23,9 @@ int main() { char* draw_msg = "Egalite !"; char* exit_msg = "Pressez une touche pour sortir ou \'r\' pour rejouer"; - /* linked list of the history shots */ - //struct shots_history_list_s shots_history; - //INIT_LIST_HEAD(&shots_history.list); - /* linked list of black playable shots */ - struct shots_list_s black_playable_shots; - INIT_LIST_HEAD(&black_playable_shots.list); - /* linked list of white playable shots */ - struct shots_list_s white_playable_shots; - INIT_LIST_HEAD(&white_playable_shots.list); + /* linked list of playable shots */ + struct shots_list_s playable_shots; + INIT_LIST_HEAD(&playable_shots.list); unsigned int pawns[board_size][board_size] = { {0, 0}, -- 2.34.1