line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catan::Map::Path; |
2
|
|
|
|
|
|
|
$Catan::Map::Path::VERSION = '0.03'; |
3
|
3
|
|
|
3
|
|
16
|
use strict; |
|
3
|
|
|
1
|
|
4
|
|
|
3
|
|
|
|
|
72
|
|
|
1
|
|
|
|
|
704
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
4
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
3
|
|
|
1
|
|
5
|
|
|
3
|
|
|
|
|
82
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use overload |
7
|
3
|
|
|
|
|
15
|
'""' => 'uuid', |
|
1
|
|
|
|
|
5
|
|
8
|
3
|
|
|
3
|
|
20
|
fallback => 1; |
|
3
|
|
|
1
|
|
4
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
3
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new |
11
|
|
|
|
|
|
|
{ |
12
|
895
|
|
|
895
|
0
|
1295
|
my ($class, $intersections) = @_; |
13
|
895
|
50
|
33
|
|
|
5947
|
die 'Path->new() requires an arrayref of 2 intersections' |
|
|
|
33
|
|
|
|
|
14
|
|
|
|
|
|
|
unless $intersections && ref $intersections eq 'ARRAY' && @$intersections == 2; |
15
|
|
|
|
|
|
|
|
16
|
895
|
50
|
|
|
|
2326
|
die 'Path->new() start and end intersections must be adjacent' |
17
|
|
|
|
|
|
|
unless $intersections->[0]->is_adjacent($intersections->[1]); |
18
|
|
|
|
|
|
|
|
19
|
895
|
|
|
|
|
2507
|
bless { |
20
|
|
|
|
|
|
|
uuid => join(' ', sort $intersections->[0]->uuid, $intersections->[1]->uuid), |
21
|
|
|
|
|
|
|
start => $intersections->[0], |
22
|
|
|
|
|
|
|
end => $intersections->[1], |
23
|
|
|
|
|
|
|
}, $class; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
5638
|
|
|
5638
|
0
|
14902
|
sub start { $_[0]->{start} } |
27
|
3860
|
|
|
3860
|
0
|
10130
|
sub end { $_[0]->{end} } |
28
|
103506
|
|
|
103506
|
0
|
369799
|
sub uuid { $_[0]->{uuid} } |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub is_adjacent |
31
|
|
|
|
|
|
|
{ |
32
|
167
|
|
|
167
|
0
|
251
|
my ($self, $obj) = @_; |
33
|
|
|
|
|
|
|
|
34
|
167
|
50
|
66
|
|
|
381
|
die 'is_adjacent requires an intersection or path argument' |
|
|
|
33
|
|
|
|
|
35
|
|
|
|
|
|
|
unless $obj && |
36
|
|
|
|
|
|
|
($obj->isa('Catan::Map::Intersection') |
37
|
|
|
|
|
|
|
|| $obj->isa('Catan::Map::Path')); |
38
|
|
|
|
|
|
|
|
39
|
167
|
100
|
|
|
|
701
|
if ($obj->isa('Catan::Map::Intersection')) |
|
|
50
|
|
|
|
|
|
40
|
|
|
|
|
|
|
{ |
41
|
111
|
|
100
|
|
|
305
|
return $obj eq $self->{start} || $obj eq $self->{end}; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
elsif ($obj->isa('Catan::Map::Path')) |
44
|
|
|
|
|
|
|
{ |
45
|
56
|
50
|
|
|
|
111
|
return 0 if $self->is_colliding($obj); |
46
|
|
|
|
|
|
|
return $obj->{start} eq $self->{start} || $obj->{start} eq $self->{end} |
47
|
56
|
|
100
|
|
|
181
|
|| $obj->{end} eq $self->{start} || $obj->{end} eq $self->{end}; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub is_colliding |
52
|
|
|
|
|
|
|
{ |
53
|
25579
|
|
|
25579
|
0
|
33457
|
my ($self, $obj) = @_; |
54
|
|
|
|
|
|
|
|
55
|
25579
|
50
|
33
|
|
|
45273
|
die 'is_colliding requires a path argument' |
56
|
|
|
|
|
|
|
unless $obj && $obj->isa('Catan::Map::Path'); |
57
|
|
|
|
|
|
|
|
58
|
25579
|
|
|
|
|
50684
|
return $obj eq $self; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__END__ |