diff options
author | Julien Dessaux | 2015-01-01 21:08:34 +0100 |
---|---|---|
committer | Julien Dessaux | 2015-01-01 21:23:33 +0100 |
commit | 4d68f76696748887fdcb9843049af7ece5e0656b (patch) | |
tree | d8e0f12d0522eaec258f9ff863f445c6d780727c | |
parent | Implemented QUESTVOTE game phase (diff) | |
download | avalon-arthur-4d68f76696748887fdcb9843049af7ece5e0656b.tar.gz avalon-arthur-4d68f76696748887fdcb9843049af7ece5e0656b.tar.bz2 avalon-arthur-4d68f76696748887fdcb9843049af7ece5e0656b.zip |
Implemented the good_wins endgame and the ASSASSINGUESS game phase
Diffstat (limited to '')
-rw-r--r-- | Avalon.pm | 37 | ||||
-rw-r--r-- | README.markdown | 2 |
2 files changed, 37 insertions, 2 deletions
@@ -69,6 +69,14 @@ sub game_ready { return ( $av->{gamephase} == GAMESTART and scalar keys $av->{registered} >= 5 ); } +sub good_wins { + my ( $self, $who ) = @_; + my $av = $self->{avalon}; + my $evil_msg = "WINNERSIDE GOOD $av->{roles}->{MERLIN}->[0] " . join(' ', @{$av->{roles}->{GOOD}}); + $self->say( channel => $av->{config}->{'game.channel'}, body => $evil_msg ); + $self->reset_game; +} + sub kick { my ( $self, $who ) = @_; my $av = $self->{avalon}; @@ -208,6 +216,15 @@ sub timeout_occurred { $av->{lastcall} = 1; } } + when (ASSASSINGUESS) { + if ($av->{lastcall}) { + $self->kick($av->{roles}->{ASSASSIN}->[0]); + } else { + $self->say( channel => $av->{config}->{'game.channel'}, body => "KILLMERLINNOW" ); + $self->set_timeout(2); + $av->{lastcall} = 1; + } + } default { $self->say( channel => $av->{config}->{'game.channel'}, body => "timeout" ); } @@ -215,6 +232,9 @@ sub timeout_occurred { } ### IRC methods override ###################################################### +sub chanpart { +} + sub connected { my $self = shift; $poe_kernel->state( 'avalon_timeout', $self, 'timeout_occurred' ); @@ -345,7 +365,22 @@ sub told { when ("QUESTRESULT") {} when ("KILLMERLIN") {} when ("KILLMERLINNOW") {} - when ("KILL") {} + when ("KILL") { + return 'ERR_BAD_ARGUMENTS' unless scalar @args == 1 and $args[0] ~~ $av->{players}; + given ($av->{gamephase}) { + when (ASSASSINGUESS) { + if ($who eq $av->{roles}->{ASSASSIN}->[0]) { + if ($args[0] eq $av->{roles}->{MERLIN}->[0]) { + $self->evil_wins; + } else { + $self->good_wins; + } + } else { + $self->kick($who); + } + } + } + } when ("WINNERSIDE") {} when ("INFO") {} when ("GAMEURL") {} diff --git a/README.markdown b/README.markdown index 86e7baf..815e8ba 100644 --- a/README.markdown +++ b/README.markdown @@ -128,7 +128,7 @@ the vote. ### Game ends #### KILLMERLIN -KILLMERLIN message is sent on the #avalon game channel by arthur to ask the ASSASSIN has 60 seconds to guess who MERLIN isi if the GOOD side win three quests. +KILLMERLIN message is sent on the #avalon game channel by arthur to tell the ASSASSIN has 60 seconds to guess who MERLIN is when the GOOD side winis its third quest. #### KILLMERLINNOW KILLMERLINNOW message is sent by arthur to the assassin that didn't designate MERLIN when there are only 2 seconds remaining. |