summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Dessaux2015-01-01 16:55:48 +0100
committerJulien Dessaux2015-01-01 18:03:26 +0100
commit1a75cb8e5a5f0c5e326703bd92d2d1e56bb5285d (patch)
treec27530ec842048de8445f757edfa0434dfb96dc0
parentDo not start a game with more than the maximum number of players (diff)
downloadavalon-arthur-1a75cb8e5a5f0c5e326703bd92d2d1e56bb5285d.tar.gz
avalon-arthur-1a75cb8e5a5f0c5e326703bd92d2d1e56bb5285d.tar.bz2
avalon-arthur-1a75cb8e5a5f0c5e326703bd92d2d1e56bb5285d.zip
Implemented TEAM nomination gamephase
-rw-r--r--Avalon.pm19
1 files changed, 18 insertions, 1 deletions
diff --git a/Avalon.pm b/Avalon.pm
index a0c92d0..b228eb3 100644
--- a/Avalon.pm
+++ b/Avalon.pm
@@ -68,6 +68,7 @@ sub reset_game {
'EVIL' => [],
};
$av->{king} = 0;
+ $av->{team} = [];
$av->{votes} = { pass => 0, fail => 0 };
$av->{quests} = { pass => 0, fail => 0 };
$av->{round} = { id => 0, failed_votes => 0 };
@@ -202,7 +203,23 @@ sub told {
when ("EVIL") {}
when ("KING") {}
when ("RULENOW") {}
- when ("TEAM") {}
+ when ("TEAM") {
+ $self->kick($who) unless ($av->{gamephase} == TEAM and $who eq $av->{players}->[$av->{king}]);
+ my ($players, $rules) = $self->rules;
+ my $team_size = $rules->[$av->{round}->{id} + 1];
+ return 'ERR_BAD_ARGUMENTS' if scalar @args != $team_size;
+ foreach (@args) {
+ if ($_ ~~ $av->{players} and !($_ ~~ $av->{team})) {
+ push $av->{team}, $_;
+ } else {
+ $av->{team} = [];
+ return 'ERR_BAD_ARGUMENTS';
+ }
+ }
+ $av->{gamephase} = TEAMVOTE;
+ $av->{lastcall} = 0;
+ $self->set_timeout(58);
+ }
when ("VOTE") {}
when ("VOTENOW") {}
when ("VOTERESULT") {}