summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Dessaux2015-01-01 20:47:59 +0100
committerJulien Dessaux2015-01-01 20:47:59 +0100
commite78d44f6cbb618e95805c1eeb731d2bf8551688e (patch)
treed81d3a3d44abe0ebb049995bfb6d85aece696836
parentImplemented TEAMVOTE game phase (diff)
downloadavalon-arthur-e78d44f6cbb618e95805c1eeb731d2bf8551688e.tar.gz
avalon-arthur-e78d44f6cbb618e95805c1eeb731d2bf8551688e.tar.bz2
avalon-arthur-e78d44f6cbb618e95805c1eeb731d2bf8551688e.zip
Added evil_wins endgame
-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 );