line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Game::WordBrain::Letter; |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
196016
|
use strict; |
|
11
|
|
|
|
|
19
|
|
|
11
|
|
|
|
|
291
|
|
4
|
11
|
|
|
11
|
|
42
|
use warnings; |
|
11
|
|
|
|
|
17
|
|
|
11
|
|
|
|
|
460
|
|
5
|
|
|
|
|
|
|
|
6
|
11
|
|
|
|
|
93
|
use overload '==' => \&_operator_equality, |
7
|
11
|
|
|
11
|
|
12803
|
'""' => \&_operator_stringify; |
|
11
|
|
|
|
|
10368
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.2.1'; # VERSION |
10
|
|
|
|
|
|
|
# ABSTRACT: Representation of a Letter in a WordBrain Game |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Game::WordBrain::Letter - Representation of a Letter in a WordBrain Game |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPSIS |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Create a new Game::WordBrain::Letter |
19
|
|
|
|
|
|
|
my $letter = Game::WordBrain::Letter->new({ |
20
|
|
|
|
|
|
|
letter => 'a', |
21
|
|
|
|
|
|
|
row => 1, |
22
|
|
|
|
|
|
|
col => 3, |
23
|
|
|
|
|
|
|
}); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Stringification is overloaded |
26
|
|
|
|
|
|
|
print $letter; # prints 'a' |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Equality is overloaded |
29
|
|
|
|
|
|
|
if( $letter == $letter ) { |
30
|
|
|
|
|
|
|
print "Same letter!'; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 DESCRIPTION |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Represents a Letter in a WordBrain Game. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 B |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
A single character string that contains the actual letter represented [a-z]. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 B |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
The row in a WordBrain game where this letter appears. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 B |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
The col in a WordBrain game where this letter appears. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 METHODS |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 new |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my $letter = Game::WordBrain::Letter->new({ |
56
|
|
|
|
|
|
|
letter => 'a', |
57
|
|
|
|
|
|
|
row => 1, |
58
|
|
|
|
|
|
|
col => 3, |
59
|
|
|
|
|
|
|
}); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Given a letter, a row, and a col, returns an instance of a Game::WordBrain::Letter. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub new { |
66
|
80
|
|
|
80
|
1
|
15938
|
my $class = shift; |
67
|
80
|
|
|
|
|
71
|
my $args = shift; |
68
|
|
|
|
|
|
|
|
69
|
80
|
|
|
|
|
195
|
return bless $args, $class; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub _operator_equality { |
73
|
45
|
|
|
45
|
|
513
|
my ( $a, $b ) = @_; |
74
|
|
|
|
|
|
|
|
75
|
45
|
100
|
100
|
|
|
175
|
if( $a->{letter} eq $b->{letter} |
|
|
|
100
|
|
|
|
|
76
|
|
|
|
|
|
|
&& $a->{row} == $b->{row} |
77
|
|
|
|
|
|
|
&& $a->{col} == $b->{col} ) { |
78
|
|
|
|
|
|
|
|
79
|
10
|
|
|
|
|
121
|
return 1; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
35
|
|
|
|
|
57
|
return 0; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub _operator_stringify { |
86
|
1
|
|
|
1
|
|
37
|
my $self = shift; |
87
|
|
|
|
|
|
|
|
88
|
1
|
|
|
|
|
8
|
return $self->{letter}; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |