line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Games::Lacuna::Task::Report::Fleet; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1446
|
use 5.010; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
56
|
|
4
|
|
|
|
|
|
|
our $VERSION = $Games::Lacuna::Task::VERSION; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
497
|
use Moose::Role; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use List::Util qw(max min); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub report_fleet { |
11
|
|
|
|
|
|
|
my ($self) = @_; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $table = Games::Lacuna::Task::Table->new( |
14
|
|
|
|
|
|
|
headline=> 'Fleet Report', |
15
|
|
|
|
|
|
|
columns => ['Planet','Count','Type','Task','Hold Size','Speed','Stealth','Combat'], |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
foreach my $planet_id ($self->my_planets) { |
19
|
|
|
|
|
|
|
$self->_report_fleet_body($planet_id,$table); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
return $table; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _report_fleet_body { |
26
|
|
|
|
|
|
|
my ($self,$planet_id,$table) = @_; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $planet_stats = $self->my_body_status($planet_id); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Get mining ministry |
31
|
|
|
|
|
|
|
my $spaceport = $self->find_building($planet_stats->{id},'SpacePort'); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
return |
34
|
|
|
|
|
|
|
unless $spaceport; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $spaceport_object = $self->build_object($spaceport); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# Get all available ships |
39
|
|
|
|
|
|
|
my $ships_data = $self->request( |
40
|
|
|
|
|
|
|
object => $spaceport_object, |
41
|
|
|
|
|
|
|
method => 'view_all_ships', |
42
|
|
|
|
|
|
|
params => [ { no_paging => 1 } ], |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
my %ships; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
SHIPS: |
48
|
|
|
|
|
|
|
foreach my $ship (@{$ships_data->{ships}}) { |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my $moniker = join('_',$ship->{type},$ship->{task}); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
$ships{$moniker} ||= { |
53
|
|
|
|
|
|
|
count => 0, |
54
|
|
|
|
|
|
|
type => $ship->{type_human}, |
55
|
|
|
|
|
|
|
task => $ship->{task}, |
56
|
|
|
|
|
|
|
}; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
foreach my $quality (qw(speed stealth hold_size combat)) { |
59
|
|
|
|
|
|
|
$ships{$moniker}->{$quality} ||= []; |
60
|
|
|
|
|
|
|
push(@{$ships{$moniker}->{$quality}},$ship->{$quality}) |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
$ships{$moniker}{count} ++; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
foreach my $ship (sort { $a->{type} cmp $b->{type} } values %ships) { |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
foreach my $quality (qw(speed stealth hold_size combat)) { |
70
|
|
|
|
|
|
|
my $min = min(@{$ship->{$quality}}); |
71
|
|
|
|
|
|
|
my $max = max(@{$ship->{$quality}}); |
72
|
|
|
|
|
|
|
if ($min != $max) { |
73
|
|
|
|
|
|
|
$ship->{$quality} = $min.'-'.$max; |
74
|
|
|
|
|
|
|
} else { |
75
|
|
|
|
|
|
|
$ship->{$quality} = $min; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
$table->add_row({ |
80
|
|
|
|
|
|
|
planet => $planet_stats->{name}, |
81
|
|
|
|
|
|
|
%$ship |
82
|
|
|
|
|
|
|
}); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
no Moose::Role; |
88
|
|
|
|
|
|
|
1; |