summaryrefslogtreecommitdiffstats
path: root/lib/Bot/Games/Game/Ghost.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Bot/Games/Game/Ghost.pm')
-rw-r--r--lib/Bot/Games/Game/Ghost.pm26
1 files changed, 14 insertions, 12 deletions
diff --git a/lib/Bot/Games/Game/Ghost.pm b/lib/Bot/Games/Game/Ghost.pm
index 093b013..480def0 100644
--- a/lib/Bot/Games/Game/Ghost.pm
+++ b/lib/Bot/Games/Game/Ghost.pm
@@ -15,13 +15,6 @@ has current_player => (
command => 1,
);
-has players_fixed => (
- is => 'rw',
- isa => 'Bool',
- default => 0,
- command => 1,
-);
-
has state => (
is => 'rw',
isa => 'Str',
@@ -59,11 +52,10 @@ augment turn => sub {
my $self = shift;
my ($player, $state) = @_;
- if ($self->current_player_index == 0
- && !$self->players_fixed
- && !grep { $player eq $_ } $self->players) {
- $self->add_player($player);
- $self->current_player($player);
+ if (!grep { $player eq $_ } $self->players) {
+ if ($self->add_player($player)) {
+ $self->current_player($player);
+ }
}
return "It's " . $self->current_player . "'s turn!"
@@ -77,6 +69,16 @@ augment turn => sub {
return $self->state($state);
};
+sub allow_new_player {
+ my $self = shift;
+
+ if ($self->current_player_index != 0 && $self->num_players > 1) {
+ $self->say("No more players can join the current game");
+ return;
+ }
+ return 1;
+}
+
command challenge => sub {
my $self = shift;
my ($word, $args) = @_;