From: Carl Worth Date: Thu, 5 Mar 2009 17:42:08 +0000 (-0800) Subject: Implement right-click for pass X-Git-Url: https://git.cworth.org/git?p=dvonn;a=commitdiff_plain;h=c1c2fe84387af8e7d9fdea36fedc4482b48027c1 Implement right-click for pass An actual button would be better, but I'm being lazy as far as real UI again. --- diff --git a/dvonn-board.c b/dvonn-board.c index b6b36e5..4aaac54 100644 --- a/dvonn-board.c +++ b/dvonn-board.c @@ -192,6 +192,17 @@ dvonn_board_next_player (dvonn_board_t *board) board->player = DVONN_PLAYER_BLACK; } +int +dvonn_board_pass (dvonn_board_t *board) +{ + /* XXX: Should check here and only allow a pass if there are + * no legal moves. */ + + dvonn_board_next_player (board); + + return TRUE; +} + int dvonn_board_place (dvonn_board_t *board, int x, int y, diff --git a/dvonn-board.h b/dvonn-board.h index 66464d8..7a361c3 100644 --- a/dvonn-board.h +++ b/dvonn-board.h @@ -88,6 +88,12 @@ dvonn_board_move (dvonn_board_t *board, int x2, int y2, char **error); +/* Pass rather than moving, allowing the turn to pass to the + * opponent. This should only be allowed if there are no legal moves, + * but that is not yet enforced. Returns TRUE if the pass succeeds. */ +int +dvonn_board_pass (dvonn_board_t *board); + /* Is the cell at (x,y) occupied by a piece. Returns FALSE for all * out-of-bounds coordinates. */ dvonn_bool_t diff --git a/dvonn.c b/dvonn.c index 8ac72b1..94146ce 100644 --- a/dvonn.c +++ b/dvonn.c @@ -161,6 +161,13 @@ on_button_press_event (GtkWidget *widget, if (event->type >= GDK_2BUTTON_PRESS) return TRUE; + /* Right-click means pass, (yes, it would be better to add some + * actual UI elements... */ + if (event->button == 3) { + dvonn_board_pass (&game->board); + return TRUE; + } + x = event->x; y = event->y; layout_device_to_board (layout, &x, &y);