Commit d7fbae9f authored by Jonathan Michalon's avatar Jonathan Michalon

OVCCGtk: skip pawn placement step if impossible to do so

parent 2e0dd3ac
......@@ -700,6 +700,29 @@ client_place_tile_handler (OVCCClientClient *client,
gtk_action_set_sensitive (app->actions.game.rotate_tile_counterclockwise, TRUE);
}
static int
check_pawn_placeable (OVCCClientClient *client,
OVCCPosition *pos,
App *app)
{
OVCCPlayer *me = ovccclient_client_get_player (client);
OVCCBoard *board = ovccgtk_board_get_board (OVCCGTK_BOARD (app->board));
OVCCTile *tile = ovcc_board_get_tile (board, pos);
for (int i = 0; i < OVCC_PAWN_KIND_N_KINDS; i++) {
if (ovcc_player_get_remaining_pawn_count (me, i) > 0) {
for (GSList *objs = ovcc_tile_get_objects (tile); objs; objs = objs->next) {
OVCCTileObject *obj = objs->data;
if (ovcc_board_add_pawn_check (board, i, obj, pos))
return TRUE; /* possible to place a pawn */
}
}
}
return FALSE;
}
static void
client_place_pawn_handler (OVCCClientClient *client,
OVCCPosition *pos,
......@@ -710,6 +733,9 @@ client_place_pawn_handler (OVCCClientClient *client,
gtk_widget_set_sensitive (app->current_tile_image, FALSE);
gtk_action_set_sensitive (app->actions.game.rotate_tile_clockwise, FALSE);
gtk_action_set_sensitive (app->actions.game.rotate_tile_counterclockwise, FALSE);
if (! check_pawn_placeable (client, pos, app))
finish_turn (app);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment