From eb5197e67e600ceb1e30df3d741c70c5024082db Mon Sep 17 00:00:00 2001 From: doy Date: Mon, 27 Apr 2009 00:43:17 -0500 Subject: invert the sense of the is_over attribute (make it is_active) --- lib/Bot/Games.pm | 4 ++-- lib/Bot/Games/Game.pm | 3 +-- lib/Bot/Games/Game/24.pm | 4 ++-- lib/Bot/Games/Game/Ghost.pm | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/Bot/Games.pm b/lib/Bot/Games.pm index cd2d24f..25d6ab6 100644 --- a/lib/Bot/Games.pm +++ b/lib/Bot/Games.pm @@ -85,7 +85,7 @@ sub said { && (!defined($action) || $action !~ /^-/)) { $self->$say($game->init($args->{who})) if $game->can('init'); $self->done_init->{$game_name} = 1; - $self->active_games->{$game_name}->is_over(0); + $self->active_games->{$game_name}->is_active(1); } return unless defined $action; @@ -117,7 +117,7 @@ sub said { $self->$say($turn) if $turn; } - if ($game->is_over) { + if (!$game->is_active) { delete $self->active_games->{$game_name}; delete $self->done_init->{$game_name}; } diff --git a/lib/Bot/Games/Game.pm b/lib/Bot/Games/Game.pm index 4b848be..1b4310b 100644 --- a/lib/Bot/Games/Game.pm +++ b/lib/Bot/Games/Game.pm @@ -45,10 +45,9 @@ has last_turn_time => ( formatter => sub { _diff_from_now(shift) }, ); -has is_over => ( +has is_active => ( is => 'rw', isa => 'Bool', - default => 1, command => 1, needs_init => 0, ); diff --git a/lib/Bot/Games/Game/24.pm b/lib/Bot/Games/Game/24.pm index ed5263d..029bf81 100644 --- a/lib/Bot/Games/Game/24.pm +++ b/lib/Bot/Games/Game/24.pm @@ -36,7 +36,7 @@ augment turn => sub { my $eval = $self->evaluate($expr); if (defined($eval) && $eval == 24) { - $self->is_over(1); + $self->is_active(0); return "$player wins! (" . concise(duration_exact(time - $self->start_time->epoch)) . ")"; @@ -48,7 +48,7 @@ augment turn => sub { command give_up => sub { my $self = shift; - $self->is_over(1); + $self->is_active(0); return $self->solution; }; diff --git a/lib/Bot/Games/Game/Ghost.pm b/lib/Bot/Games/Game/Ghost.pm index 1c8f9f7..d1f7267 100644 --- a/lib/Bot/Games/Game/Ghost.pm +++ b/lib/Bot/Games/Game/Ghost.pm @@ -85,7 +85,7 @@ command challenge => sub { return "$word is not valid for state " . $self->state . "!" unless $self->valid_word_from_state($word); - $self->is_over(1); + $self->is_active(0); # if there is a challenger, then this is a response by the current # player, so if it's valid, the challenger loses, otherwise the current # player loses. if there isn't a challenger, then this is asserting -- cgit v1.2.3-54-g00ecf