From 75716be62e0b3b18420a076ec243f69d94fb502b Mon Sep 17 00:00:00 2001 From: Ian Docherty Date: Fri, 20 Jul 2012 17:57:47 -0400 Subject: [PATCH 1/2] Fixed fractional resources showing in summary --- lib/Lacuna/DB/Result/Map/Body/Planet.pm | 28 +++++++------------------ 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/lib/Lacuna/DB/Result/Map/Body/Planet.pm b/lib/Lacuna/DB/Result/Map/Body/Planet.pm index 2252dbba..4fd72267 100644 --- a/lib/Lacuna/DB/Result/Map/Body/Planet.pm +++ b/lib/Lacuna/DB/Result/Map/Body/Planet.pm @@ -917,8 +917,6 @@ sub build_building { sub found_colony { my ($self, $empire) = @_; $self->empire_id($empire->id); -# $self->empire($empire); -# weaken($self->{_relationship_data}{empire}); $self->usable_as_starter_enabled(0); $self->last_tick(DateTime->now); $self->update; @@ -1481,17 +1479,13 @@ sub tick_to { my $total_ore = $self->ore_stored; if ($total_ore > 0) { my $deduct_ratio = $ore_consumed / $total_ore; + $deduct_ratio = 1 if $deduct_ratio > 1; foreach my $type (ORE_TYPES) { my $type_stored = $self->type_stored($type); $ore{$type} = 0 if $ore{$type} > 0; - if ($deduct_ratio > 1) { - $self->spend_ore_type($type, $type_stored); - $ore_consumed -= $type_stored; - } - else { - $self->spend_ore_type($type, $type_stored * $deduct_ratio); - $ore_consumed -= $type_stored * $deduct_ratio; - } + my $to_deduct = sprintf('%.0f', $type_stored * $deduct_ratio); + $self->spend_ore_type($type, $to_deduct); + $ore_consumed -= $to_deduct; } } @@ -1541,20 +1535,14 @@ sub tick_to { if ($total_food > 0) { # my $deduct_ratio = $food_consumed / $total_food; + $deduct_ratio = 1 if $deduct_ratio > 1; foreach my $type (FOOD_TYPES) { my $type_stored = $self->type_stored($type); $food{$type} = 0 if $food{$type} > 0; - if ($deduct_ratio > 1) { - # then spend it all - $self->spend_food_type($type, $type_stored); - $food_consumed -= $type_stored; - } - else { - $self->spend_food_type($type, $type_stored * $deduct_ratio); - $food_consumed -= $type_stored * $deduct_ratio; - } + my $to_deduct = sprintf('%.0f', $type_stored * $deduct_ratio); + $self->spend_food_type($type, $to_deduct); + $food_consumed -= $to_deduct; } - } # if we *still* have food to consume when we have nothing then we are in trouble! if ($food_consumed > 0) { -- 2.51.2 From 134037426513106ac5c697d36ec6cacb67f0c8cd Mon Sep 17 00:00:00 2001 From: Ian Docherty Date: Sat, 21 Jul 2012 11:47:28 -0400 Subject: [PATCH 2/2] Supply chains that stall send a message --- lib/Lacuna/DB/Result/Map/Body/Planet.pm | 11 +++++++++++ var/messages/stalled_chain.txt | 7 +++++++ var/www/public/changes.txt | 11 ++++++----- 3 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 var/messages/stalled_chain.txt diff --git a/lib/Lacuna/DB/Result/Map/Body/Planet.pm b/lib/Lacuna/DB/Result/Map/Body/Planet.pm index 4fd72267..86d273e7 100644 --- a/lib/Lacuna/DB/Result/Map/Body/Planet.pm +++ b/lib/Lacuna/DB/Result/Map/Body/Planet.pm @@ -1603,6 +1603,17 @@ sub toggle_supply_chain { $chain->target->update; $self->needs_recalc(1); $self->update; + my $empire = $self->empire; + if ($stalled + and defined $empire + and not $empire->check_for_repeat_message('supply_stalled'.$chain->id)) { + $empire->send_predefined_message( + filename => 'stalled_chain.txt', + params => [$self->id, $self->name, $chain->resource_type], + repeat_check=> 'supply_stalled'.$chain->id, + tags => ['Complaint','Alert'], + ); + } } } diff --git a/var/messages/stalled_chain.txt b/var/messages/stalled_chain.txt new file mode 100644 index 00000000..093d7e49 --- /dev/null +++ b/var/messages/stalled_chain.txt @@ -0,0 +1,7 @@ +Transport Workers Strike +~~~ +Transport workers on {Planet %s %s} went on strike today when stocks of %s ran out. A spokesman from the union said that Supply chains would not be restarted until such time as stocks were replenished and that furthermore the union would not be held responsible for any damage caused. + +Regards, + +Your Humble Assistant diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 2153f7a1..322c7864 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -1,10 +1,11 @@ 3.0861: - Mod: Neutral Zone now enforced via Code. -- Add: Added water and energy to PCC and SCC Resources details -- Mod: Resource calculations now work correctly, but the proof is too large to fit in the margin. -- Mod: Supply chains that stall should no longer cause damage on the sending colony -- Fix: Glyphs for missions properly checked and used. - + - Add: Added water and energy to PCC and SCC Resources details + - Mod: Resource calculations now work correctly, but the proof is too large to fit in the margin. + - Mod: Supply chains that stall should no longer cause damage on the sending colony + - Fix: Glyphs for missions properly checked and used. + - Add: Supply chains that stall send a message + 3.0860: - Fix: Scows deliver the amount of waste in their payload, not capacity. - Fix: Space Station Command accessible via UI. -- 2.51.2