diff options
author | Julien Dessaux | 2015-01-01 16:55:48 +0100 |
---|---|---|
committer | Julien Dessaux | 2015-01-01 18:03:26 +0100 |
commit | 1a75cb8e5a5f0c5e326703bd92d2d1e56bb5285d (patch) | |
tree | c27530ec842048de8445f757edfa0434dfb96dc0 | |
parent | Do not start a game with more than the maximum number of players (diff) | |
download | avalon-arthur-1a75cb8e5a5f0c5e326703bd92d2d1e56bb5285d.tar.gz avalon-arthur-1a75cb8e5a5f0c5e326703bd92d2d1e56bb5285d.tar.bz2 avalon-arthur-1a75cb8e5a5f0c5e326703bd92d2d1e56bb5285d.zip |
Implemented TEAM nomination gamephase
Diffstat (limited to '')
-rw-r--r-- | Avalon.pm | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -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") {} |