line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Games::Lacuna::Task::Action::WasteProduction; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1758
|
use 5.010; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
64
|
|
4
|
|
|
|
|
|
|
our $VERSION = $Games::Lacuna::Task::VERSION; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
467
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
extends qw(Games::Lacuna::Task::Action); |
8
|
|
|
|
|
|
|
with 'Games::Lacuna::Task::Role::Waste', |
9
|
|
|
|
|
|
|
'Games::Lacuna::Task::Role::PlanetRun', |
10
|
|
|
|
|
|
|
'Games::Lacuna::Task::Role::CommonAttributes' => { attributes => ['plan_for_hours'] }; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use List::Util qw(min); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub description { |
15
|
|
|
|
|
|
|
return q[Maintain minimum waste levels for waste recycling buildings]; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub process_planet { |
19
|
|
|
|
|
|
|
my ($self,$planet_stats) = @_; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Get stored waste |
22
|
|
|
|
|
|
|
my $waste_stored = $planet_stats->{waste_stored}; |
23
|
|
|
|
|
|
|
my $waste_hour = $planet_stats->{waste_hour}; |
24
|
|
|
|
|
|
|
my $waste_empty = $waste_stored + ($self->plan_for_hours * $waste_hour); |
25
|
|
|
|
|
|
|
my $waste_capacity = int($planet_stats->{waste_capacity} * 0.9 - $waste_stored); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
return |
28
|
|
|
|
|
|
|
if $waste_hour > 0; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
return |
31
|
|
|
|
|
|
|
if $waste_empty > 0; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $waste_dump = int($waste_empty * -1.1); |
34
|
|
|
|
|
|
|
$waste_dump = min($waste_dump,$waste_capacity); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
$self->convert_waste($planet_stats,$waste_dump); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
40
|
|
|
|
|
|
|
no Moose; |
41
|
|
|
|
|
|
|
1; |