diff options
author | Julien Dessaux | 2015-01-01 17:26:25 +0100 |
---|---|---|
committer | Julien Dessaux | 2015-01-01 18:11:58 +0100 |
commit | 606d05ea452764db6eb770086f0bf92e46916706 (patch) | |
tree | effe7529ef9a7dd58e03dd4e3ddd1214c5e57822 | |
parent | Protocol update (diff) | |
download | avalon-arthur-606d05ea452764db6eb770086f0bf92e46916706.tar.gz avalon-arthur-606d05ea452764db6eb770086f0bf92e46916706.tar.bz2 avalon-arthur-606d05ea452764db6eb770086f0bf92e46916706.zip |
Small starting game state fixes
-rw-r--r-- | Avalon.pm | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -59,8 +59,7 @@ sub reset_game { my $self = shift; my $av = $self->{avalon}; $av->{gamephase} = GAMESTART; - $av->{timeout} = 0; - $av->{players} = (); + $av->{players} = []; $av->{roles} = { 'MERLIN' => [], 'ASSASSIN' => [], @@ -69,9 +68,9 @@ sub reset_game { }; $av->{king} = 0; $av->{team} = []; - $av->{votes} = { pass => 0, fail => 0 }; + $av->{votes} = {}; $av->{quests} = { pass => 0, fail => 0 }; - $av->{round} = { id => 0, failed_votes => 0 }; + $av->{round} = { id => 1, failed_votes => 0 }; $av->{lastcall} = 0; $self->start_game if $self->game_ready; } @@ -123,7 +122,7 @@ sub timeout_occurred { $self->say( channel => 'msg', who => $_, body => $evil_msg ) foreach (@{$av->{roles}->{EVIL}}); # Finally we designate the first king $av->{king} = rand($players); - $self->say( channel => $av->{config}->{'game.channel'}, body => "KING $av->{players}->[$av->{king}] $rules->[$av->{round}->{id} + 1] $av->{round}->{failed_votes}" ); + $self->say( channel => $av->{config}->{'game.channel'}, body => "KING $av->{players}->[$av->{king}] $rules->[$av->{round}->{id}] $av->{round}->{failed_votes}" ); $av->{gamephase} = TEAM; $av->{lastcall} = 0; $self->set_timeout(58); @@ -206,7 +205,7 @@ sub told { 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]; + my $team_size = $rules->[$av->{round}->{id}]; return 'ERR_BAD_ARGUMENTS' if scalar @args != $team_size; foreach (@args) { if ($_ ~~ $av->{players} and !($_ ~~ $av->{team})) { |