line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Games::Lacuna::Task::Report::Glyph; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1382
|
use 5.010; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
54
|
|
4
|
|
|
|
|
|
|
our $VERSION = $Games::Lacuna::Task::VERSION; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
778
|
use Moose::Role; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Games::Lacuna::Client::Types qw(ore_types); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub report_glyph { |
11
|
|
|
|
|
|
|
my ($self) = @_; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $table = Games::Lacuna::Task::Table->new( |
14
|
|
|
|
|
|
|
headline=> 'Glyph Report', |
15
|
|
|
|
|
|
|
columns => ['Planet',(map { ucfirst($_) } ore_types()),'Total'], |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $cache_glyphs = { map { $_ => 0 } ore_types() }; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
foreach my $planet_id ($self->my_planets) { |
21
|
|
|
|
|
|
|
my %planet_glyphs = $self->_report_glyph_planet($planet_id,$table); |
22
|
|
|
|
|
|
|
while (my ($glyph,$count) = each %planet_glyphs) { |
23
|
|
|
|
|
|
|
$cache_glyphs->{$glyph} += $count; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Write glyph cache |
28
|
|
|
|
|
|
|
$self->set_cache( |
29
|
|
|
|
|
|
|
key => 'glyphs', |
30
|
|
|
|
|
|
|
value => $cache_glyphs, |
31
|
|
|
|
|
|
|
max_age => (60*60*24), |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
return $table; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _report_glyph_planet { |
38
|
|
|
|
|
|
|
my ($self,$planet_id,$table) = @_; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $planet_stats = $self->my_body_status($planet_id); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Get archaeology ministry |
43
|
|
|
|
|
|
|
my $archaeology_ministry = $self->find_building($planet_stats->{id},'Archaeology'); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
return |
46
|
|
|
|
|
|
|
unless defined $archaeology_ministry; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Get all glyphs |
49
|
|
|
|
|
|
|
my $archaeology_ministry_object = $self->build_object($archaeology_ministry); |
50
|
|
|
|
|
|
|
my $gylph_data = $self->request( |
51
|
|
|
|
|
|
|
object => $archaeology_ministry_object, |
52
|
|
|
|
|
|
|
method => 'get_glyphs', |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my $total_glyphs = 0; |
56
|
|
|
|
|
|
|
my %all_glyphs = ( map { $_ => 0 } ore_types() ); |
57
|
|
|
|
|
|
|
foreach my $glyph (@{$gylph_data->{glyphs}}) { |
58
|
|
|
|
|
|
|
$all_glyphs{$glyph->{type}} ++; |
59
|
|
|
|
|
|
|
$total_glyphs ++; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
$table->add_row({ |
63
|
|
|
|
|
|
|
planet => $planet_stats->{name}, |
64
|
|
|
|
|
|
|
total => $total_glyphs, |
65
|
|
|
|
|
|
|
%all_glyphs, |
66
|
|
|
|
|
|
|
}); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
return %all_glyphs; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
no Moose::Role; |
72
|
|
|
|
|
|
|
1; |