From 14af2793f9bfec0833b7c07df5f7fa9d3f6b895b Mon Sep 17 00:00:00 2001 From: doy Date: Mon, 26 Jan 2009 02:21:15 -0500 Subject: 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 --- lib/Bot/Games/Game.pm | 11 +++++++++++ 1 file changed, 11 insertions(+) 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; -- cgit v1.2.3-54-g00ecf