| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Games::Lacuna::Task::Action::WasteDispose; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1656
|
use 5.010; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
152
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = $Games::Lacuna::Task::VERSION; |
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
626
|
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 => ['dispose_percentage','keep_waste_hours'] }; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub description { |
|
13
|
|
|
|
|
|
|
return q[Dispose overflowing waste with scows]; |
|
14
|
|
|
|
|
|
|
} |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub process_planet { |
|
17
|
|
|
|
|
|
|
my ($self,$planet_stats) = @_; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Get stored waste |
|
20
|
|
|
|
|
|
|
my $waste_stored = $planet_stats->{waste_stored}; |
|
21
|
|
|
|
|
|
|
my $waste_capacity = $planet_stats->{waste_capacity}; |
|
22
|
|
|
|
|
|
|
my $waste_filled = ($waste_stored / $waste_capacity) * 100; |
|
23
|
|
|
|
|
|
|
my $waste_disposeable = $self->disposeable_waste($planet_stats); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Check if waste is overflowing |
|
26
|
|
|
|
|
|
|
return |
|
27
|
|
|
|
|
|
|
if ($waste_filled < $self->dispose_percentage); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# Get space port |
|
30
|
|
|
|
|
|
|
my ($spaceport) = $self->find_building($planet_stats->{id},'SpacePort'); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
return |
|
33
|
|
|
|
|
|
|
unless $spaceport; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $spaceport_object = $self->build_object($spaceport); |
|
36
|
|
|
|
|
|
|
my $spaceport_data = $self->request( |
|
37
|
|
|
|
|
|
|
object => $spaceport_object, |
|
38
|
|
|
|
|
|
|
method => 'view_all_ships', |
|
39
|
|
|
|
|
|
|
params => [ { no_paging => 1 } ], |
|
40
|
|
|
|
|
|
|
); |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Get all available scows |
|
43
|
|
|
|
|
|
|
foreach my $ship (@{$spaceport_data->{ships}}) { |
|
44
|
|
|
|
|
|
|
next |
|
45
|
|
|
|
|
|
|
unless $ship->{task} eq 'Docked'; |
|
46
|
|
|
|
|
|
|
next |
|
47
|
|
|
|
|
|
|
unless $ship->{type} eq 'scow'; |
|
48
|
|
|
|
|
|
|
next |
|
49
|
|
|
|
|
|
|
if $ship->{name} =~ m/\!/; |
|
50
|
|
|
|
|
|
|
next |
|
51
|
|
|
|
|
|
|
if $ship->{hold_size} > $waste_disposeable; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
$self->log('notice',"Disposing %s waste on %s",$ship->{hold_size},$planet_stats->{name}); |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# Send scow to closest star |
|
56
|
|
|
|
|
|
|
my $spaceport_data = $self->request( |
|
57
|
|
|
|
|
|
|
object => $spaceport_object, |
|
58
|
|
|
|
|
|
|
method => 'send_ship', |
|
59
|
|
|
|
|
|
|
params => [ $ship->{id},{ "star_id" => $planet_stats->{star_id} } ], |
|
60
|
|
|
|
|
|
|
); |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
$waste_disposeable -= $ship->{hold_size}; |
|
63
|
|
|
|
|
|
|
$waste_stored -= $ship->{hold_size}; |
|
64
|
|
|
|
|
|
|
$waste_filled = ($waste_stored / $waste_capacity) * 100; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# Check if waste is overflowing |
|
67
|
|
|
|
|
|
|
return |
|
68
|
|
|
|
|
|
|
if ($waste_filled < $self->dispose_percentage); |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
$self->clear_cache('body/'.$planet_stats->{id}); |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
return; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
77
|
|
|
|
|
|
|
no Moose; |
|
78
|
|
|
|
|
|
|
1; |