diff options
author | Jesse Luehrs <doy@tozt.net> | 2009-06-01 23:34:26 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2009-06-01 23:34:26 -0500 |
commit | 788d8e02c55ae4a336976cc5d809d8b152d4ae7f (patch) | |
tree | 46df8225802dc94bce9016f985b710dba9e96ff9 /lib/Bot/Games/Game | |
parent | f4085a9faff3ab82600e306f587b2d84e0104108 (diff) | |
download | bot-games-788d8e02c55ae4a336976cc5d809d8b152d4ae7f.tar.gz bot-games-788d8e02c55ae4a336976cc5d809d8b152d4ae7f.zip |
only allow players to move on their turn
Diffstat (limited to 'lib/Bot/Games/Game')
-rw-r--r-- | lib/Bot/Games/Game/Chess.pm | 3 |
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 $@; |