From e78d44f6cbb618e95805c1eeb731d2bf8551688e Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Thu, 1 Jan 2015 20:47:59 +0100 Subject: Added evil_wins endgame --- Avalon.pm | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Avalon.pm b/Avalon.pm index 403593f..edd62a5 100644 --- a/Avalon.pm +++ b/Avalon.pm @@ -32,16 +32,25 @@ sub check_endgame_and_proceed { my $self = shift; my $av = $self->{avalon}; - if ($av->{round}->{failed_votes} >= 5) { - # TODO $self->evil_wins - } given ($av->{gamephase}) { when (TEAMVOTE) { - $self->new_king; + if ($av->{round}->{failed_votes} == 5) { + $self->evil_wins; + } else { + $self->new_king; + } } } } +sub evil_wins { + my ( $self, $who ) = @_; + my $av = $self->{avalon}; + my $evil_msg = "WINNERSIDE EVIL $av->{roles}->{ASSASSIN}->[0] " . join(' ', @{$av->{roles}->{EVIL}}); + $self->say( channel => $av->{config}->{'game.channel'}, body => $evil_msg ); + $self->reset_game; +} + sub game_ready { my $av = shift->{avalon}; return ( $av->{gamephase} == GAMESTART and scalar keys $av->{registered} >= 5 ); -- cgit v1.2.3