| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package BalanceOfPower::Player::Role::Traveler; |
|
2
|
|
|
|
|
|
|
$BalanceOfPower::Player::Role::Traveler::VERSION = '0.400110'; |
|
3
|
13
|
|
|
13
|
|
4245
|
use strict; |
|
|
13
|
|
|
|
|
18
|
|
|
|
13
|
|
|
|
|
287
|
|
|
4
|
13
|
|
|
13
|
|
96
|
use v5.10; |
|
|
13
|
|
|
|
|
29
|
|
|
5
|
13
|
|
|
13
|
|
37
|
use Moo::Role; |
|
|
13
|
|
|
|
|
12
|
|
|
|
13
|
|
|
|
|
58
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
13
|
|
|
13
|
|
2597
|
use BalanceOfPower::Constants ':all'; |
|
|
13
|
|
|
|
|
15
|
|
|
|
13
|
|
|
|
|
8178
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has position => ( |
|
12
|
|
|
|
|
|
|
is => 'rw', |
|
13
|
|
|
|
|
|
|
); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has movements => ( |
|
16
|
|
|
|
|
|
|
is => 'rw', |
|
17
|
|
|
|
|
|
|
); |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub print_travel_plan |
|
22
|
|
|
|
|
|
|
{ |
|
23
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
24
|
0
|
|
|
|
|
0
|
my $world = shift; |
|
25
|
0
|
|
0
|
|
|
0
|
my $mode = shift || 'print'; |
|
26
|
0
|
|
|
|
|
0
|
my %plan = $world->make_travel_plan($self->position); |
|
27
|
0
|
|
|
|
|
0
|
return BalanceOfPower::Printer::print($mode, $self, 'print_travel_plan', |
|
28
|
|
|
|
|
|
|
{ plan => \%plan } ); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub refill_movements |
|
33
|
|
|
|
|
|
|
{ |
|
34
|
10
|
|
|
10
|
0
|
12
|
my $self = shift; |
|
35
|
10
|
|
|
|
|
31
|
$self->movements(PLAYER_MOVEMENTS); |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
sub go |
|
38
|
|
|
|
|
|
|
{ |
|
39
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
40
|
0
|
|
|
|
|
|
my $world = shift; |
|
41
|
0
|
|
|
|
|
|
my $destination = shift; |
|
42
|
0
|
|
|
|
|
|
my %plan = $world->make_travel_plan($self->position); |
|
43
|
0
|
|
|
|
|
|
foreach my $way ('air', 'ground') |
|
44
|
|
|
|
|
|
|
{ |
|
45
|
0
|
0
|
|
|
|
|
if(my $route = $plan{$way}->{$destination}) |
|
46
|
|
|
|
|
|
|
{ |
|
47
|
0
|
0
|
|
|
|
|
if($route->{status} eq 'KO') |
|
|
|
0
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
{ |
|
49
|
0
|
|
|
|
|
|
return -1; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
elsif($route->{cost} > $self->movements) |
|
52
|
|
|
|
|
|
|
{ |
|
53
|
0
|
|
|
|
|
|
return -2; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
0
|
|
|
|
|
|
$self->movements($self->movements - $route->{cost}); |
|
56
|
0
|
|
|
|
|
|
$self->position($destination); |
|
57
|
0
|
|
|
|
|
|
return (1, { destination => $destination, way => $way, cost => $route->{cost} }); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
} |
|
60
|
0
|
|
|
|
|
|
return -3; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
1; |