From 880dfe8177549891a31f1632821f6fdefbd69c4f Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 2 Jun 2009 18:52:25 -0500 Subject: move maybe_add_player to the currentplayer role --- lib/Bot/Games/Game/Ghost.pm | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'lib/Bot/Games/Game/Ghost.pm') diff --git a/lib/Bot/Games/Game/Ghost.pm b/lib/Bot/Games/Game/Ghost.pm index 8a3a9c6..6f8ad83 100644 --- a/lib/Bot/Games/Game/Ghost.pm +++ b/lib/Bot/Games/Game/Ghost.pm @@ -118,15 +118,12 @@ command valid_word_from_state => sub { return uc($word_prefix) eq $self->state; }, formatter => 'Bool'; -sub maybe_add_player { +around maybe_add_player => sub { + my $orig = shift; my $self = shift; - my ($player) = @_; - if (!$self->has_challenger && !grep { $player eq $_ } $self->players) { - if ($self->add_player($player)) { - $self->current_player($player); - } - } -} + return if $self->has_challenger; + return $self->$orig(@_); +}; __PACKAGE__->meta->make_immutable; no Bot::Games::OO::Game; -- cgit v1.2.3-54-g00ecf