summaryrefslogtreecommitdiffstats
path: root/lib/Bot/Games/Game.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Bot/Games/Game.pm')
-rw-r--r--lib/Bot/Games/Game.pm49
1 files changed, 9 insertions, 40 deletions
diff --git a/lib/Bot/Games/Game.pm b/lib/Bot/Games/Game.pm
index d57461d..a9d0862 100644
--- a/lib/Bot/Games/Game.pm
+++ b/lib/Bot/Games/Game.pm
@@ -1,18 +1,10 @@
package Bot::Games::Game;
-use Bot::Games::OO::Game;
+use Bot::Games::OO;
use DateTime;
use Time::Duration;
-has help => (
- is => 'ro',
- isa => 'Str',
- default => 'This game doesn\'t have any help text!',
- command => 1,
- needs_init => 0,
-);
-
has players => (
- traits => ['Collection::Array'],
+ traits => ['MooseX::AttributeHelpers::Trait::Collection::Array'],
is => 'ro',
isa => 'ArrayRef[Str]',
auto_deref => 1,
@@ -55,19 +47,12 @@ has last_turn_time => (
},
);
-has is_active => (
- is => 'rw',
- isa => 'Bool',
- command => 1,
- needs_init => 0,
-);
-
-sub turn {
- my $turn = inner();
- return $turn if defined($turn);
- return "Games must provide a turn method";
+sub default {
+ my $self = shift;
+ return "Games must provide a turn method" unless $self->can('turn');
+ $self->turn(@_);
}
-after turn => sub { shift->last_turn_time(DateTime->now) };
+after default => sub { shift->last_turn_time(DateTime->now) };
sub allow_new_player { 1 }
around add_player => sub {
@@ -80,25 +65,9 @@ around add_player => sub {
return;
};
-command cmdlist => sub {
- my $self = shift;
- my @commands;
- for my $method ($self->meta->get_all_methods) {
- push @commands, $method->name
- if $method->meta->can('does_role')
- && $method->meta->does_role('Bot::Games::Trait::Method::Command');
- }
- return \@commands;
-}, needs_init => 0,
- formatter => sub {
- my $list = shift;
- return join ' ', sort map { '-' . $_ } @$list
- };
-
sub _diff_from_now { ago(time - shift->epoch, 3) }
-# this happens in Bot::Games, since we want to add the say method from there
-#__PACKAGE__->meta->make_immutable;
-no Bot::Games::OO::Game;
+__PACKAGE__->meta->make_immutable;
+no Bot::Games::OO;
1;