if (game->board.cells[x][y].type == DVONN_CELL_INVALID)
return TRUE;
- if (game->board.cells[x][y].type == DVONN_CELL_EMPTY)
- game->board.cells[x][y].type = DVONN_CELL_WHITE;
- else if (game->board.cells[x][y].type == DVONN_CELL_WHITE)
- game->board.cells[x][y].type = DVONN_CELL_EMPTY;
-
- dvonn_game_update_windows (game);
+ if (game->board.phase == DVONN_PHASE_PLACEMENT) {
+ if (dvonn_board_place (&game->board, x, y, &error))
+ dvonn_game_update_windows (game);
+ else
+ printf ("Illegal placement %c%d: %s\n",
+ 'a' + x,
+ y + 1,
+ error);
- return TRUE;
+ return TRUE;
+ }
if (! game->has_selected) {
if (game->board.cells[x][y].type == game->board.player) {
return TRUE;
}
- if (x == game->selected_x &&
- y == game->selected_y)
+ if (x == game->selected_x && y == game->selected_y)
{
game->has_selected = FALSE;
dvonn_game_update_windows (game);
} else {
printf ("Illegal move %c%d%c%d: %s\n",
'a' + game->selected_x,
- DVONN_BOARD_Y_SIZE - game->selected_y,
+ game->selected_y + 1,
'a' + x,
- DVONN_BOARD_Y_SIZE - y,
+ y + 1,
error);
}
x + (y - DVONN_BOARD_Y_SIZE/2) / 2.0,
M_SQRT1_2 * y);
ring_path (cr);
- if (cell.type == DVONN_CELL_WHITE)
+ switch (cell.type) {
+ case DVONN_CELL_WHITE:
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */
- else
+ break;
+ case DVONN_CELL_BLACK:
+ cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); /* black */
+ break;
+ case DVONN_CELL_RED:
+ cairo_set_source_rgb (cr, 0.8, 0.2, 0.2); /* red */
+ break;
+ case DVONN_CELL_EMPTY:
+ default:
cairo_set_source_rgba (cr, 0.0, 0.0, 0.2, 0.1);
+ break;
+ }
cairo_fill (cr);
cairo_restore (cr);