From 694dc5c24f570b34c272a425b2e1bfbf6a217654 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Fri, 12 Nov 2010 11:11:21 -0600 Subject: [PATCH] fixed getting caught --- lib/Lacuna.pm | 2 +- lib/Lacuna/DB/Result/Ships.pm | 11 ++++++++++- var/messages/ship_captured_with_spies.txt | 11 +++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 var/messages/ship_captured_with_spies.txt diff --git a/lib/Lacuna.pm b/lib/Lacuna.pm index 6385fc6d..300d9676 100644 --- a/lib/Lacuna.pm +++ b/lib/Lacuna.pm @@ -7,7 +7,7 @@ use Config::JSON; useall __PACKAGE__; -our $VERSION = 2.2900; +our $VERSION = 2.2902; my $config = Config::JSON->new('/data/Lacuna-Server/etc/lacuna.conf'); my $db = Lacuna::DB->connect($config->get('db/dsn'),$config->get('db/username'),$config->get('db/password'), { mysql_enable_utf8 => 1}); diff --git a/lib/Lacuna/DB/Result/Ships.pm b/lib/Lacuna/DB/Result/Ships.pm index 2c28c985..6c343766 100644 --- a/lib/Lacuna/DB/Result/Ships.pm +++ b/lib/Lacuna/DB/Result/Ships.pm @@ -203,7 +203,10 @@ sub arrive { sub capture_with_spies { my ($self) = @_; - return 0 unless (exists $self->payload->{spies} || exists $self->payload->{fetch_spies} ); + return 0 unless ( + (exists $self->payload->{spies} && scalar(@{$self->payload->{spies}})) + || (exists $self->payload->{fetch_spies} && scalar(@{$self->payload->{fetch_spies}})) + ); my $body = $self->foreign_body; return 0 if ($body->empire_id == $self->body->empire_id); my $security = $body->get_building_of_class('Lacuna::DB::Result::Building::Security'); @@ -216,7 +219,13 @@ sub capture_with_spies { my $spy = $spies->find($id); next unless defined $spy; $spy->go_to_jail; + $spy->update; } + $self->body->empire->send_predefined_message( + tags => ['Alert'], + filename => 'ship_captured_with_spies.txt', + params => [$self->name, $body->x, $body->y, $body->name], + ); $self->delete; return 1; } diff --git a/var/messages/ship_captured_with_spies.txt b/var/messages/ship_captured_with_spies.txt new file mode 100644 index 00000000..58d6c8a1 --- /dev/null +++ b/var/messages/ship_captured_with_spies.txt @@ -0,0 +1,11 @@ +Ship Captured +~~~ +We received this message just moments ago from the commander of %s on route to {Starmap %s %s %s}. + +"Mayday! Mayday! Mayday! We're being boarded. There are troops on the ground. Agents on board. Request immediate....." + +I'm afraid the ship is lost, and our agents have been captured. + +Regards, + +Your Humble Assistant \ No newline at end of file -- 2.51.2