File Coverage

blib/lib/Games/AssaultCube/Log/Line/Killed.pm
Criterion Covered Total %
statement 1 3 33.3
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 2 4 50.0


line stmt bran cond sub pod time code
1             # Declare our package
2             package Games::AssaultCube::Log::Line::Killed;
3              
4             # import the Moose stuff
5 1     1   2287 use Moose;
  0            
  0            
6              
7             # Initialize our version
8             use vars qw( $VERSION );
9             $VERSION = '0.04';
10              
11             extends 'Games::AssaultCube::Log::Line::Base';
12              
13             with 'Games::AssaultCube::Log::Line::Base::NickIP';
14              
15             # TODO improve validation for everything here, ha!
16              
17             has 'victim' => (
18             isa => 'Str',
19             is => 'ro',
20             required => 1,
21             );
22              
23             has 'tk' => (
24             isa => 'Bool',
25             is => 'ro',
26             required => 1,
27             );
28              
29             has 'gib' => (
30             isa => 'Bool',
31             is => 'ro',
32             required => 1,
33             );
34              
35             has 'score' => (
36             isa => 'Int',
37             is => 'ro',
38             lazy => 1,
39             default => sub {
40             my $self = shift;
41             if ( $self->tk ) {
42             if ( $self->gib ) {
43             return -2;
44             } else {
45             return -1;
46             }
47             } else {
48             if ( $self->gib ) {
49             return 2;
50             } else {
51             return 1;
52             }
53             }
54             },
55             );
56              
57             has 'tostr' => (
58             isa => 'Str',
59             is => 'ro',
60             lazy => 1,
61             default => sub {
62             my $self = shift;
63             return $self->nick . ( $self->gib ? " gibbed " : " killed " ) . ( $self->tk ? "teammate " : "" ) . $self->victim;
64             },
65             );
66              
67             no Moose;
68             __PACKAGE__->meta->make_immutable;
69              
70             1;
71             __END__
72              
73             =for stopwords gamemode gib gibbed tk ip
74              
75             =head1 NAME
76              
77             Games::AssaultCube::Log::Line::Killed - Describes the Killed event in a log line
78              
79             =head1 ABSTRACT
80              
81             Describes the Killed event in a log line
82              
83             =head1 DESCRIPTION
84              
85             This module holds the "Killed" event data from a log line. Normally, you would not use this class directly
86             but via the L<Games::AssaultCube::Log::Line> class.
87              
88             This line is emitted when a client kills somebody. ( frag/gib )
89              
90             =head2 Attributes
91              
92             Those attributes hold information about the event. As this class extends the L<Games::AssaultCube::Log::Line::Base>
93             class, you can also use it's attributes too.
94              
95             =head3 nick
96              
97             The nick of the client who did the kill
98              
99             =head3 victim
100              
101             The nick who died
102              
103             =head3 ip
104              
105             The ip of the client who did the kill
106              
107             =head3 tk
108              
109             Boolean value indicating if the client killed somebody on his team or not.
110              
111             =head3 gib
112              
113             Boolean value indicating if the client gibbed the victim or not.
114              
115             =head3 score
116              
117             The AC-specific score for this kill. ( varies from gamemode to gamemode, this is the default )
118              
119             Gib = 2
120             Frag = 1
121             TK Frag = -1
122             TK Gib = -2
123              
124             =head1 AUTHOR
125              
126             Apocalypse E<lt>apocal@cpan.orgE<gt>
127              
128             Props goes to the BS clan for the support!
129              
130             This project is sponsored by L<http://cubestats.net>
131              
132             =head1 COPYRIGHT AND LICENSE
133              
134             Copyright 2009 by Apocalypse
135              
136             This library is free software; you can redistribute it and/or modify
137             it under the same terms as Perl itself.
138              
139             =cut