]> git.cworth.org Git - dvonn/blobdiff - dvonn-board.c
Add visual indication for non-red stacks containing a red piece
[dvonn] / dvonn-board.c
index f80277531ee7a8ee9bf71ba616a2e8c2ca69ea45..4d09e13be58f0ce25f2ee048bca2ea11391ee2b5 100644 (file)
@@ -63,6 +63,7 @@ dvonn_board_init (dvonn_board_t *board)
        for (y = 0; y < DVONN_BOARD_Y_SIZE; y++) {
            board->cells[x][y].type = DVONN_CELL_EMPTY;
            board->cells[x][y].height = 0;
+           board->cells[x][y].contains_red = FALSE;
        }
     }
 
@@ -140,12 +141,14 @@ dvonn_board_place (dvonn_board_t *board,
        return FALSE;
     }
 
-    if (board->moves < 3)
+    if (board->moves < 3) {
        board->cells[x][y].type = DVONN_CELL_RED;
-    else if (board->moves % 2)
+       board->cells[x][y].contains_red = TRUE;
+    } else if (board->moves % 2) {
        board->cells[x][y].type = DVONN_CELL_BLACK;
-    else
+    } else {
        board->cells[x][y].type = DVONN_CELL_WHITE;
+    }
 
     board->cells[x][y].height = 1;
 
@@ -175,9 +178,11 @@ dvonn_board_move (dvonn_board_t *board,
 
     board->cells[x2][y2].height += board->cells[x1][y1].height;
     board->cells[x2][y2].type = board->cells[x1][y1].type;
+    board->cells[x2][y2].contains_red |= board->cells[x1][y1].contains_red;
 
     board->cells[x1][y1].type = DVONN_CELL_EMPTY;
     board->cells[x1][y1].height = 0;
+    board->cells[x1][y1].contains_red = FALSE;
 
     dvonn_board_next_player (board);