From 1c21153f09164bc6fcf11efd37d10cec8594e33f Mon Sep 17 00:00:00 2001 From: lemming552 Date: Mon, 14 May 2012 21:33:54 -0600 Subject: [PATCH] Unhappy equation messed with. --- lib/Lacuna/DB/Result/Building/Archaeology.pm | 35 ++++++++++---------- lib/Lacuna/DB/Result/Map/Body/Planet.pm | 4 ++- var/www/public/changes.txt | 3 +- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/lib/Lacuna/DB/Result/Building/Archaeology.pm b/lib/Lacuna/DB/Result/Building/Archaeology.pm index de2cd5f1..8fedef23 100644 --- a/lib/Lacuna/DB/Result/Building/Archaeology.pm +++ b/lib/Lacuna/DB/Result/Building/Archaeology.pm @@ -77,12 +77,13 @@ sub max_excavators { sub run_excavators { my $self = shift; + my $results; my $level = $self->level; my $empire = $self->body->empire; # Do once for arch itself. No chance of destroy or artifacts. my $result = $self->dig_it($self->body, $level, 1); $result->{id} = $self->id; - my @results = ($result); + push @{$results}, $result; if ($level > 10) { my $excavators = $self->excavators; while (my $excav = $excavators->next) { @@ -102,33 +103,33 @@ sub run_excavators { $result = $self->dig_it($body, $level, 0); $result->{id} = $excav->id; } - push @results, $result; + push @{$results}, $result; if ($result->{outcome} eq "Destroyed") { $self->remove_excavator($excav); } } } - my @report; - for $result (sort { $a->{site} cmp $b->{site} } @results) { + my $report; + for $result (sort { $a->{site} cmp $b->{site} } @{$results}) { next if ($empire->skip_found_nothing and $result->{outcome} eq "Nothing"); next if ($empire->skip_excavator_artifact and $result->{outcome} eq "Artifact"); next if ($empire->skip_excavator_resources and $result->{outcome} eq "Resource"); next if ($empire->skip_excavator_plan and $result->{outcome} eq "Plan"); next if ($empire->skip_excavator_glyph and $result->{outcome} eq "Glyph"); next if ($empire->skip_excavator_destroyed and $result->{outcome} eq "Destroyed"); - push @report, [ + push @{$report}, [ $result->{site}, $result->{outcome}, $result->{message}, ]; } - if (@report) { - unshift @report, (['Site','Type','Result']); + if (scalar @{$report}) { + unshift @{$report}, (['Site','Type','Result']); $empire->send_predefined_message( tags => ['Excavator','Alert'], filename => 'excavator_results.txt', params => [ $self->body->id, $self->body->name ], - attachments => { table => \@report}, + attachments => { table => $report}, ); } return 1; @@ -293,15 +294,15 @@ sub found_artifact { my ($self, $body, $level) = @_; my $plan_types = plans_of_type(); - my @buildings; + my $artifacts; my $buildings = $body->buildings; while (my $building = $buildings->next) { unless ( grep { $building->class eq $_ } @{$plan_types->{disallow}}) { - push @buildings, $building; + push @{$artifacts}, $building; } } - return (0,0,"Nothing") unless (@buildings); - my $select = random_element(\@buildings); + return (0,0,"Nothing") unless (scalar @{$artifacts}); + my $select = random_element($artifacts); my $class; my $lvl; my $plus; my $name; my $destroy; if ($level > $select->level and randint(1, int(3 * $level/2)) >= $select->level) { $class = $select->class; @@ -341,21 +342,21 @@ sub found_artifact { sub found_glyph { my ($self, $body) = @_; - my %ores; + my $ores; my $ore_total = 0; for my $ore (ORE_TYPES) { - $ores{$ore} = $body->$ore; - $ore_total += $ores{$ore}; + $ores->{$ore} = $body->$ore; + $ore_total += $ores->{$ore}; } my $base = 0; my $rnum = randint(1,$ore_total); my $glyph = "error"; for my $ore (ORE_TYPES) { - if ($rnum <= $ores{$ore} + $base) { + if ($rnum <= $ores->{$ore} + $base) { $glyph = $ore; last; } - $base += $ores{$ore}; + $base += $ores->{$ore}; } if ($glyph ne "error") { $self->body->add_glyph($glyph); diff --git a/lib/Lacuna/DB/Result/Map/Body/Planet.pm b/lib/Lacuna/DB/Result/Map/Body/Planet.pm index 1fa0b424..eaca6d4d 100644 --- a/lib/Lacuna/DB/Result/Map/Body/Planet.pm +++ b/lib/Lacuna/DB/Result/Map/Body/Planet.pm @@ -1085,8 +1085,10 @@ sub recalc_stats { # Decrease happiness production if short on plots. if ($stats{plots_available} < 0) { my $plot_tax = int(50 * 1.62 ** (abs($stats{plots_available})-1)); + my $max_neg = -2 * abs($stats{happiness_hour}); + $max_neg = -50_000 if $max_neg > -50_000; $stats{happiness_hour} -= $plot_tax; - $stats{happiness_hour} = -100_000_000_000 if ($stats{happiness_hour} < -100_000_000_000); + $stats{happiness_hour} = $max_neg if ($stats{happiness_hour} < $max_neg); } $self->update(\%stats); diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 754f1df3..f1575ba3 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -3,11 +3,12 @@ - Mod: You don't have to build all Halls of Vrbansk to sacrifice (only one) - Add: API only, supply chain to any planet or SS. Note. No UI support yet. - Fix: Damaged Trade Ministry reduces the waste transferred in a waste chain. - - Fix: Scows are no longer are tagged with 'Trade' + - Fix: Scows are no longer tagged with 'Trade' - Mod: Change in consumption rates for secondary food. - Fix: Colony ships and trade ships in flight away from insurrected planet now switch flag to their own Capitol. - Mod: Ships in a fleet will return at their own speed if on return trip. - Mod: Damaged Platforms give plots based on efficiency. + - Mod: Damaged Pantheon gives plots based on efficiency. - Fix: Deployed Bleeders no longer count toward population totals. - Mod: Supply Pods no longer use a plot. - Mod: Being at negative plots makes your people unhappy. -- 2.54.0