From e1c6df5904957c0528925a4b89fed7f8da56364f Mon Sep 17 00:00:00 2001 From: lemming552 Date: Fri, 23 Dec 2011 23:27:05 -0700 Subject: [PATCH] Battle Logs and email generated when SAW disabled. Negative Resources fixed on planet tic. --- lib/Lacuna/DB/Result/Map/Body/Planet.pm | 24 ++++++++++++++++++- lib/Lacuna/Role/Ship/Arrive/TriggerDefense.pm | 13 +++++----- var/messages/saw_disabled.txt | 2 +- var/messages/saw_neutralized.txt | 2 +- 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/lib/Lacuna/DB/Result/Map/Body/Planet.pm b/lib/Lacuna/DB/Result/Map/Body/Planet.pm index fa4c3312..3c835092 100644 --- a/lib/Lacuna/DB/Result/Map/Body/Planet.pm +++ b/lib/Lacuna/DB/Result/Map/Body/Planet.pm @@ -850,7 +850,18 @@ sub recalc_stats { # overall ore production $stats{ore_hour} = $total_ore_production_hour - $ore_consumption_hour; - + + # deal with negative amounts stored + if ($self->water_stored < 0) { + $self->water_stored(0); + } + if ($self->energy_stored < 0) { + $self->energy_stored(0); + } + for my $type (FOOD_TYPES, ORE_TYPES) { + my $stype = $type.'_stored'; + $self->$stype(0) if ($self->$stype < 0); + } # deal with storage overages if ($self->ore_stored > $self->ore_capacity) { @@ -1127,6 +1138,17 @@ sub tick_to { $self->add_food(sprintf('%.0f', $self->food_hour * $tick_rate)); } } + # deal with negative amounts stored + if ($self->water_stored < 0) { + $self->water_stored(0); + } + if ($self->energy_stored < 0) { + $self->energy_stored(0); + } + for my $type (FOOD_TYPES, ORE_TYPES) { + my $stype = $type.'_stored'; + $self->$stype(0) if ($self->$stype < 0); + } $self->update; } diff --git a/lib/Lacuna/Role/Ship/Arrive/TriggerDefense.pm b/lib/Lacuna/Role/Ship/Arrive/TriggerDefense.pm index e0d2dc44..d71c3c7e 100644 --- a/lib/Lacuna/Role/Ship/Arrive/TriggerDefense.pm +++ b/lib/Lacuna/Role/Ship/Arrive/TriggerDefense.pm @@ -93,14 +93,15 @@ sub saw_disabled { $self->body->empire->send_predefined_message( tags => ['Attack','Alert'], filename => 'saw_neutralized.txt', - params => [$defender->body->x, + params => [ + $defender->body->x, $defender->body->y, $defender->body->name, + $defender->body->empire_id, + $defender->body->empire->name, $body_attacked->x, $body_attacked->y, - $body_attacked->name, - $defender->body->empire_id, - $defender->body->empire->name], + $body_attacked->name], ); } @@ -114,8 +115,8 @@ sub saw_disabled { $body_attacked->x, $body_attacked->y, $body_attacked->name, - $defender->body->empire_id, - $defender->body->empire->name, + $self->body->empire_id, + $self->body->empire->name, $self->type_formatted], ); } diff --git a/var/messages/saw_disabled.txt b/var/messages/saw_disabled.txt index 2e20080f..f959bcbc 100644 --- a/var/messages/saw_disabled.txt +++ b/var/messages/saw_disabled.txt @@ -1,6 +1,6 @@ SAW Disabled ~~~ -Our SAW at {Starmap %s %s %s} that was defending {Starmap %s %s %s} was disabled following an attack from Empire {Empire %s %s} by one of their %s. +Our SAW on {Starmap %s %s %s} while defending {Starmap %s %s %s} was disabled following an attack from the empire of {Empire %s %s} by one of their %ss. Regards, diff --git a/var/messages/saw_neutralized.txt b/var/messages/saw_neutralized.txt index 56b7da91..feaf60c5 100644 --- a/var/messages/saw_neutralized.txt +++ b/var/messages/saw_neutralized.txt @@ -1,6 +1,6 @@ SAW Neutralized ~~~ -Our offensive squadron was able to neutralize a SAW from {Starmap %s %s %s} that was defending {Starmap %s %s %s}. Empire {Empire %s %s}. +Our offensive squadron was able to neutralize a SAW on planet {Starmap %s %s %s} from the empire of {Empire %s %s} that was defending {Starmap %s %s %s}. Regards, -- 2.51.2