diff options
author | doy <doy@tozt.net> | 2009-01-14 05:09:16 -0500 |
---|---|---|
committer | doy <doy@tozt.net> | 2009-01-14 05:09:16 -0500 |
commit | 94a9a6a179e48f2d98ecc2954cd33ec6e7f5c10a (patch) | |
tree | e0bc716ac2b2749fa7a95d83def69c98fdb8fc22 | |
parent | 76ded94cf254c45f8516f298be5ee534cc453e5b (diff) | |
download | bot-games-94a9a6a179e48f2d98ecc2954cd33ec6e7f5c10a.tar.gz bot-games-94a9a6a179e48f2d98ecc2954cd33ec6e7f5c10a.zip |
update Bot::Games to use the new meta-stuff... completely untested, and probably broken!
-rw-r--r-- | lib/Bot/Games.pm | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/Bot/Games.pm b/lib/Bot/Games.pm index 92b22ae..ff2f76f 100644 --- a/lib/Bot/Games.pm +++ b/lib/Bot/Games.pm @@ -1,6 +1,6 @@ #!/usr/bin/perl package Bot::Games; -use Moose; +use Bot::Games::OO; use Module::Pluggable search_path => 'Bot::Games::Game', except => ['Bot::Games::Game::Ghostlike'], @@ -45,14 +45,14 @@ sub said { if ($action =~ /^-(\w+)\s*(.*)/) { my ($action, $arg) = ($1, $2); - if ($action =~ s/^_//) { - $output = "$action is private in $game_name"; - } - elsif ($game->meta->find_attribute_by_name($action)) { - $output = $game->$action(); - } - elsif ($game->can($action)) { - $output = $game->$action($arg, {player => $args->{who}}); + my $method_meta = $game->meta->find_method_by_name($action); + # bleh. isa isn't what i want either, but it's getting closer. + if ($method_meta->isa('Bot::Games::Meta::Method::Command')) { + my @command_args; + if (!$game->meta->has_attribute($action)) { + push @command_args, ($arg, {player => $args->{who}}); + } + $output = $game->$action(@command_args); } else { $output = "Unknown command $action for game $game_name"; @@ -105,6 +105,6 @@ sub _format { } __PACKAGE__->meta->make_immutable; -no Moose; +no Bot::Games::OO; 1; |