summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Avalon.pm17
1 files 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 );