summaryrefslogtreecommitdiff
path: root/Avalon.pm
blob: cd6d874870882e606927336eb03a718f20a8fdc8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package Bot::BasicBot::Pluggable::Module::Avalon;
{
    $Avalon::Arthur::VERSION = '0.02';
};

use strict;
use warnings;
use v5.12;
use experimental qw(switch);
use POE;
use Time::HiRes qw(time);

use base qw(Bot::BasicBot::Pluggable::Module);

### Game logic ###############################################################
sub set_timeout {
    my ( $self, $value) = @_;
    $poe_kernel->alarm( avalon_timeout => time() + $value );
}

sub timeout_occurred {
    my $self = shift;
    $self->say( channel => $self->{avalon}->{config}->{'game.channel'}, body => "timeout" );
}

### IRC methods override ######################################################
sub connected {
    my $self = shift;
    $poe_kernel->state( 'avalon_timeout', $self, 'timeout_occurred' );
}

sub init {
    my $self = shift;
    $self->{avalon} = {};
    $self->{avalon}->{config} = $self->bot->{store_object}->{store}->{cfg}->{cfg};
}

sub help {
    return "The avalon game simulator : https://github.com/adyxax/avalon-arthur";
}

sub told {
    my ( $self, $mess ) = @_;
    my $who = $mess->{who};
    my $body = $mess->{body};
    my $ispriv = defined $mess->{address};

    my ( $command, @args ) = split /\s+/, $mess->{body};
    given ($command) {
        when ("REGISTER") {}
        when ("REGISTERED") {}
        when ("UNREGISTER") {}
        when ("UNREGISTERED") {}
        when ("GAMESTART") {}
        when ("ROLE") {}
        when ("EVIL") {}
        when ("KING") {}
        when ("RULENOW") {}
        when ("TEAM") {}
        when ("VOTE") {}
        when ("VOTENOW") {}
        when ("VOTERESULT") {}
        when ("QUESTRESULT") {}
        when ("KILLMERLIN") {}
        when ("KILLMERLINNOW") {}
        when ("KILL") {}
        when ("WINNERSIDE") {}
        when ("INFO") {}
        when ("GAMEURL") {}
        when ("ERR_BAD_ARGUMENTS") {}
        when ("ERR_BAD_DESTINATION") {}
        when ("ERR_NICK_RESERVED") {}
        when ("ERR_PROTOCOL_MISMATCH") {}
        when ("ERR_BANNED") {}
        when ("ERR_INVALID_TEAM") {}
        when ("ERR_INVALID_VOTE") {}
        when ("ERR_VOTE_TIMEOUT") {}
        when ("ERR_NOT_THE_ASSASSIN") {}
        when ("ERR_NOT_NOW") {}
        when ("ERR_JOIN_AVALON_FIRST") {}
        default {}
    }
}

1;