summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/Bot/Games/Game/Ghost.pm16
-rw-r--r--lib/Bot/Games/Game/Spook.pm18
-rw-r--r--lib/Bot/Games/Game/Superghost.pm17
-rw-r--r--lib/Bot/Games/Game/Xghost.pm18
4 files changed, 69 insertions, 0 deletions
diff --git a/lib/Bot/Games/Game/Ghost.pm b/lib/Bot/Games/Game/Ghost.pm
new file mode 100644
index 0000000..4d5d9c0
--- /dev/null
+++ b/lib/Bot/Games/Game/Ghost.pm
@@ -0,0 +1,16 @@
+#!/usr/bin/perl
+package Bot::Games::Game::Ghost;
+use Moose;
+extends 'Bot::Games::Game::Ghostlike';
+
+has '+help' => (
+ default => "ghost help",
+);
+
+sub valid_move {
+ my $self = shift;
+ my ($move) = @_;
+ return uc(substr($move, 0, -1)) eq $self->state;
+}
+
+1;
diff --git a/lib/Bot/Games/Game/Spook.pm b/lib/Bot/Games/Game/Spook.pm
new file mode 100644
index 0000000..83b3890
--- /dev/null
+++ b/lib/Bot/Games/Game/Spook.pm
@@ -0,0 +1,18 @@
+#!/usr/bin/perl
+package Bot::Games::Game::Spook;
+use Moose;
+use Games::Word qw/is_subpermutation/;
+extends 'Bot::Games::Game::Ghostlike';
+
+has '+help' => (
+ default => "spook help",
+);
+
+sub valid_move {
+ my $self = shift;
+ my ($move) = @_;
+ return is_subpermutation($self->state, $move)
+ && length($self->state) + 1 == length($move);
+}
+
+1;
diff --git a/lib/Bot/Games/Game/Superghost.pm b/lib/Bot/Games/Game/Superghost.pm
new file mode 100644
index 0000000..13502ed
--- /dev/null
+++ b/lib/Bot/Games/Game/Superghost.pm
@@ -0,0 +1,17 @@
+#!/usr/bin/perl
+package Bot::Games::Game::Superghost;
+use Moose;
+extends 'Bot::Games::Game::Ghostlike';
+
+has '+help' => (
+ default => "superghost help",
+);
+
+sub valid_move {
+ my $self = shift;
+ my ($move) = @_;
+ return uc(substr($move, 0, -1)) eq $self->state
+ || uc(substr($move, 1)) eq $self->state;
+}
+
+1;
diff --git a/lib/Bot/Games/Game/Xghost.pm b/lib/Bot/Games/Game/Xghost.pm
new file mode 100644
index 0000000..346ddf6
--- /dev/null
+++ b/lib/Bot/Games/Game/Xghost.pm
@@ -0,0 +1,18 @@
+#!/usr/bin/perl
+package Bot::Games::Game::Xghost;
+use Moose;
+use Games::Word qw/is_substring/;
+extends 'Bot::Games::Game::Ghostlike';
+
+has '+help' => (
+ default => "xghost help",
+);
+
+sub valid_move {
+ my $self = shift;
+ my ($move) = @_;
+ return is_substring($self->state, $move)
+ && length($self->state) + 1 == length($move);
+}
+
+1;