summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2009-06-02 01:24:13 -0500
committerJesse Luehrs <doy@tozt.net>2009-06-02 01:24:13 -0500
commitcbe5cf384a5fe0933fdf16099dad1bb7b928c00e (patch)
tree1f43038c6a3c0d9e36e90d77417d5b890f819ee8
parent83c5f5f920656948d0528320c28150c618593ff6 (diff)
downloadbot-games-cbe5cf384a5fe0933fdf16099dad1bb7b928c00e.tar.gz
bot-games-cbe5cf384a5fe0933fdf16099dad1bb7b928c00e.zip
use the CurrentPlayer role in the chess plugin
-rw-r--r--lib/Bot/Games/Game/Chess.pm5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/Bot/Games/Game/Chess.pm b/lib/Bot/Games/Game/Chess.pm
index fb32c9d..ad4549c 100644
--- a/lib/Bot/Games/Game/Chess.pm
+++ b/lib/Bot/Games/Game/Chess.pm
@@ -1,6 +1,7 @@
package Bot::Games::Game::Chess;
use Bot::Games::OO::Game;
extends 'Bot::Games::Game';
+with 'Bot::Games::Game::Role::CurrentPlayer';
use Chess::Rep;
use App::Nopaste;
@@ -31,9 +32,8 @@ 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] || '');
+ if $player ne $self->current_player;
my $status = eval { $self->game->go_move($move) };
return $@ if $@;
@@ -41,6 +41,7 @@ augment turn => sub {
$self->inc_turn if $self->game->to_move;
$self->is_active(0) if $self->game->status->{mate}
|| $self->game->status->{stalemate};
+ $self->current_player($self->next_player);
return "$desc: " . App::Nopaste::nopaste(text => $self->game->dump_pos,
desc => $desc,