blob: 74a44e61fbd33ad2e897cdfd5006dce0b5a88492 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#!/usr/bin/perl
package Bot::Games::Game::Spook;
use Bot::Games::OO;
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, uc($move))
&& length($self->state) + 1 == length($move);
}
sub valid_word_from_state {
my $self = shift;
my ($word) = @_;
$word = uc join '', sort split(//, $word);
my $state = join '', sort split(//, $self->state);
return $word eq $state;
}
__PACKAGE__->meta->make_immutable;
no Bot::Games::OO;
1;
|