line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
28003
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
146
|
|
2
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
207
|
|
3
|
|
|
|
|
|
|
package Games::Board; |
4
|
|
|
|
|
|
|
{ |
5
|
|
|
|
|
|
|
$Games::Board::VERSION = '1.013'; |
6
|
|
|
|
|
|
|
} |
7
|
|
|
|
|
|
|
# ABSTRACT: a parent class for board games |
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
25
|
use Carp; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
384
|
|
10
|
4
|
|
|
4
|
|
2179
|
use Games::Board::Space; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
105
|
|
11
|
4
|
|
|
4
|
|
2142
|
use Games::Board::Piece; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
1234
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
2
|
|
|
2
|
1
|
872
|
my $class = shift; |
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
|
|
7
|
my $board = { |
18
|
|
|
|
|
|
|
spaces => { } |
19
|
|
|
|
|
|
|
}; |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
|
|
8
|
bless $board => $class; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub space { |
26
|
228
|
|
|
228
|
1
|
31980
|
my $board = shift; |
27
|
228
|
|
|
|
|
320
|
my $space = shift; |
28
|
|
|
|
|
|
|
|
29
|
228
|
|
|
|
|
849
|
return $board->{spaces}{$space}; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub add_space { |
34
|
68
|
|
|
68
|
1
|
1261
|
my ($board, %args) = @_; |
35
|
68
|
|
|
|
|
68
|
my $space; |
36
|
|
|
|
|
|
|
|
37
|
68
|
|
|
|
|
99
|
$space = $board->spaceclass->new(board => $board, %args); |
38
|
|
|
|
|
|
|
|
39
|
68
|
50
|
|
|
|
92
|
return unless eval { $space->isa('Games::Board::Space') }; |
|
68
|
|
|
|
|
265
|
|
40
|
|
|
|
|
|
|
|
41
|
68
|
50
|
|
|
|
160
|
if ($board->space($space->id)) { |
42
|
0
|
|
|
|
|
0
|
carp "space '" . $space->id . "' already exists on board"; |
43
|
|
|
|
|
|
|
} else { |
44
|
68
|
|
|
|
|
191
|
$board->{spaces}{$space->id} = $space; |
45
|
68
|
|
|
|
|
203
|
return $space; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
2
|
|
|
2
|
1
|
21
|
sub piececlass { 'Games::Board::Piece' } |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
68
|
|
|
68
|
1
|
295
|
sub spaceclass { 'Games::Board::Space' } |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub add_piece { |
57
|
3
|
|
|
3
|
1
|
795
|
my $board = shift; |
58
|
3
|
|
|
|
|
14
|
my %args = @_; |
59
|
3
|
|
|
|
|
8
|
my $piece; |
60
|
|
|
|
|
|
|
|
61
|
3
|
|
|
|
|
19
|
$piece = $board->piececlass->new(board => $board, @_); |
62
|
3
|
|
33
|
|
|
27
|
$piece ||= shift; |
63
|
|
|
|
|
|
|
|
64
|
3
|
50
|
|
|
|
8
|
return unless eval { $piece->isa('Games::Board::Piece') }; |
|
3
|
|
|
|
|
21
|
|
65
|
|
|
|
|
|
|
|
66
|
3
|
|
|
|
|
11
|
return $piece; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
"Family fun night!"; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__END__ |