Commit 6394f0e4 authored by Jonathan Michalon's avatar Jonathan Michalon
Browse files

Bots play together!

Forward TILE_PLACED signals. Now bots play together on the same game.
Hurra !!!
parent 313278d0
......@@ -76,6 +76,8 @@ public class Bot : OVCCClient.Client
for (var j = 0; j < 4; j++) {
/* FIXME: this should probably be asynchronous... */
if (player.place_tile (npos)) {
debug ("Placed tile ID %u at %d %d angle %u", tile.id,
npos.x, npos.y, tile.rotation);
return false;
} else {
tile.rotate (1);
......
......@@ -35,10 +35,7 @@ namespace OVCC.Network
PLAYER_ADDED,
PLAYER_REMOVED,
GAME_STATE,
PLACE_TILE,
PLACE_PAWN,
CURRENT_TILE_CHANGED,
CURRENT_PLAYER_CHANGED,
TILE_PLACED,
TYPES_N;
}
......@@ -91,6 +88,10 @@ namespace OVCC.Network
send_to_peer (SignalType.GAME_STATE, "i", state);
// }
});
handle_ids[SignalType.TILE_PLACED] =
game_object.board.tile_added.connect ((t, p) => {
send_to_peer (SignalType.TILE_PLACED, "(iiu)", p.x, p.y, t.rotation);
});
/* incoming signal messages handling */
signal_received.connect ((msg) => {
......@@ -140,6 +141,17 @@ namespace OVCC.Network
}
resume_forward (game_object, SignalType.GAME_STATE);
});
signal_received[SignalType.TILE_PLACED.to_string ()].connect ((msg) => {
Position p = Position();
uint r;
msg.parse ("(iiu)", out p.x, out p.y, out r);
debug ("Current player '%s' placed tile with ID %u at %d %d, angle %u",
game_object.current_player.nick, game_object.current_tile.id, p.x, p.y, r);
game_object.current_tile.rotate ((int) r);
stop_forward (game_object.board, SignalType.TILE_PLACED);
game_object.current_player.place_tile (p);
resume_forward (game_object.board, SignalType.TILE_PLACED);
});
}
private void send_to_peer (SignalType s, string format, ...)
......
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