show/hide positions
authorLaurent Mazet <mazet@softndesign.org>
Thu, 19 Sep 2024 20:19:56 +0000 (22:19 +0200)
committerLaurent Mazet <mazet@softndesign.org>
Thu, 19 Sep 2024 20:36:26 +0000 (22:36 +0200)
display.c
reversi.c

index 98021de5d9ecc87d2dc018e8e136b6cbf39fcdff..2b9f495608e2f0838c9a6db739bdba36f6b96b43 100644 (file)
--- a/display.c
+++ b/display.c
@@ -85,7 +85,7 @@ void _put_color_block (int y, int x, char symb)
         mvaddcb (y, x, lighterred);
         break;
     case '4':
-        mvaddcb (y, x, lightergreen);
+        mvaddcb (y, x, yellow);
         break;
     }
 }
index 67ffb36cda349c6b5cf08af06c11273c664a831b..5eb26a76cbb823df5324e8847d218b9cae81d022 100644 (file)
--- a/reversi.c
+++ b/reversi.c
@@ -20,13 +20,14 @@ char *version = "0.1";
 
 char *filename = NULL;
 int scale = 1;
-char *boardname = "12x12";
+char *boardname = "8x8";
 
 char *help =
     "<i> Move up cursor\n"
     "<j> Move left cursor\n"
     "<k> Move down cursor\n"
     "<l> Move right cursor\n"
+    "<m> Show/Hide positions\n"
     "<o> Hold/Release piece\n"
     "<q> Quit\n"
     "<s> Save file\n"
@@ -171,17 +172,31 @@ int main (int argc, char *argv[])
 
     /* main loop */
     int stop = 0;
+    int showpos = 0;
     int id = 0;
     int mode = 0;
     while (!stop) {
 
+        /* board */
         board_t *boardturn = copyboard (board);
-        int ret = find (boardturn, id);
-        boardwindow (boardturn, 0);
+        if (!find (boardturn, id)) {
+            id = id ? 0 : 1;
+            if (!find (boardturn, id)) {
+                mode = 1;
+            }
+        }
+        boardwindow ((showpos) ? boardturn : board, 0);
         freeboard (boardturn);
 
-        displaycursor (board, id, xcursor, ycursor);
+        /* cursor */
+        if (!mode) {
+            displaycursor (board, id, xcursor, ycursor);
+        }
+
+        /* message */
+
 
+        /* get key press */
         int ch = getch ();
 
         /* general controls */
@@ -214,7 +229,7 @@ int main (int argc, char *argv[])
         case KEY_DELETE:
         case 127:
         case 'u':
-            id = (id == 0) ? 1 : 0;
+            id = id ? 0 : 1;
             break;
         case KEY_UP:
         case 'i':
@@ -240,12 +255,15 @@ int main (int argc, char *argv[])
                 xcursor++;
             }
             break;
+        case 'm':
+            showpos = showpos ? 0 : 1;
+            break;
         case '\n':
         case '\r':
         case ' ':
         case 'o':
             if (putdisk (board, xcursor, ycursor, id)) {
-                id = (id == 0) ? 1 : 0;
+                id = id ? 0 : 1;
             }
             break;
         }