From f290f92181d6b855f4b9cd4b70268db812cca571 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Wed, 20 Oct 2010 19:30:34 -0500 Subject: [PATCH] should fix the manufacturing stopped problem --- lib/Lacuna/DB/Result/Map/Body/Planet.pm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/Lacuna/DB/Result/Map/Body/Planet.pm b/lib/Lacuna/DB/Result/Map/Body/Planet.pm index ab889434..103c41e9 100644 --- a/lib/Lacuna/DB/Result/Map/Body/Planet.pm +++ b/lib/Lacuna/DB/Result/Map/Body/Planet.pm @@ -617,11 +617,22 @@ sub recalc_stats { } } } + my $overage; foreach my $type (ORE_TYPES) { my $method = $type.'_hour'; - $stats{$method} += sprintf('%.0f',$self->$type * $stats{ore_hour} / 10000); + my $planet_side = sprintf('%.0f',$self->$type * $stats{ore_hour} / 10000); # calculate local spend/prod + if (abs($planet_side) > $stats{$method}) { # local spend might be more than local production + $overage += abs($planet_side) - $stats{$method}; # make up the difference with an overage + $stats{$method} = 0; + } + else { + $stats{$method} += $planet_side; + } + } + $stats{ore_hour} += $mining_ministry_ore_hour - $overage; # adjust the total ore hour to reflect mining ministry and overage + if ($stats{ore_hour} < 0) { # if there's not enough total ore production to go around + $stats{gold_hour} = $stats{ore_hour}; # arbitrarily assign it to one type } - $stats{ore_hour} += $mining_ministry_ore_hour; $self->update(\%stats); return $self; } -- 2.51.2