summaryrefslogtreecommitdiffstats
path: root/lib/Bot/Games/Game.pm
diff options
context:
space:
mode:
authordoy <doy@tozt.net>2009-01-25 22:16:08 -0500
committerdoy <doy@tozt.net>2009-01-25 22:16:08 -0500
commitd5d7a9d1c72e331e09a717204db80f9d3fdbe618 (patch)
treedab710b32cf87e54f5bbeaff63cb35116f9f40f1 /lib/Bot/Games/Game.pm
parent9a6f2a51e59600e91c97a410d84d45d01434555c (diff)
downloadbot-games-d5d7a9d1c72e331e09a717204db80f9d3fdbe618.tar.gz
bot-games-d5d7a9d1c72e331e09a717204db80f9d3fdbe618.zip
add @foo -cmdlist to list available commands for a game
Diffstat (limited to 'lib/Bot/Games/Game.pm')
-rw-r--r--lib/Bot/Games/Game.pm11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/Bot/Games/Game.pm b/lib/Bot/Games/Game.pm
index 0c0de30..2bc467c 100644
--- a/lib/Bot/Games/Game.pm
+++ b/lib/Bot/Games/Game.pm
@@ -52,6 +52,17 @@ sub turn {
}
after turn => sub { shift->last_turn_time(DateTime->now) };
+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::Meta::Role::Command');
+ }
+ return join ' ', map { '-' . $_ } @commands;
+}, needs_init => 0;
+
# this happens in Bot::Games, since we want to add the say method from there
#__PACKAGE__->meta->make_immutable;
no Bot::Games::OO;