Add WIP on the playable shots list displaying
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sat, 3 Jun 2017 15:27:36 +0000 (17:27 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Sat, 3 Jun 2017 15:27:36 +0000 (17:27 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
Makefile
lib/othello.c
src/main.c

index 584ff34828b62514bab181bdaaa46dd8ffa1563b..6ff0b81a95e20711ead308b7240e7349d6242e77 100644 (file)
--- a/Makefile
+++ b/Makefile
 # 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
 
index 5d9970c6941a0942d8e948a90541a0a55a06fdbd..4f1b83ec52cd1b8cda16f1696b85c56a9e499b4b 100644 (file)
@@ -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;
+    }
+}
index ce7c8a6b98a13d1f0636c8f0130fb34a701fd9ba..b0bf5b91dcfbd259bcd87554a78b9b5bf3ec5e36 100644 (file)
@@ -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},