summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordoy <doy@tozt.net>2009-01-25 02:22:52 -0500
committerdoy <doy@tozt.net>2009-01-25 02:22:52 -0500
commitd9eeef50ec74526248551a80dc9df665f22f1059 (patch)
tree586615dce0eefc65907f62db159aa485674b7a26
parent8a875ee303a3533011c7e0d5326de86d6ffdc5ea (diff)
downloadbot-games-d9eeef50ec74526248551a80dc9df665f22f1059.tar.gz
bot-games-d9eeef50ec74526248551a80dc9df665f22f1059.zip
allow games to return '' from their turn method without the base class whining
-rw-r--r--lib/Bot/Games/Game.pm6
-rw-r--r--lib/Bot/Games/Game/24.pm2
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/Bot/Games/Game.pm b/lib/Bot/Games/Game.pm
index e0f4a2d..1ac4005 100644
--- a/lib/Bot/Games/Game.pm
+++ b/lib/Bot/Games/Game.pm
@@ -44,7 +44,11 @@ has is_over => (
command => 1,
);
-sub turn { inner() || "Games must provide a turn method" }
+sub turn {
+ my $turn = inner();
+ return $turn if defined($turn);
+ return "Games must provide a turn method";
+}
after turn => sub { shift->last_turn_time(DateTime->now) };
__PACKAGE__->meta->make_immutable;
diff --git a/lib/Bot/Games/Game/24.pm b/lib/Bot/Games/Game/24.pm
index 1e339e0..c049865 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 ($eval == 24) {
$self->is_over("$player wins!");
- return;
+ return '';
}
else {
return $eval;