line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Games::Lacuna::Task::Role::PlanetRun; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1468
|
use 5.010; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
56
|
|
4
|
|
|
|
|
|
|
our $VERSION = $Games::Lacuna::Task::VERSION; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
556
|
use Moose::Role; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
requires qw(process_planet); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has 'exclude_planet' => ( |
10
|
|
|
|
|
|
|
is => 'rw', |
11
|
|
|
|
|
|
|
isa => 'ArrayRef[Str]', |
12
|
|
|
|
|
|
|
documentation => 'Do not process given planets', |
13
|
|
|
|
|
|
|
traits => ['Array'], |
14
|
|
|
|
|
|
|
default => sub { [] }, |
15
|
|
|
|
|
|
|
handles => { |
16
|
|
|
|
|
|
|
'has_exclude_planet' => 'count', |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has 'only_planet' => ( |
21
|
|
|
|
|
|
|
is => 'rw', |
22
|
|
|
|
|
|
|
isa => 'ArrayRef[Str]', |
23
|
|
|
|
|
|
|
documentation => 'Only process given planets', |
24
|
|
|
|
|
|
|
traits => ['Array'], |
25
|
|
|
|
|
|
|
default => sub { [] }, |
26
|
|
|
|
|
|
|
handles => { |
27
|
|
|
|
|
|
|
'has_only_planet' => 'count', |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub run { |
32
|
|
|
|
|
|
|
my ($self) = @_; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
foreach my $planet_stats ($self->get_planets) { |
35
|
|
|
|
|
|
|
$self->log('info',"Processing planet %s",$planet_stats->{name}); |
36
|
|
|
|
|
|
|
$self->process_planet($planet_stats); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub get_planets { |
41
|
|
|
|
|
|
|
my ($self) = @_; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my @planets; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# Only selected planets |
46
|
|
|
|
|
|
|
if ($self->has_only_planet) { |
47
|
|
|
|
|
|
|
foreach my $only_planet (@{$self->only_planet}) { |
48
|
|
|
|
|
|
|
my $planet = $self->my_body_status($only_planet); |
49
|
|
|
|
|
|
|
push(@planets,$planet) |
50
|
|
|
|
|
|
|
if $planet; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
# All but selected planets |
53
|
|
|
|
|
|
|
} elsif ($self->has_exclude_planet) { |
54
|
|
|
|
|
|
|
my @exclude_planets; |
55
|
|
|
|
|
|
|
foreach my $planet (@{$self->exclude_planet}) { |
56
|
|
|
|
|
|
|
my $planet_id = $self->my_body_id($planet); |
57
|
|
|
|
|
|
|
push(@exclude_planets,$planet_id) |
58
|
|
|
|
|
|
|
if $planet_id; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
foreach my $planet_stats ($self->my_planets) { |
61
|
|
|
|
|
|
|
push(@planets,$planet_stats) |
62
|
|
|
|
|
|
|
unless $planet_stats->{id} ~~ \@exclude_planets; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
# All planets |
65
|
|
|
|
|
|
|
} else { |
66
|
|
|
|
|
|
|
@planets = $self->my_planets; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
return @planets; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
no Moose::Role; |
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=encoding utf8 |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 NAME |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Games::Lacuna::Role::PlanetRun -Â Helper role for all planet-centric actions |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 SYNOPSIS |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
package Games::Lacuna::Task::Action::MyTask; |
84
|
|
|
|
|
|
|
use Moose; |
85
|
|
|
|
|
|
|
extends qw(Games::Lacuna::Task::Action); |
86
|
|
|
|
|
|
|
with qw(Games::Lacuna::Task::Role::RPCLimit); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub process_planet { |
89
|
|
|
|
|
|
|
my ($self,$planet_stats) = @_; |
90
|
|
|
|
|
|
|
... |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |