line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
21
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
117
|
|
2
|
4
|
|
|
4
|
|
19
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
182
|
|
3
|
|
|
|
|
|
|
package Games::Board::Space; |
4
|
|
|
|
|
|
|
{ |
5
|
|
|
|
|
|
|
$Games::Board::Space::VERSION = '1.013'; |
6
|
|
|
|
|
|
|
} |
7
|
|
|
|
|
|
|
# ABSTRACT: a parent class for spaces on game board |
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
18
|
use Carp; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
2165
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
196
|
|
|
196
|
1
|
223
|
my $class = shift; |
15
|
196
|
|
|
|
|
420
|
my %args = @_; |
16
|
|
|
|
|
|
|
|
17
|
196
|
50
|
|
|
|
354
|
return unless $args{id}; |
18
|
|
|
|
|
|
|
croak "no board supplied in space creation" |
19
|
196
|
50
|
|
|
|
197
|
unless eval { $args{board}->isa('Games::Board') }; |
|
196
|
|
|
|
|
682
|
|
20
|
|
|
|
|
|
|
|
21
|
196
|
|
|
|
|
559
|
my $space = { |
22
|
|
|
|
|
|
|
id => $args{id}, |
23
|
|
|
|
|
|
|
board => $args{board}, |
24
|
|
|
|
|
|
|
}; |
25
|
|
|
|
|
|
|
|
26
|
196
|
100
|
66
|
|
|
597
|
$space->{dir} = $args{dir} |
27
|
|
|
|
|
|
|
if $args{dir} and (ref $args{dir} eq 'HASH'); |
28
|
|
|
|
|
|
|
|
29
|
196
|
|
|
|
|
950
|
bless $space => $class; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub id { |
34
|
246
|
|
|
246
|
1
|
254
|
my $space = shift; |
35
|
|
|
|
|
|
|
|
36
|
246
|
|
|
|
|
1596
|
return $space->{id}; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub board { |
41
|
142
|
|
|
142
|
1
|
169
|
my $space = shift; |
42
|
142
|
|
|
|
|
391
|
$space->{board}; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub dir_id { |
47
|
28
|
|
|
28
|
1
|
43
|
my ($space, $dir) = @_; |
48
|
|
|
|
|
|
|
|
49
|
28
|
50
|
|
|
|
257
|
return $space->{dir}{$dir} if (ref $space->{dir} eq 'HASH'); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub dir { |
54
|
2
|
|
|
2
|
1
|
6
|
my ($space, $dir) = @_; |
55
|
2
|
|
|
|
|
8
|
$space->board->space($space->dir_id($dir)); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub contains { |
60
|
4
|
|
|
4
|
1
|
6
|
my ($self, $piece) = @_; |
61
|
4
|
50
|
|
|
|
7
|
return 1 if grep { $_ eq $piece->id } @{$self->{contents}}; |
|
0
|
|
|
|
|
0
|
|
|
4
|
|
|
|
|
38
|
|
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub receive { |
66
|
4
|
|
|
4
|
1
|
7
|
my ($self, $piece) = @_; |
67
|
|
|
|
|
|
|
|
68
|
4
|
50
|
|
|
|
6
|
return unless eval { $piece->isa('Games::Board::Piece') }; |
|
4
|
|
|
|
|
20
|
|
69
|
4
|
50
|
|
|
|
19
|
return if $self->contains($piece); |
70
|
|
|
|
|
|
|
|
71
|
4
|
|
|
|
|
12
|
$piece->{current_space} = $self->id; |
72
|
4
|
|
|
|
|
6
|
push @{$self->{contents}}, $piece->id; |
|
4
|
|
|
|
|
21
|
|
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
__END__ |