Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Misc updates, includes ship invalidation based on excavator replaceme…

…nt mail
  • Loading branch information...
commit 9abcb4be21fe7b236181dd319d1cf6eb8560ee4d 1 parent 43f0066
T. Alexander Popiel authored
View
6 archaeologist.pl
@@ -127,7 +127,7 @@
}
@ores = sort keys %ores;
my $port = $client->find_building($body_id, "Space Port");
- my $ships = $client->port_all_ships($port->{id});
+ my $ships = $client->port_all_ships($body_id);
my @excavators = grep { $_->{type} eq "excavator" } @{$ships->{ships}};
my @travelling = grep { $_->{task} eq "Travelling" } @excavators;
for my $excavator (@travelling) {
@@ -169,7 +169,7 @@
}
@ores = sort keys %ores;
my $port = $client->find_building($body_id, "Space Port");
- my $ships = $client->port_all_ships($port->{id});
+ my $ships = $client->port_all_ships($body_id);
my @excavators = grep { $_->{type} eq "excavator" } @{$ships->{ships}};
my @travelling = grep { $_->{task} eq "Travelling" } @excavators;
for my $excavator (@travelling) {
@@ -341,7 +341,7 @@
next unless $delta > 0;
my $port = $client->find_building($body_id, "Space Port");
- my $ships = $client->port_all_ships($port->{id});
+ my $ships = $client->port_all_ships($body_id);
my @excavators = grep { $_->{type} eq "excavator" } @{$ships->{ships}};
my @ready = grep { $_->{task} eq "Docked" } @excavators;
View
24 balance_resources.pl
@@ -21,15 +21,17 @@
my $quiet = 0;
my $noaction = 0;
my $do_waste = 1;
+my $use_chain = 0;
GetOptions(
- "config=s" => \$config_name,
- "body=s" => \@body_names,
- "ship|name=s" => \$ship_name,
- "debug" => \$debug,
- "quiet" => \$quiet,
- "noaction!" => \$noaction,
- "waste!" => \$do_waste,
+ "config=s" => \$config_name,
+ "body=s" => \@body_names,
+ "ship|name=s" => \$ship_name,
+ "debug" => \$debug,
+ "quiet" => \$quiet,
+ "noaction!" => \$noaction,
+ "waste!" => \$do_waste,
+ "use_chain|chain!" => \$use_chain,
) or die "$0 --config=foo.json --body=Bar\n";
my @foods = qw(algae apple bean beetle bread burger
@@ -210,6 +212,14 @@ sub express_desires {
return %ideals;
}
+sub find_best_chaining {
+ for my $resource (@resources) {
+ my @bodies = keys %vitals;
+ my %excess = map { $_, ($ideals{$_}{$resource} - $vitals{$_}{resources}{$resource}) } @bodies;
+# for my $
+ }
+}
+
sub find_best_shipping {
my %vitals = %{shift()};
my %ideals = %{shift()};
View
5 build_queue.pl
@@ -585,6 +585,11 @@ sub upgrade_check {
if $status->{"${_}_stored"} < $building->{upgrade}{cost}{$_};
}
return "Not enough ".join(", ", @message)." in storage to build this." if @message;
+ for (qw(food ore water energy)) {
+ push(@message, "$_ (".($status->{"${_}_hour"} - $building->{upgrade}{production}{"${_}_hour"} + $building->{"${_}_hour"})."/hour)")
+ if $status->{"${_}_hour"} < $building->{upgrade}{production}{"${_}_hour"} - $building->{"${_}_hour"};
+ }
+ return "Unsustainable. Not enough ".join(", ", @message)." production." if @message;
my $view = $client->building_view($building->{url}, $building->{id})->{building};
return $view->{upgrade}{reason}[1] unless $view->{upgrade}{can};
return;
View
12 mailman.pl
@@ -64,6 +64,18 @@ sub match_planet {
emit("Trashing $message->{id}") if $debug;
push(@trash, $message->{id});
}
+ if (grep(/Excavator/, @{$message->{tags}}) &&
+ $message->{subject} =~ /Excavator Results/) {
+ my $detail = $client->call(inbox => read_message => $message->{id});
+ my @replacements = grep { $_->[1] eq "Replace" && $_->[2] !~ /^Fail/ } @{$detail->{message}{attachments}{table}};
+ if (@replacements) {
+ my $body_id = ($detail->{message}{body} =~ /\{Planet (\d+)/);
+ emit("Excavator replacement for ".join(", ", map { $_->[0] } @replacements)."; invalidating ship list.", $body_id);
+ $client->cache_invalidate( type => 'spaceport_view_all_ships', id => $body_id );
+ }
+ emit("Trashing $message->{id}") if $debug;
+ push(@trash, $message->{id});
+ }
}
last unless @trash;
Please sign in to comment.
Something went wrong with that request. Please try again.