line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Settlers::Map::Path; |
2
|
|
|
|
|
|
|
$Settlers::Map::Path::VERSION = '0.07'; |
3
|
3
|
|
|
3
|
|
14
|
use strict; |
|
3
|
|
|
1
|
|
5
|
|
|
3
|
|
|
|
|
69
|
|
|
1
|
|
|
|
|
861
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
4
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
3
|
|
|
1
|
|
6
|
|
|
3
|
|
|
|
|
83
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use overload |
7
|
3
|
|
|
|
|
22
|
'""' => 'uuid', |
|
1
|
|
|
|
|
5
|
|
8
|
3
|
|
|
3
|
|
64
|
fallback => 1; |
|
3
|
|
|
1
|
|
6
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
1
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new |
11
|
|
|
|
|
|
|
{ |
12
|
949
|
|
|
949
|
0
|
1449
|
my ($class, $intersections) = @_; |
13
|
949
|
50
|
33
|
|
|
6317
|
die 'Path->new() requires an arrayref of 2 intersections' |
|
|
|
33
|
|
|
|
|
14
|
|
|
|
|
|
|
unless $intersections && ref $intersections eq 'ARRAY' && @$intersections == 2; |
15
|
|
|
|
|
|
|
|
16
|
949
|
50
|
|
|
|
2653
|
die 'Path->new() start and end intersections must be adjacent' |
17
|
|
|
|
|
|
|
unless $intersections->[0]->is_adjacent($intersections->[1]); |
18
|
|
|
|
|
|
|
|
19
|
949
|
|
|
|
|
2675
|
bless { |
20
|
|
|
|
|
|
|
uuid => join(' ', sort $intersections->[0]->uuid, $intersections->[1]->uuid), |
21
|
|
|
|
|
|
|
start => $intersections->[0], |
22
|
|
|
|
|
|
|
end => $intersections->[1], |
23
|
|
|
|
|
|
|
}, $class; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
5697
|
|
|
5697
|
0
|
15049
|
sub start { $_[0]->{start} } |
27
|
3860
|
|
|
3860
|
0
|
10014
|
sub end { $_[0]->{end} } |
28
|
103668
|
|
|
103668
|
0
|
359118
|
sub uuid { $_[0]->{uuid} } |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub is_adjacent |
31
|
|
|
|
|
|
|
{ |
32
|
419
|
|
|
419
|
0
|
584
|
my ($self, $obj) = @_; |
33
|
|
|
|
|
|
|
|
34
|
419
|
50
|
66
|
|
|
979
|
die 'is_adjacent requires an intersection or path argument' |
|
|
|
33
|
|
|
|
|
35
|
|
|
|
|
|
|
unless $obj && |
36
|
|
|
|
|
|
|
($obj->isa('Settlers::Map::Intersection') |
37
|
|
|
|
|
|
|
|| $obj->isa('Settlers::Map::Path')); |
38
|
|
|
|
|
|
|
|
39
|
419
|
100
|
|
|
|
1537
|
if ($obj->isa('Settlers::Map::Intersection')) |
|
|
50
|
|
|
|
|
|
40
|
|
|
|
|
|
|
{ |
41
|
363
|
|
100
|
|
|
962
|
return $obj eq $self->{start} || $obj eq $self->{end}; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
elsif ($obj->isa('Settlers::Map::Path')) |
44
|
|
|
|
|
|
|
{ |
45
|
56
|
50
|
|
|
|
117
|
return 0 if $self->is_colliding($obj); |
46
|
|
|
|
|
|
|
return $obj->{start} eq $self->{start} || $obj->{start} eq $self->{end} |
47
|
56
|
|
100
|
|
|
173
|
|| $obj->{end} eq $self->{start} || $obj->{end} eq $self->{end}; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub is_colliding |
52
|
|
|
|
|
|
|
{ |
53
|
25579
|
|
|
25579
|
0
|
33719
|
my ($self, $obj) = @_; |
54
|
|
|
|
|
|
|
|
55
|
25579
|
50
|
33
|
|
|
43266
|
die 'is_colliding requires a path argument' |
56
|
|
|
|
|
|
|
unless $obj && $obj->isa('Settlers::Map::Path'); |
57
|
|
|
|
|
|
|
|
58
|
25579
|
|
|
|
|
53431
|
return $obj eq $self; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__END__ |