Commit c0158ca6 authored by Colomban Wendling's avatar Colomban Wendling
Browse files

LibOVCC: make turn finish explicit

Now players must explicitly notify that they finished their turn.
This will be needed for pawn placing.
parent 958925d6
......@@ -106,6 +106,7 @@ public class Bot : OVCCClient.Client
// break;
// }
}
game.turn_finished ();
}));
......
......@@ -578,6 +578,7 @@ on_tile_add_request (OVCCGtkBoard *board,
player = ovccclient_client_get_player (OVCCCLIENT_CLIENT (app->client));
if (ovcc_player_place_tile (player, pos)) {
g_debug ("OK, placed.");
g_signal_emit_by_name (app->game, "turn-finished");
}
} else {
show_message (GTK_WINDOW (app->main_window), GTK_MESSAGE_INFO,
......
......@@ -36,6 +36,7 @@ namespace OVCC.Network
PLAYER_REMOVED,
GAME_STATE,
TILE_PLACED,
TURN_FINISHED,
TYPES_N;
}
......@@ -92,6 +93,11 @@ namespace OVCC.Network
game_object.board.tile_added.connect ((t, p) => {
send_to_peer (SignalType.TILE_PLACED, "(iiu)", p.x, p.y, t.rotation);
});
handle_ids[SignalType.TURN_FINISHED] =
game_object.turn_finished.connect (() => {
/* actually we don't want to send anything, but currently we can't */
send_to_peer (SignalType.TURN_FINISHED, "i", 42);
});
/* incoming signal messages handling */
signal_received.connect ((msg) => {
......@@ -160,6 +166,13 @@ namespace OVCC.Network
game_object.current_player.place_tile (p);
resume_forward (game_object.board, SignalType.TILE_PLACED);
});
signal_received[SignalType.TURN_FINISHED.to_string ()].connect ((msg) => {
debug ("Current player '%s' finished its turn",
game_object.current_player.nick);
stop_forward (game_object, SignalType.TURN_FINISHED);
game_object.turn_finished ();
resume_forward (game_object, SignalType.TURN_FINISHED);
});
}
private void send_to_peer (SignalType s, string format, ...)
......
......@@ -77,6 +77,10 @@ namespace OVCC
public signal void player_added (Player p);
public signal void player_removed (Player p);
public signal void unplaceable_tile (Tile t);
/**
* A signal to be emitted when a player finished its turn
*/
public signal void turn_finished ();
public Game (TileSet ts, Stack? s = null)
......@@ -109,6 +113,7 @@ namespace OVCC
this.player_removed.connect ((p) => {
this.notify_property ("players");
});
this.turn_finished.connect (() => next_player ());
}
/**
......@@ -188,7 +193,6 @@ namespace OVCC
tile = stack.peek ();
if (board.add_tile (tile, pos)) {
stack.pop ();
next_player ();
placed = true;
}
}
......
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