| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package BalanceOfPower::Player::Role::Traveler; | 
| 2 |  |  |  |  |  |  | $BalanceOfPower::Player::Role::Traveler::VERSION = '0.400115'; | 
| 3 | 13 |  |  | 13 |  | 5242 | use strict; | 
|  | 13 |  |  |  |  | 21 |  | 
|  | 13 |  |  |  |  | 339 |  | 
| 4 | 13 |  |  | 13 |  | 128 | use v5.10; | 
|  | 13 |  |  |  |  | 44 |  | 
| 5 | 13 |  |  | 13 |  | 46 | use Moo::Role; | 
|  | 13 |  |  |  |  | 18 |  | 
|  | 13 |  |  |  |  | 75 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 | 13 |  |  | 13 |  | 3052 | use BalanceOfPower::Constants ':all'; | 
|  | 13 |  |  |  |  | 17 |  | 
|  | 13 |  |  |  |  | 10222 |  | 
| 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 | 17 | my $self = shift; | 
| 35 | 10 |  |  |  |  | 53 | $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; |