| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Game::WordBrain::Letter; |
|
2
|
|
|
|
|
|
|
|
|
3
|
12
|
|
|
12
|
|
186547
|
use strict; |
|
|
12
|
|
|
|
|
18
|
|
|
|
12
|
|
|
|
|
256
|
|
|
4
|
12
|
|
|
12
|
|
35
|
use warnings; |
|
|
12
|
|
|
|
|
13
|
|
|
|
12
|
|
|
|
|
381
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
12
|
|
|
|
|
74
|
use overload '==' => \&_operator_equality, |
|
7
|
12
|
|
|
12
|
|
10023
|
'""' => \&_operator_stringify; |
|
|
12
|
|
|
|
|
8119
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.2.2'; # 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
|
696
|
|
|
696
|
1
|
226569
|
my $class = shift; |
|
67
|
696
|
|
|
|
|
476
|
my $args = shift; |
|
68
|
|
|
|
|
|
|
|
|
69
|
696
|
|
|
|
|
1493
|
return bless $args, $class; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub _operator_equality { |
|
73
|
39314
|
|
|
39314
|
|
26233
|
my ( $a, $b ) = @_; |
|
74
|
|
|
|
|
|
|
|
|
75
|
39314
|
100
|
100
|
|
|
79519
|
if( $a->{letter} eq $b->{letter} |
|
|
|
|
100
|
|
|
|
|
|
76
|
|
|
|
|
|
|
&& $a->{row} == $b->{row} |
|
77
|
|
|
|
|
|
|
&& $a->{col} == $b->{col} ) { |
|
78
|
|
|
|
|
|
|
|
|
79
|
6616
|
|
|
|
|
10491
|
return 1; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
32698
|
|
|
|
|
49793
|
return 0; |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub _operator_stringify { |
|
86
|
25991
|
|
|
25991
|
|
17792
|
my $self = shift; |
|
87
|
|
|
|
|
|
|
|
|
88
|
25991
|
|
|
|
|
37068
|
return $self->{letter}; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |