line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Games::Lacuna::Task::Report::Incoming; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1558
|
use 5.010; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
67
|
|
4
|
|
|
|
|
|
|
our $VERSION = $Games::Lacuna::Task::VERSION; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
404
|
use Moose::Role; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Games::Lacuna::Task::Utils qw(parse_date); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub report_incoming { |
11
|
|
|
|
|
|
|
my ($self) = @_; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $table = Games::Lacuna::Task::Table->new( |
14
|
|
|
|
|
|
|
headline=> 'Incoming Ships Report', |
15
|
|
|
|
|
|
|
columns => ['Planet','Type','Ship','From','ETA'], |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
foreach my $planet_id ($self->my_planets) { |
19
|
|
|
|
|
|
|
$self->_report_incoming_planet($planet_id,$table); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
return $table; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _report_incoming_planet { |
26
|
|
|
|
|
|
|
my ($self,$planet_id,$table) = @_; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $planet_stats = $self->my_body_status($planet_id); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
return |
31
|
|
|
|
|
|
|
unless defined($planet_stats->{incoming_enemy_ships}); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Get space port |
34
|
|
|
|
|
|
|
my $spaceport = $self->find_building($planet_stats->{id},'SpacePort'); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
return |
37
|
|
|
|
|
|
|
unless defined $spaceport; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my $spaceport_object = $self->build_object($spaceport); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Get all incoming ships |
42
|
|
|
|
|
|
|
my $ships_data = $self->paged_request( |
43
|
|
|
|
|
|
|
object => $spaceport_object, |
44
|
|
|
|
|
|
|
method => 'view_foreign_ships', |
45
|
|
|
|
|
|
|
total => 'number_of_ships', |
46
|
|
|
|
|
|
|
data => 'ships', |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my %incoming; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
foreach my $element (@{$ships_data->{ships}}) { |
52
|
|
|
|
|
|
|
my $type; |
53
|
|
|
|
|
|
|
if ($element->{is_own}) { |
54
|
|
|
|
|
|
|
$type = 'own'; |
55
|
|
|
|
|
|
|
} elsif ($element->{is_ally}) { |
56
|
|
|
|
|
|
|
$type = 'ally'; |
57
|
|
|
|
|
|
|
} else { |
58
|
|
|
|
|
|
|
$type = 'hostile'; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
my $from = 'unknown'; |
61
|
|
|
|
|
|
|
$incoming{$element->{id}} = { |
62
|
|
|
|
|
|
|
type => $type, |
63
|
|
|
|
|
|
|
from => $from, |
64
|
|
|
|
|
|
|
ship => $element->{type_human}, |
65
|
|
|
|
|
|
|
eta => parse_date($element->{date_arrives}), |
66
|
|
|
|
|
|
|
}; |
67
|
|
|
|
|
|
|
if (defined $element->{from}) { |
68
|
|
|
|
|
|
|
$incoming{$element->{id}}{from} = ($element->{from}{empire}{name} // 'unknown').' '.($element->{from}{name} // 'unknown'); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
foreach my $element (values %incoming) { |
73
|
|
|
|
|
|
|
$table->add_row({ |
74
|
|
|
|
|
|
|
planet => $planet_stats->{name}, |
75
|
|
|
|
|
|
|
%$element |
76
|
|
|
|
|
|
|
}); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
no Moose::Role; |
81
|
|
|
|
|
|
|
1; |