From 80e18bbaa05a1f5947f2a4457e16cedd888fd540 Mon Sep 17 00:00:00 2001 From: Mark Lemming Date: Tue, 1 Jan 2013 10:56:17 -0700 Subject: [PATCH] fissure_sealer returns email on non-valid target --- lib/Lacuna/Role/Ship/Arrive/SealFissure.pm | 28 +++++++++++++++++----- var/messages/no_fissure_found.txt | 7 ++++++ var/messages/occupied_fissure.txt | 7 ++++++ var/www/public/changes.txt | 1 + 4 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 var/messages/no_fissure_found.txt create mode 100644 var/messages/occupied_fissure.txt diff --git a/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm b/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm index 50de60f3..e23e1bd6 100644 --- a/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm +++ b/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm @@ -9,13 +9,34 @@ use Lacuna::Constants qw(FOOD_TYPES ORE_TYPES); after handle_arrival_procedures => sub { my ($self) = @_; + my $body_hit = $self->foreign_body; + # we're coming home if ($self->direction eq 'in') { $self->unload($self->body); } # Turn around if occupied - return if ($self->foreign_body->empire_id); + if ($self->foreign_body->empire_id) { + $self->body->empire->send_predefined_message( + tags => ['Alert'], + filename => 'occupied_fissure.txt', + params => [$self->type_formatted, $body_hit->x, $body_hit->y, $body_hit->name ], + ); + return; + } + + # determine target building + my $building; + my ($fissure) = grep {$_->class eq 'Lacuna::DB::Result::Building::Permanent::Fissure'} @{$body_hit->building_cache}; + if (not defined($fissure)) { + $self->body->empire->send_predefined_message( + tags => ['Alert'], + filename => 'no_fissure_found.txt', + params => [$self->type_formatted, $body_hit->x, $body_hit->y, $body_hit->name ], + ); + return; + } my $amount = 0; my $payload = $self->payload; @@ -24,11 +45,6 @@ after handle_arrival_procedures => sub { $amount += $payload->{resources}{$type}; } } - # determine target building - my $building; - my $body_hit = $self->foreign_body; - my ($fissure) = grep {$_->class eq 'Lacuna::DB::Result::Building::Permanent::Fissure'} @{$body_hit->building_cache}; - return if not defined $fissure; $body_hit->add_news(10, sprintf('An attempt to fix the fissure on %s happened today.', $body_hit->name)); diff --git a/var/messages/no_fissure_found.txt b/var/messages/no_fissure_found.txt new file mode 100644 index 00000000..9a199bc4 --- /dev/null +++ b/var/messages/no_fissure_found.txt @@ -0,0 +1,7 @@ +No Fissure Found +~~~ +Our %s reached {Starmap %s %s %s} but no fissure was found. Ship is now returning to base. + +Regards, + +Your Humble Assistant diff --git a/var/messages/occupied_fissure.txt b/var/messages/occupied_fissure.txt new file mode 100644 index 00000000..2b0da3f6 --- /dev/null +++ b/var/messages/occupied_fissure.txt @@ -0,0 +1,7 @@ +Fissure Target Occupied +~~~ +Our %s reached {Starmap %s %s %s} but planet is now occupied. Ship is now returning to base. + +Regards, + +Your Humble Assistant diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 5dd5d543..09937f05 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -4,6 +4,7 @@ - Fix: Medals for buildings over level 31 and Asteroid A26 added. - Add: Upgrades can be cancelled from the Development Ministry - Add: Individual builds can be subsidized in the Development Ministry + - Add: Fissures send email if they don't find a fissure at target. 3.0876: - Add: Seasonal gift -- 2.51.2