summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordoy <doy@tozt.net>2009-04-27 17:33:51 -0500
committerdoy <doy@tozt.net>2009-04-27 17:33:51 -0500
commit01317ece9f8b8b07d438afcbd6de2df557fac4fe (patch)
treea69add8d007d46da2e8ff3774c3d48fc0715ba30
parente80ea4c3328f5d2919d9f4bc09247004de07ec4a (diff)
downloadbot-games-01317ece9f8b8b07d438afcbd6de2df557fac4fe.tar.gz
bot-games-01317ece9f8b8b07d438afcbd6de2df557fac4fe.zip
the games themselves keep track of whether or not they are active, don't need to also track it in the bot
-rw-r--r--lib/Bot/Games.pm14
1 files changed, 3 insertions, 11 deletions
diff --git a/lib/Bot/Games.pm b/lib/Bot/Games.pm
index 25d6ab6..653e9da 100644
--- a/lib/Bot/Games.pm
+++ b/lib/Bot/Games.pm
@@ -18,13 +18,6 @@ has active_games => (
default => sub { {} },
);
-has done_init => (
- is => 'ro',
- isa => 'HashRef[Bool]',
- lazy => 1,
- default => sub { {} },
-);
-
has alias => (
is => 'ro',
isa => 'HashRef[Str]',
@@ -81,10 +74,9 @@ sub said {
$game = $game_package->new;
$self->active_games->{$game_name} = $game;
}
- if (!$self->done_init->{$game_name}
+ if (!$self->active_games->{$game_name}->is_active
&& (!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_active(1);
}
@@ -95,7 +87,8 @@ sub said {
# XXX: maybe the meta stuff should get pushed out into the plugins
# themselves, and this should become $game->meta->get_command or so?
if (my $method_meta = _get_command($game, $action)) {
- if ($method_meta->needs_init && !$self->done_init->{$game_name}) {
+ if ($method_meta->needs_init
+ && !$self->active_games->{$game_name}->is_active) {
$self->$say("Game $game_name hasn't started yet!");
return;
}
@@ -119,7 +112,6 @@ sub said {
if (!$game->is_active) {
delete $self->active_games->{$game_name};
- delete $self->done_init->{$game_name};
}
return;