From d9eeef50ec74526248551a80dc9df665f22f1059 Mon Sep 17 00:00:00 2001 From: doy Date: Sun, 25 Jan 2009 02:22:52 -0500 Subject: allow games to return '' from their turn method without the base class whining --- lib/Bot/Games/Game.pm | 6 +++++- lib/Bot/Games/Game/24.pm | 2 +- 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; -- cgit v1.2.3-54-g00ecf