diff options
author | doy <doy@tozt.net> | 2009-04-27 17:52:32 -0500 |
---|---|---|
committer | doy <doy@tozt.net> | 2009-04-27 17:52:32 -0500 |
commit | a3d2e93584fad534414255ce45f58d9d98fbceeb (patch) | |
tree | 63508348f66fed5fee78147f547aa3c69d91aaab | |
parent | 892366afd72b42858459e54beb32600f2e85d508 (diff) | |
download | bot-games-a3d2e93584fad534414255ce45f58d9d98fbceeb.tar.gz bot-games-a3d2e93584fad534414255ce45f58d9d98fbceeb.zip |
add a has_player method to the base game class
-rw-r--r-- | lib/Bot/Games/Game.pm | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/Bot/Games/Game.pm b/lib/Bot/Games/Game.pm index 24f4caa..6d0c29c 100644 --- a/lib/Bot/Games/Game.pm +++ b/lib/Bot/Games/Game.pm @@ -26,9 +26,20 @@ has players => ( push => 'add_player', count => 'num_players', }, + curries => { + find => { + has_player => sub { + my $self = shift; + my $body = shift; + my ($player) = @_; + return $self->$body(sub { $_[0] eq $player }) ? 1 : 0; + }, + }, + }, command => 1, ); command 'num_players'; +command 'has_player', formatter => sub { $_[0] ? 'true' : 'false' }; has start_time => ( is => 'ro', |