summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2009-06-01 23:34:26 -0500
committerJesse Luehrs <doy@tozt.net>2009-06-01 23:34:26 -0500
commit788d8e02c55ae4a336976cc5d809d8b152d4ae7f (patch)
tree46df8225802dc94bce9016f985b710dba9e96ff9
parentf4085a9faff3ab82600e306f587b2d84e0104108 (diff)
downloadbot-games-788d8e02c55ae4a336976cc5d809d8b152d4ae7f.tar.gz
bot-games-788d8e02c55ae4a336976cc5d809d8b152d4ae7f.zip
only allow players to move on their turn
-rw-r--r--lib/Bot/Games/Game/Chess.pm3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/Bot/Games/Game/Chess.pm b/lib/Bot/Games/Game/Chess.pm
index 473fe21..abd94fd 100644
--- a/lib/Bot/Games/Game/Chess.pm
+++ b/lib/Bot/Games/Game/Chess.pm
@@ -31,6 +31,9 @@ augment turn => sub {
$self->add_player($player) unless $self->has_player($player);
return "The game has already begun between " . join ' and ', $self->players
unless $self->has_player($player);
+ my $player_index = $self->game->to_move ? 0 : 1;
+ return "It's not your turn"
+ if $player ne $self->players->[$player_index];
my $status = eval { $self->game->go_move($move) };
return $@ if $@;