summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordoy <doy@tozt.net>2009-04-24 23:28:38 -0500
committerdoy <doy@tozt.net>2009-04-24 23:28:38 -0500
commitc635cf5996f9ec6439b8eaee284681014451583d (patch)
tree69818ab6cb240c4024ca9be0d05dea09cfc931b4
parent2bb2c85f4cd80117df0bfb25330b57b5eeb0474f (diff)
downloadbot-games-c635cf5996f9ec6439b8eaee284681014451583d.tar.gz
bot-games-c635cf5996f9ec6439b8eaee284681014451583d.zip
get rid of the 'ghostlike' abstract base, and have other ghostlike games just inherit from ghost directly
-rw-r--r--lib/Bot/Games.pm1
-rw-r--r--lib/Bot/Games/Game/Ghost.pm (renamed from lib/Bot/Games/Game/Ghostlike.pm)12
-rw-r--r--lib/Bot/Games/Game/Spook.pm2
-rw-r--r--lib/Bot/Games/Game/Superghost.pm2
-rw-r--r--lib/Bot/Games/Game/Xghost.pm2
5 files changed, 13 insertions, 6 deletions
diff --git a/lib/Bot/Games.pm b/lib/Bot/Games.pm
index 83516bb..599927b 100644
--- a/lib/Bot/Games.pm
+++ b/lib/Bot/Games.pm
@@ -3,7 +3,6 @@ package Bot::Games;
use Bot::Games::OO;
use Module::Pluggable
search_path => 'Bot::Games::Game',
- except => ['Bot::Games::Game::Ghostlike'],
sub_name => 'games';
extends 'Bot::BasicBot';
diff --git a/lib/Bot/Games/Game/Ghostlike.pm b/lib/Bot/Games/Game/Ghost.pm
index fc6229a..093b013 100644
--- a/lib/Bot/Games/Game/Ghostlike.pm
+++ b/lib/Bot/Games/Game/Ghost.pm
@@ -1,9 +1,13 @@
#!/usr/bin/perl
-package Bot::Games::Game::Ghostlike;
+package Bot::Games::Game::Ghost;
use Bot::Games::OO;
use Games::Word::Wordlist;
extends 'Bot::Games::Game';
+has '+help' => (
+ default => "ghost help",
+);
+
has current_player => (
is => 'rw',
isa => 'Str',
@@ -113,7 +117,11 @@ command next_player => sub {
return $self->players->[($self->current_player_index + 1) % $self->num_players];
};
-command valid_move => sub { 1 };
+command valid_move => sub {
+ my $self = shift;
+ my ($move) = @_;
+ return uc(substr($move, 0, -1)) eq $self->state;
+};
command valid_word_from_state => sub {
my $self = shift;
diff --git a/lib/Bot/Games/Game/Spook.pm b/lib/Bot/Games/Game/Spook.pm
index 5780953..609bc06 100644
--- a/lib/Bot/Games/Game/Spook.pm
+++ b/lib/Bot/Games/Game/Spook.pm
@@ -2,7 +2,7 @@
package Bot::Games::Game::Spook;
use Bot::Games::OO;
use Games::Word qw/is_subpermutation/;
-extends 'Bot::Games::Game::Ghostlike';
+extends 'Bot::Games::Game::Ghost';
has '+help' => (
default => "spook help",
diff --git a/lib/Bot/Games/Game/Superghost.pm b/lib/Bot/Games/Game/Superghost.pm
index df297ee..0784698 100644
--- a/lib/Bot/Games/Game/Superghost.pm
+++ b/lib/Bot/Games/Game/Superghost.pm
@@ -1,7 +1,7 @@
#!/usr/bin/perl
package Bot::Games::Game::Superghost;
use Bot::Games::OO;
-extends 'Bot::Games::Game::Ghostlike';
+extends 'Bot::Games::Game::Ghost';
has '+help' => (
default => "superghost help",
diff --git a/lib/Bot/Games/Game/Xghost.pm b/lib/Bot/Games/Game/Xghost.pm
index 0c44cff..20dc19a 100644
--- a/lib/Bot/Games/Game/Xghost.pm
+++ b/lib/Bot/Games/Game/Xghost.pm
@@ -2,7 +2,7 @@
package Bot::Games::Game::Xghost;
use Bot::Games::OO;
use Games::Word qw/is_substring/;
-extends 'Bot::Games::Game::Ghostlike';
+extends 'Bot::Games::Game::Ghost';
has '+help' => (
default => "xghost help",