diff options
author | doy <doy@tozt.net> | 2009-01-26 02:21:15 -0500 |
---|---|---|
committer | doy <doy@tozt.net> | 2009-01-26 02:21:15 -0500 |
commit | 14af2793f9bfec0833b7c07df5f7fa9d3f6b895b (patch) | |
tree | 83a2f67e2627281528aaf49d08dfb2ec3d8d07cf | |
parent | a840c4ceec045d6ae50cbeed1713db18d7ad7a57 (diff) | |
download | bot-games-14af2793f9bfec0833b7c07df5f7fa9d3f6b895b.tar.gz bot-games-14af2793f9bfec0833b7c07df5f7fa9d3f6b895b.zip |
provide an overridable allow_new_player method which determines whether adding players is allowed, and make add_player return whether or not the player was added
-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 bba2b16..39c6462 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) }; +sub allow_new_player { 1 } +around add_player => sub { + my $orig = shift; + my $self = shift; + if ($self->allow_new_player) { + $self->$orig(@_); + return 1; + } + return; +}; + command cmdlist => sub { my $self = shift; my @commands; |