diff --git a/lib/Lacuna/DB/Result/Building.pm b/lib/Lacuna/DB/Result/Building.pm index 41734d4b..9089a0f1 100755 --- a/lib/Lacuna/DB/Result/Building.pm +++ b/lib/Lacuna/DB/Result/Building.pm @@ -1264,6 +1264,20 @@ sub spend_efficiency { return $self; } +# POPULATION + +has population => ( + is => 'ro', + lazy => 1, + builder => '_build_population', + ); + +sub _build_population { + my ($self) = @_; + + $self->effective_level * 10_000; +} + { local *ensure_class_loaded = sub {}; # graham's crazy fix for circular dependency, may break if DynamicSubclass gets upgraded __PACKAGE__->typecast_map(class => { diff --git a/lib/Lacuna/DB/Result/Building/DeployedBleeder.pm b/lib/Lacuna/DB/Result/Building/DeployedBleeder.pm index 8ee3fe03..2ea02873 100644 --- a/lib/Lacuna/DB/Result/Building/DeployedBleeder.pm +++ b/lib/Lacuna/DB/Result/Building/DeployedBleeder.pm @@ -116,6 +116,10 @@ use constant water_consumption => 250; use constant waste_production => 1000; use constant happiness_consumption => 1000; +# bleeders come with no population +sub _build_population { + 0 +} no Moose; __PACKAGE__->meta->make_immutable(inline_constructor => 0); diff --git a/lib/Lacuna/DB/Result/Building/Permanent.pm b/lib/Lacuna/DB/Result/Building/Permanent.pm index 9ae41820..5ddc4801 100644 --- a/lib/Lacuna/DB/Result/Building/Permanent.pm +++ b/lib/Lacuna/DB/Result/Building/Permanent.pm @@ -9,5 +9,10 @@ sub sortable_name { '25'.shift->name } +# permanent buildings come with no population +sub _build_population { + 0 +} + no Moose; __PACKAGE__->meta->make_immutable(inline_constructor => 0); diff --git a/lib/Lacuna/DB/Result/Building/SupplyPod.pm b/lib/Lacuna/DB/Result/Building/SupplyPod.pm index cd8d98e9..9bee2b38 100644 --- a/lib/Lacuna/DB/Result/Building/SupplyPod.pm +++ b/lib/Lacuna/DB/Result/Building/SupplyPod.pm @@ -67,6 +67,10 @@ use constant energy_storage => 2000; use constant ore_storage => 2000; use constant water_storage => 2000; +# supply pods come with no population +sub _build_population { + 0 +} no Moose; __PACKAGE__->meta->make_immutable(inline_constructor => 0); diff --git a/lib/Lacuna/DB/Result/Map/Body/Planet.pm b/lib/Lacuna/DB/Result/Map/Body/Planet.pm index 1e41f415..41c33a64 100644 --- a/lib/Lacuna/DB/Result/Map/Body/Planet.pm +++ b/lib/Lacuna/DB/Result/Map/Body/Planet.pm @@ -6,7 +6,7 @@ use utf8; no warnings qw(uninitialized); extends 'Lacuna::DB::Result::Map::Body'; use Lacuna::Constants qw(FOOD_TYPES ORE_TYPES BUILDABLE_CLASSES SPACE_STATION_MODULES); -use List::Util qw(shuffle max min none); +use List::Util qw(shuffle max min none sum); use Lacuna::Util qw(randint format_date random_element); use DateTime; use Data::Dumper; @@ -605,13 +605,8 @@ has population => ( sub _build_population { my ($self) = @_; - my $population = 0; - foreach my $building (@{$self->building_cache}) { - next if $building->class =~ /Lacuna::DB::Result::Building::Permanent/; - next if $building->class eq 'Lacuna::DB::Result::Building::DeployedBleeder'; - $population += $building->effective_level * 10_000; - } - return $population; + my $population = sum map { $_->population } @{$self->building_cache}; + return $population; } has building_count => ( diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index a15ed64c..e64a34ec 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -12,6 +12,7 @@ - Add: homeworld highlighted and always at the top of the public profile - Mod: Spies from tech levels above 15 on Jackpot are bounced automatically instead of jailed. - Fix: allow_bhg_by_alliance rejection fixed. + - Fix: Supply Pods don't count toward population. 3.0911: - Add: Reduce opacity for less-well-controlled stars.