summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Dessaux2014-12-07 13:33:06 +0100
committerJulien Dessaux2014-12-07 13:33:06 +0100
commit13fe7ea8a611b3e1600d3399ab1ea36051c5d022 (patch)
treedac43e742c16956b1b0ee71ca39f1b4985bd7371
parentMinor fixes (diff)
downloadavalon-arthur-13fe7ea8a611b3e1600d3399ab1ea36051c5d022.tar.gz
avalon-arthur-13fe7ea8a611b3e1600d3399ab1ea36051c5d022.tar.bz2
avalon-arthur-13fe7ea8a611b3e1600d3399ab1ea36051c5d022.zip
Implemented TEAM election gamephase timeout and the kick system
-rw-r--r--Avalon.pm23
1 files changed, 23 insertions, 0 deletions
diff --git a/Avalon.pm b/Avalon.pm
index ccdddb7..965d554 100644
--- a/Avalon.pm
+++ b/Avalon.pm
@@ -33,6 +33,18 @@ sub game_ready {
return ( $av->{gamephase} == GAMESTART and scalar keys $av->{registered} >= 5 );
}
+sub kick {
+ my ( $self, $who ) = @_;
+ my $av = $self->{avalon};
+ my $avdb = $self->{avdb};
+ my $entry = $who . $av->{registered}->{$who}->{version};
+ my $score = $avdb->get('KICKS', $entry);
+ $avdb->set('KICKS', $entry, defined $score ? int($score) + 1 : 1);
+ $self->say( channel => $av->{config}->{'game.channel'}, body => "UNREGISTERED $who" );
+ delete $av->{registered}->{$who};
+ $self->reset_game;
+}
+
sub load_avalon_db {
my $self = shift;
# This database stores registrations and bans
@@ -110,6 +122,17 @@ sub timeout_occurred {
$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}" );
$av->{gamephase} = TEAM;
+ $av->{lastcall} = 0;
+ $self->set_timeout(58);
+ }
+ when (TEAM) {
+ if ($av->{lastcall}) {
+ $self->kick($av->{players}->[$av->{king}]);
+ } else {
+ $self->say( channel => $av->{config}->{'game.channel'}, body => "RULENOW $av->{players}->[$av->{king}]" );
+ $self->set_timeout(2);
+ $av->{lastcall} = 1;
+ }
}
default {
$self->say( channel => $av->{config}->{'game.channel'}, body => "timeout" );