Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Refactored to move some repetitive code into roles.

  • Loading branch information...
commit 58ba6d109fd592e1c6a73634765a06a903a6470a 1 parent 6ca1c5c
@icydee icydee authored
Showing with 185 additions and 657 deletions.
  1. +73 −95 lib/Lacuna/DB/Result/Building.pm
  2. +6 −19 lib/Lacuna/DB/Result/Building/Permanent/AlgaePond.pm
  3. +3 −16 lib/Lacuna/DB/Result/Building/Permanent/AmalgusMeadow.pm
  4. +1 −7 lib/Lacuna/DB/Result/Building/Permanent/Beach1.pm
  5. +1 −8 lib/Lacuna/DB/Result/Building/Permanent/Beach10.pm
  6. +1 −7 lib/Lacuna/DB/Result/Building/Permanent/Beach11.pm
  7. +1 −7 lib/Lacuna/DB/Result/Building/Permanent/Beach12.pm
  8. +1 −7 lib/Lacuna/DB/Result/Building/Permanent/Beach13.pm
  9. +1 −7 lib/Lacuna/DB/Result/Building/Permanent/Beach2.pm
  10. +1 −7 lib/Lacuna/DB/Result/Building/Permanent/Beach3.pm
  11. +1 −7 lib/Lacuna/DB/Result/Building/Permanent/Beach4.pm
  12. +1 −7 lib/Lacuna/DB/Result/Building/Permanent/Beach5.pm
  13. +1 −7 lib/Lacuna/DB/Result/Building/Permanent/Beach6.pm
  14. +1 −7 lib/Lacuna/DB/Result/Building/Permanent/Beach7.pm
  15. +1 −7 lib/Lacuna/DB/Result/Building/Permanent/Beach8.pm
  16. +1 −7 lib/Lacuna/DB/Result/Building/Permanent/Beach9.pm
  17. +2 −15 lib/Lacuna/DB/Result/Building/Permanent/BeeldebanNest.pm
  18. +2 −15 lib/Lacuna/DB/Result/Building/Permanent/BlackHoleGenerator.pm
  19. +2 −15 lib/Lacuna/DB/Result/Building/Permanent/CitadelOfKnope.pm
  20. +2 −16 lib/Lacuna/DB/Result/Building/Permanent/CrashedShipSite.pm
  21. +1 −7 lib/Lacuna/DB/Result/Building/Permanent/Crater.pm
  22. +2 −15 lib/Lacuna/DB/Result/Building/Permanent/DentonBrambles.pm
  23. +2 −11 lib/Lacuna/DB/Result/Building/Permanent/EssentiaVein.pm
  24. +2 −15 lib/Lacuna/DB/Result/Building/Permanent/Fissure.pm
  25. +2 −8 lib/Lacuna/DB/Result/Building/Permanent/GasGiantPlatform.pm
  26. +3 −16 lib/Lacuna/DB/Result/Building/Permanent/GeoThermalVent.pm
  27. +3 −16 lib/Lacuna/DB/Result/Building/Permanent/GratchsGauntlet.pm
  28. +2 −8 lib/Lacuna/DB/Result/Building/Permanent/GreatBallOfJunk.pm
  29. +2 −8 lib/Lacuna/DB/Result/Building/Permanent/Grove.pm
  30. +2 −8 lib/Lacuna/DB/Result/Building/Permanent/HallsOfVrbansk.pm
  31. +3 −16 lib/Lacuna/DB/Result/Building/Permanent/InterDimensionalRift.pm
  32. +2 −8 lib/Lacuna/DB/Result/Building/Permanent/JunkHengeSculpture.pm
  33. +3 −16 lib/Lacuna/DB/Result/Building/Permanent/KalavianRuins.pm
  34. +5 −0 lib/Lacuna/DB/Result/Building/Permanent/KasternsKeep.pm
  35. +2 −8 lib/Lacuna/DB/Result/Building/Permanent/Lagoon.pm
  36. +2 −8 lib/Lacuna/DB/Result/Building/Permanent/Lake.pm
  37. +3 −16 lib/Lacuna/DB/Result/Building/Permanent/LapisForest.pm
  38. +3 −16 lib/Lacuna/DB/Result/Building/Permanent/LibraryOfJith.pm
  39. +3 −16 lib/Lacuna/DB/Result/Building/Permanent/MalcudField.pm
  40. +5 −0 lib/Lacuna/DB/Result/Building/Permanent/MassadsHenge.pm
  41. +2 −8 lib/Lacuna/DB/Result/Building/Permanent/MetalJunkArches.pm
  42. +3 −16 lib/Lacuna/DB/Result/Building/Permanent/NaturalSpring.pm
  43. +3 −16 lib/Lacuna/DB/Result/Building/Permanent/OracleOfAnid.pm
  44. +3 −17 lib/Lacuna/DB/Result/Building/Permanent/PantheonOfHagness.pm
  45. +2 −8 lib/Lacuna/DB/Result/Building/Permanent/PyramidJunkSculpture.pm
  46. +3 −16 lib/Lacuna/DB/Result/Building/Permanent/Ravine.pm
  47. +2 −8 lib/Lacuna/DB/Result/Building/Permanent/RockyOutcrop.pm
  48. +2 −8 lib/Lacuna/DB/Result/Building/Permanent/Sand.pm
  49. +2 −8 lib/Lacuna/DB/Result/Building/Permanent/SpaceJunkPark.pm
  50. +3 −16 lib/Lacuna/DB/Result/Building/Permanent/TempleOfTheDrajilites.pm
  51. +2 −8 lib/Lacuna/DB/Result/Building/Permanent/TerraformingPlatform.pm
  52. +3 −17 lib/Lacuna/DB/Result/Building/Permanent/Volcano.pm
  53. +0 −12 lib/Lacuna/DB/Result/Building/SAW.pm
View
168 lib/Lacuna/DB/Result/Building.pm
@@ -75,93 +75,56 @@ sub image_level {
sub produces_food_items { [] };
-use constant time_to_build => 60;
-
-use constant energy_to_build => 0;
-
-use constant food_to_build => 0;
-
-use constant ore_to_build => 0;
-
-use constant water_to_build => 0;
-
-use constant waste_to_build => 0;
-
-use constant happiness_consumption => 0;
-
-use constant energy_consumption => 0;
-
-use constant water_consumption => 0;
-
-use constant waste_consumption => 0;
-
-use constant food_consumption => 0;
-
-use constant ore_consumption => 0;
-
-use constant happiness_production => 0;
-
-use constant energy_production => 0;
-
-use constant water_production => 0;
-
-use constant waste_production => 0;
-
-use constant beetle_production => 0;
-
-use constant shake_production => 0;
-
-use constant burger_production => 0;
-
-use constant fungus_production => 0;
-
-use constant syrup_production => 0;
-
-use constant algae_production => 0;
-
-use constant meal_production => 0;
-
-use constant milk_production => 0;
-
-use constant pancake_production => 0;
-
-use constant pie_production => 0;
-
-use constant chip_production => 0;
-
-use constant soup_production => 0;
-
-use constant bread_production => 0;
-
-use constant wheat_production => 0;
-
-use constant cider_production => 0;
-
-use constant corn_production => 0;
-
-use constant root_production => 0;
-
-use constant bean_production => 0;
-
-use constant cheese_production => 0;
-
-use constant apple_production => 0;
-
-use constant lapis_production => 0;
-
-use constant potato_production => 0;
-
-use constant ore_production => 0;
-
-use constant water_storage => 0;
-
-use constant energy_storage => 0;
-
-use constant food_storage => 0;
-
-use constant ore_storage => 0;
-
-use constant waste_storage => 0;
+use constant time_to_build => 60;
+
+use constant build_with_halls => 0;
+
+use constant energy_to_build => 0;
+use constant food_to_build => 0;
+use constant ore_to_build => 0;
+use constant water_to_build => 0;
+use constant waste_to_build => 0;
+
+use constant happiness_consumption => 0;
+use constant energy_consumption => 0;
+use constant water_consumption => 0;
+use constant waste_consumption => 0;
+use constant food_consumption => 0;
+use constant ore_consumption => 0;
+
+use constant happiness_production => 0;
+use constant energy_production => 0;
+use constant water_production => 0;
+use constant waste_production => 0;
+use constant beetle_production => 0;
+use constant shake_production => 0;
+use constant burger_production => 0;
+use constant fungus_production => 0;
+use constant syrup_production => 0;
+use constant algae_production => 0;
+use constant meal_production => 0;
+use constant milk_production => 0;
+use constant pancake_production => 0;
+use constant pie_production => 0;
+use constant chip_production => 0;
+use constant soup_production => 0;
+use constant bread_production => 0;
+use constant wheat_production => 0;
+use constant cider_production => 0;
+use constant corn_production => 0;
+use constant root_production => 0;
+use constant bean_production => 0;
+use constant cheese_production => 0;
+use constant apple_production => 0;
+use constant lapis_production => 0;
+use constant potato_production => 0;
+use constant ore_production => 0;
+
+use constant water_storage => 0;
+use constant energy_storage => 0;
+use constant food_storage => 0;
+use constant ore_storage => 0;
+use constant waste_storage => 0;
# BASE FORMULAS
@@ -791,14 +754,22 @@ sub cost_to_upgrade {
$time_cost = 5184000 if ($time_cost > 5184000); # 60 Days
$time_cost = 15 if ($time_cost < 15);
- return {
- food => sprintf('%.0f',$self->food_to_build * $upgrade_cost * $upgrade_cost_reduction),
- energy => sprintf('%.0f',$self->energy_to_build * $upgrade_cost * $upgrade_cost_reduction),
- ore => sprintf('%.0f',$self->ore_to_build * $upgrade_cost * $upgrade_cost_reduction),
- water => sprintf('%.0f',$self->water_to_build * $upgrade_cost * $upgrade_cost_reduction),
- waste => sprintf('%.0f',$self->waste_to_build * $upgrade_cost * $upgrade_cost_reduction),
- time => sprintf('%.0f',$time_cost),
- };
+ if ($self->build_with_halls) {
+ return {
+ halls => $self->level + 1,
+ time => sprintf('%.0f',$time_cost),
+ };
+ }
+ else {
+ return {
+ food => sprintf('%.0f',$self->food_to_build * $upgrade_cost * $upgrade_cost_reduction),
+ energy => sprintf('%.0f',$self->energy_to_build * $upgrade_cost * $upgrade_cost_reduction),
+ ore => sprintf('%.0f',$self->ore_to_build * $upgrade_cost * $upgrade_cost_reduction),
+ water => sprintf('%.0f',$self->water_to_build * $upgrade_cost * $upgrade_cost_reduction),
+ waste => sprintf('%.0f',$self->waste_to_build * $upgrade_cost * $upgrade_cost_reduction),
+ time => sprintf('%.0f',$time_cost),
+ };
+ }
}
sub stats_after_upgrade {
@@ -857,6 +828,13 @@ sub start_upgrade {
sub finish_upgrade {
my ($self) = @_;
+ my ($schedule) = Lacuna->db->resultset('Schedule')->search({
+ parent_table => 'Building',
+ parent_id => $self->id,
+ task => 'finish_upgrade',
+ });
+ $schedule->delete if defined $schedule;
+
if ($self->is_upgrading) {
my $body = $self->body;
my $new_level = $self->level+1;
View
25 lib/Lacuna/DB/Result/Building/Permanent/AlgaePond.pm
@@ -8,21 +8,8 @@ use Lacuna::Util qw(randint);
use constant controller_class => 'Lacuna::RPC::Building::AlgaePond';
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build an Algae Pond. It forms naturally."];
-};
-
-around can_upgrade => sub {
- my ($orig, $self) = @_;
- if ($self->body->get_plan(__PACKAGE__, $self->level + 1)) {
- return $orig->($self);
- }
- confess [1013,"You can't upgrade an Algae Pond. It forms naturally."];
-};
+with "Lacuna::Role::Building::UpgradeWithHalls";
+with "Lacuna::Role::Building::FormsNaturally";
use constant image => 'algaepond';
@@ -36,10 +23,10 @@ after finish_upgrade => sub {
$self->body->add_news(30, sprintf('This is no fisherman\'s tale. A local fisherman caught a '.randint(1,9).' meter Rakl out of an algae pond on %s.', $self->body->name));
};
-use constant name => 'Algae Pond';
-use constant time_to_build => 0;
-use constant max_instances_per_planet => 1;
-use constant algae_production => 4000;
+use constant name => 'Algae Pond';
+use constant time_to_build => 0;
+use constant max_instances_per_planet => 1;
+use constant algae_production => 4000;
around produces_food_items => sub {
my ($orig, $class) = @_;
View
19 lib/Lacuna/DB/Result/Building/Permanent/AmalgusMeadow.pm
@@ -5,23 +5,10 @@ use utf8;
no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building::Permanent';
-use constant controller_class => 'Lacuna::RPC::Building::AmalgusMeadow';
-
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build an Amalgus Meadow. It forms naturally."];
-};
+with "Lacuna::Role::Building::UpgradeWithHalls";
+with "Lacuna::Role::Building::FormsNaturally";
-around can_upgrade => sub {
- my ($orig, $self) = @_;
- if ($self->body->get_plan(__PACKAGE__, $self->level + 1)) {
- return $orig->($self);
- }
- confess [1013,"You can't upgrade an Amalgus Meadow. It forms naturally."];
-};
+use constant controller_class => 'Lacuna::RPC::Building::AmalgusMeadow';
use constant image => 'amalgusmeadow';
View
8 lib/Lacuna/DB/Result/Building/Permanent/Beach1.pm
@@ -7,13 +7,7 @@ extends 'Lacuna::DB::Result::Building::Permanent';
use constant controller_class => 'Lacuna::RPC::Building::Beach1';
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build a beach. It forms naturally."];
-};
+with "Lacuna::Role::Building::FormsNaturally";
sub can_upgrade {
confess [1013, "You can't upgrade a beach. It forms naturally."];
View
9 lib/Lacuna/DB/Result/Building/Permanent/Beach10.pm
@@ -6,14 +6,7 @@ no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building::Permanent';
use constant controller_class => 'Lacuna::RPC::Building::Beach10';
-
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build a beach. It forms naturally."];
-};
+with "Lacuna::Role::Building::FormsNaturally";
sub can_upgrade {
confess [1013, "You can't upgrade a beach. It forms naturally."];
View
8 lib/Lacuna/DB/Result/Building/Permanent/Beach11.pm
@@ -7,13 +7,7 @@ extends 'Lacuna::DB::Result::Building::Permanent';
use constant controller_class => 'Lacuna::RPC::Building::Beach11';
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build a beach. It forms naturally."];
-};
+with "Lacuna::Role::Building::FormsNaturally";
sub can_upgrade {
confess [1013, "You can't upgrade a beach. It forms naturally."];
View
8 lib/Lacuna/DB/Result/Building/Permanent/Beach12.pm
@@ -7,13 +7,7 @@ extends 'Lacuna::DB::Result::Building::Permanent';
use constant controller_class => 'Lacuna::RPC::Building::Beach12';
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build a beach. It forms naturally."];
-};
+with "Lacuna::Role::Building::FormsNaturally";
sub can_upgrade {
confess [1013, "You can't upgrade a beach. It forms naturally."];
View
8 lib/Lacuna/DB/Result/Building/Permanent/Beach13.pm
@@ -7,13 +7,7 @@ extends 'Lacuna::DB::Result::Building::Permanent';
use constant controller_class => 'Lacuna::RPC::Building::Beach13';
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build a beach. It forms naturally."];
-};
+with "Lacuna::Role::Building::FormsNaturally";
sub can_upgrade {
confess [1013, "You can't upgrade a beach. It forms naturally."];
View
8 lib/Lacuna/DB/Result/Building/Permanent/Beach2.pm
@@ -7,13 +7,7 @@ extends 'Lacuna::DB::Result::Building::Permanent';
use constant controller_class => 'Lacuna::RPC::Building::Beach2';
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build a beach. It forms naturally."];
-};
+with "Lacuna::Role::Building::FormsNaturally";
sub can_upgrade {
confess [1013, "You can't upgrade a beach. It forms naturally."];
View
8 lib/Lacuna/DB/Result/Building/Permanent/Beach3.pm
@@ -7,13 +7,7 @@ extends 'Lacuna::DB::Result::Building::Permanent';
use constant controller_class => 'Lacuna::RPC::Building::Beach3';
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build a beach. It forms naturally."];
-};
+with "Lacuna::Role::Building::FormsNaturally";
sub can_upgrade {
confess [1013, "You can't upgrade a beach. It forms naturally."];
View
8 lib/Lacuna/DB/Result/Building/Permanent/Beach4.pm
@@ -7,13 +7,7 @@ extends 'Lacuna::DB::Result::Building::Permanent';
use constant controller_class => 'Lacuna::RPC::Building::Beach4';
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build a beach. It forms naturally."];
-};
+with "Lacuna::Role::Building::FormsNaturally";
sub can_upgrade {
confess [1013, "You can't upgrade a beach. It forms naturally."];
View
8 lib/Lacuna/DB/Result/Building/Permanent/Beach5.pm
@@ -7,13 +7,7 @@ extends 'Lacuna::DB::Result::Building::Permanent';
use constant controller_class => 'Lacuna::RPC::Building::Beach5';
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build a beach. It forms naturally."];
-};
+with "Lacuna::Role::Building::FormsNaturally";
sub can_upgrade {
confess [1013, "You can't upgrade a beach. It forms naturally."];
View
8 lib/Lacuna/DB/Result/Building/Permanent/Beach6.pm
@@ -7,13 +7,7 @@ extends 'Lacuna::DB::Result::Building::Permanent';
use constant controller_class => 'Lacuna::RPC::Building::Beach6';
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build a beach. It forms naturally."];
-};
+with "Lacuna::Role::Building::FormsNaturally";
sub can_upgrade {
confess [1013, "You can't upgrade a beach. It forms naturally."];
View
8 lib/Lacuna/DB/Result/Building/Permanent/Beach7.pm
@@ -7,13 +7,7 @@ extends 'Lacuna::DB::Result::Building::Permanent';
use constant controller_class => 'Lacuna::RPC::Building::Beach7';
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build a beach. It forms naturally."];
-};
+with "Lacuna::Role::Building::FormsNaturally";
sub can_upgrade {
confess [1013, "You can't upgrade a beach. It forms naturally."];
View
8 lib/Lacuna/DB/Result/Building/Permanent/Beach8.pm
@@ -7,13 +7,7 @@ extends 'Lacuna::DB::Result::Building::Permanent';
use constant controller_class => 'Lacuna::RPC::Building::Beach8';
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build a beach. It forms naturally."];
-};
+with "Lacuna::Role::Building::FormsNaturally";
sub can_upgrade {
confess [1013, "You can't upgrade a beach. It forms naturally."];
View
8 lib/Lacuna/DB/Result/Building/Permanent/Beach9.pm
@@ -7,13 +7,7 @@ extends 'Lacuna::DB::Result::Building::Permanent';
use constant controller_class => 'Lacuna::RPC::Building::Beach9';
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build a beach. It forms naturally."];
-};
+with "Lacuna::Role::Building::FormsNaturally";
sub can_upgrade {
confess [1013, "You can't upgrade a beach. It forms naturally."];
View
17 lib/Lacuna/DB/Result/Building/Permanent/BeeldebanNest.pm
@@ -7,21 +7,8 @@ extends 'Lacuna::DB::Result::Building::Permanent';
use constant controller_class => 'Lacuna::RPC::Building::BeeldebanNest';
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build a Beeldeban Nest. It forms naturally."];
-};
-
-around can_upgrade => sub {
- my ($orig, $self) = @_;
- if ($self->body->get_plan(__PACKAGE__, $self->level + 1)) {
- return $orig->($self);
- }
- confess [1013,"You can't upgrade a Beeldeban Nest. It forms naturally."];
-};
+with "Lacuna::Role::Building::UpgradeWithHalls";
+with "Lacuna::Role::Building::FormsNaturally";
use constant image => 'beeldebannest';
View
17 lib/Lacuna/DB/Result/Building/Permanent/BlackHoleGenerator.pm
@@ -7,21 +7,8 @@ extends 'Lacuna::DB::Result::Building::Permanent';
use constant controller_class => 'Lacuna::RPC::Building::BlackHoleGenerator';
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build a Black Hole Generator."];
-};
-
-around can_upgrade => sub {
- my ($orig, $self) = @_;
- if ($self->body->get_plan(__PACKAGE__, $self->level + 1)) {
- return $orig->($self);
- }
- confess [1013,"You can't upgrade a Black Hole Generator. It was left behind by the Great Race."];
-};
+with "Lacuna::Role::Building::UpgradeWithHalls";
+with "Lacuna::Role::Building::CantBuildWithoutPlan";
use constant image => 'blackholegenerator';
View
17 lib/Lacuna/DB/Result/Building/Permanent/CitadelOfKnope.pm
@@ -8,21 +8,8 @@ extends 'Lacuna::DB::Result::Building::Permanent';
use constant controller_class => 'Lacuna::RPC::Building::CitadelOfKnope';
use Lacuna::Util qw(randint);
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build the Citadel of Knope. It was left behind by the Great Race."];
-};
-
-around can_upgrade => sub {
- my ($orig, $self) = @_;
- if ($self->body->get_plan(__PACKAGE__, $self->level + 1)) {
- return $orig->($self);
- }
- confess [1013,"You can't upgrade the Citadel of Knope. It was left behind by the Great Race."];
-};
+with "Lacuna::Role::Building::UpgradeWithHalls";
+with "Lacuna::Role::Building::CantBuildWithoutPlan";
use constant image => 'citadelofknope';
View
18 lib/Lacuna/DB/Result/Building/Permanent/CrashedShipSite.pm
@@ -6,23 +6,9 @@ no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building::Permanent';
use constant controller_class => 'Lacuna::RPC::Building::CrashedShipSite';
-use Lacuna::Util qw(randint);
-
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build the Crashed Ship Site. It was left behind by the Great Race."];
-};
-around can_upgrade => sub {
- my ($orig, $self) = @_;
- if ($self->body->get_plan(__PACKAGE__, $self->level + 1)) {
- return $orig->($self);
- }
- confess [1013,"You can't upgrade the Crashed Ship Site. It was left behind by the Great Race."];
-};
+with "Lacuna::Role::Building::UpgradeWithHalls";
+with "Lacuna::Role::Building::CantBuildWithoutPlan";
use constant image => 'crashedshipsite';
View
8 lib/Lacuna/DB/Result/Building/Permanent/Crater.pm
@@ -7,13 +7,7 @@ extends 'Lacuna::DB::Result::Building::Permanent';
use constant controller_class => 'Lacuna::RPC::Building::Crater';
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build a crater. It forms naturally."];
-};
+with "Lacuna::Role::Building::CantBuildWithoutPlan";
sub can_upgrade {
confess [1013, "You can't upgrade a crater. It forms naturally."];
View
17 lib/Lacuna/DB/Result/Building/Permanent/DentonBrambles.pm
@@ -7,21 +7,8 @@ extends 'Lacuna::DB::Result::Building::Permanent';
use constant controller_class => 'Lacuna::RPC::Building::DentonBrambles';
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build Denton Brambles. They form naturally."];
-};
-
-around can_upgrade => sub {
- my ($orig, $self) = @_;
- if ($self->body->get_plan(__PACKAGE__, $self->level + 1)) {
- return $orig->($self);
- }
- confess [1013,"You can't upgrade Denton Brambles. They form naturally."];
-};
+with "Lacuna::Role::Building::UpgradeWithHalls";
+with "Lacuna::Role::Building::CantBuildWithoutPlan";
use constant image => 'dentonbrambles';
View
13 lib/Lacuna/DB/Result/Building/Permanent/EssentiaVein.pm
@@ -7,17 +7,8 @@ extends 'Lacuna::DB::Result::Building::Permanent';
use constant controller_class => 'Lacuna::RPC::Building::EssentiaVein';
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build an Essentia Vein. It forms naturally."];
-};
-
-sub can_upgrade {
- confess [1013, "You can't upgrade an Essentia Vein. It forms naturally."];
-}
+with "Lacuna::Role::Building::UpgradeWithHalls";
+with "Lacuna::Role::Building::CantBuildWithoutPlan";
sub can_downgrade {
confess [1013, "You can't downgrade an Essentia Vein."];
View
17 lib/Lacuna/DB/Result/Building/Permanent/Fissure.pm
@@ -7,21 +7,8 @@ extends 'Lacuna::DB::Result::Building::Permanent';
use constant controller_class => 'Lacuna::RPC::Building::Fissure';
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build a Fissure. It is created by a violent release of energy."];
-};
-
-around can_upgrade => sub {
- my ($orig, $self) = @_;
- if ($self->body->get_plan(__PACKAGE__, $self->level + 1)) {
- return $orig->($self);
- }
- confess [1013,"You can't upgrade a Fissure. It is expanded by a violent release of energy."];
-};
+with "Lacuna::Role::Building::UpgradeWithHalls";
+with "Lacuna::Role::Building::CantBuildWithoutPlan";
use constant image => 'fissure';
View
10 lib/Lacuna/DB/Result/Building/Permanent/GasGiantPlatform.pm
@@ -5,6 +5,8 @@ use utf8;
no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building::Permanent';
+with "Lacuna::Role::Building::CantBuildWithoutPlan";
+
around 'build_tags' => sub {
my ($orig, $class) = @_;
return ($orig->($class), qw(Infrastructure Construction));
@@ -14,14 +16,6 @@ use constant controller_class => 'Lacuna::RPC::Building::GasGiantPlatform';
use constant image => 'gas-giant-platform';
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't directly build a Gas Giant Platform. You need a gas giant platform ship."];
-};
-
before 'can_demolish' => sub {
my $self = shift;
View
19 lib/Lacuna/DB/Result/Building/Permanent/GeoThermalVent.pm
@@ -5,23 +5,10 @@ use utf8;
no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building::Permanent';
-use constant controller_class => 'Lacuna::RPC::Building::GeoThermalVent';
-
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build a Geo Thermal Vent. It forms naturally."];
-};
+with "Lacuna::Role::Building::UpgradeWithHalls";
+with "Lacuna::Role::Building::CantBuildWithoutPlan";
-around can_upgrade => sub {
- my ($orig, $self) = @_;
- if ($self->body->get_plan(__PACKAGE__, $self->level + 1)) {
- return $orig->($self);
- }
- confess [1013,"You can't upgrade a Geo Thermal Vent. It forms naturally."];
-};
+use constant controller_class => 'Lacuna::RPC::Building::GeoThermalVent';
use constant image => 'geothermalvent';
View
19 lib/Lacuna/DB/Result/Building/Permanent/GratchsGauntlet.pm
@@ -6,23 +6,10 @@ no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building::Permanent';
use Lacuna::Util qw(randint);
-use constant controller_class => 'Lacuna::RPC::Building::GratchsGauntlet';
-
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build Gratch's Gauntlet."];
-};
+with "Lacuna::Role::Building::UpgradeWithHalls";
+with "Lacuna::Role::Building::CantBuildWithoutPlan";
-around can_upgrade => sub {
- my ($orig, $self) = @_;
- if ($self->body->get_plan(__PACKAGE__, $self->level + 1)) {
- return $orig->($self);
- }
- confess [1013,"You can't upgrade a Gratch's Gauntlet. You need a plan."];
-};
+use constant controller_class => 'Lacuna::RPC::Building::GratchsGauntlet';
use constant image => 'gratchsgauntlet';
View
10 lib/Lacuna/DB/Result/Building/Permanent/GreatBallOfJunk.pm
@@ -5,15 +5,9 @@ use utf8;
no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building::Permanent';
-use constant controller_class => 'Lacuna::RPC::Building::GreatBallOfJunk';
+with "Lacuna::Role::Building::UpgradeWithHalls";
-around can_upgrade => sub {
- my ($orig, $self) = @_;
- if ($self->body->get_plan(__PACKAGE__, $self->level + 1)) {
- return $orig->($self);
- }
- confess [1013,"You can't upgrade a monument."];
-};
+use constant controller_class => 'Lacuna::RPC::Building::GreatBallOfJunk';
around 'build_tags' => sub {
my ($orig, $class) = @_;
View
10 lib/Lacuna/DB/Result/Building/Permanent/Grove.pm
@@ -5,15 +5,9 @@ use utf8;
no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building::Permanent';
-use constant controller_class => 'Lacuna::RPC::Building::Grove';
+with "Lacuna::Role::Building::CantBuildWithoutPlan";
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build a grove of trees. It forms naturally."];
-};
+use constant controller_class => 'Lacuna::RPC::Building::Grove';
use constant image => 'grove';
View
10 lib/Lacuna/DB/Result/Building/Permanent/HallsOfVrbansk.pm
@@ -7,15 +7,9 @@ use List::Util qw(min);
no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building::Permanent';
-use constant controller_class => 'Lacuna::RPC::Building::HallsOfVrbansk';
+with "Lacuna::Role::Building::CantBuildWithoutPlan";
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build the Halls of Vrbansk."];
-};
+use constant controller_class => 'Lacuna::RPC::Building::HallsOfVrbansk';
sub can_upgrade {
confess [1013, "You can't upgrade the Halls of Vrbansk."];
View
19 lib/Lacuna/DB/Result/Building/Permanent/InterDimensionalRift.pm
@@ -5,23 +5,10 @@ use utf8;
no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building::Permanent';
-use constant controller_class => 'Lacuna::RPC::Building::InterDimensionalRift';
-
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build an Interdimensional Rift. It was left behind by the Great Race."];
-};
+with "Lacuna::Role::Building::UpgradeWithHalls";
+with "Lacuna::Role::Building::CantBuildWithoutPlan";
-around can_upgrade => sub {
- my ($orig, $self) = @_;
- if ($self->body->get_plan(__PACKAGE__, $self->level + 1)) {
- return $orig->($self);
- }
- confess [1013,"You can't upgrade an Interdimensional Rift. It was left behind by the Great Race."];
-};
+use constant controller_class => 'Lacuna::RPC::Building::InterDimensionalRift';
use constant image => 'interdimensionalrift';
View
10 lib/Lacuna/DB/Result/Building/Permanent/JunkHengeSculpture.pm
@@ -5,15 +5,9 @@ use utf8;
no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building::Permanent';
-use constant controller_class => 'Lacuna::RPC::Building::JunkHengeSculpture';
+with "Lacuna::Role::Building::UpgradeWithHalls";
-around can_upgrade => sub {
- my ($orig, $self) = @_;
- if ($self->body->get_plan(__PACKAGE__, $self->level + 1)) {
- return $orig->($self);
- }
- confess [1013,"You can't upgrade a monument."];
-};
+use constant controller_class => 'Lacuna::RPC::Building::JunkHengeSculpture';
around 'build_tags' => sub {
my ($orig, $class) = @_;
View
19 lib/Lacuna/DB/Result/Building/Permanent/KalavianRuins.pm
@@ -5,25 +5,12 @@ use utf8;
no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building::Permanent';
+with "Lacuna::Role::Building::UpgradeWithHalls";
+with "Lacuna::Role::Building::CantBuildWithoutPlan";
+
use constant controller_class => 'Lacuna::RPC::Building::KalavianRuins';
use Lacuna::Util qw(randint);
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build the Kalavian Ruins. They were left behind by the Great Race."];
-};
-
-around can_upgrade => sub {
- my ($orig, $self) = @_;
- if ($self->body->get_plan(__PACKAGE__, $self->level + 1)) {
- return $orig->($self);
- }
- confess [1013,"You can't upgrade the Kalavian Ruins. It was left behind by the Great Race."];
-};
-
use constant image => 'kalavianruins';
sub image_level {
View
5 lib/Lacuna/DB/Result/Building/Permanent/KasternsKeep.pm
@@ -6,8 +6,13 @@ no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building::Permanent';
use Lacuna::Util qw(randint);
+#with "Lacuna::Role::Building::UpgradeWithHalls";
+#with "Lacuna::Role::Building::CantBuildWithoutPlan";
+
use constant controller_class => 'Lacuna::RPC::Building::KasternsKeep';
+# delete the around can_build and can_upgrade when we enable the Keep
+# TODO
around can_build => sub {
my ($orig, $self, $body) = @_;
confess [1013,"You can't build Kastern's Keep."];
View
10 lib/Lacuna/DB/Result/Building/Permanent/Lagoon.pm
@@ -5,15 +5,9 @@ use utf8;
no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building::Permanent';
-use constant controller_class => 'Lacuna::RPC::Building::Lagoon';
+with "Lacuna::Role::Building::CantBuildWithoutPlan";
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build a lagoon. It forms naturally."];
-};
+use constant controller_class => 'Lacuna::RPC::Building::Lagoon';
use constant image => 'lagoon';
View
10 lib/Lacuna/DB/Result/Building/Permanent/Lake.pm
@@ -5,15 +5,9 @@ use utf8;
no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building::Permanent';
-use constant controller_class => 'Lacuna::RPC::Building::Lake';
+with "Lacuna::Role::Building::CantBuildWithoutPlan";
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build a lake. It forms naturally."];
-};
+use constant controller_class => 'Lacuna::RPC::Building::Lake';
sub can_upgrade {
confess [1013, "You can't upgrade a lake. It forms naturally."];
View
19 lib/Lacuna/DB/Result/Building/Permanent/LapisForest.pm
@@ -5,23 +5,10 @@ use utf8;
no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building::Permanent';
-use constant controller_class => 'Lacuna::RPC::Building::LapisForest';
-
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build a Lapis Forest. It forms naturally."];
-};
+with "Lacuna::Role::Building::UpgradeWithHalls";
+with "Lacuna::Role::Building::CantBuildWithoutPlan";
-around can_upgrade => sub {
- my ($orig, $self) = @_;
- if ($self->body->get_plan(__PACKAGE__, $self->level + 1)) {
- return $orig->($self);
- }
- confess [1013,"You can't upgrade a Lapis Forest. It forms naturally."];
-};
+use constant controller_class => 'Lacuna::RPC::Building::LapisForest';
use constant image => 'lapisforest';
View
19 lib/Lacuna/DB/Result/Building/Permanent/LibraryOfJith.pm
@@ -5,23 +5,10 @@ use utf8;
no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building::Permanent';
-use constant controller_class => 'Lacuna::RPC::Building::LibraryOfJith';
-
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build the Library of Jith."];
-};
+with "Lacuna::Role::Building::UpgradeWithHalls";
+with "Lacuna::Role::Building::CantBuildWithoutPlan";
-around can_upgrade => sub {
- my ($orig, $self) = @_;
- if ($self->body->get_plan(__PACKAGE__, $self->level + 1)) {
- return $orig->($self);
- }
- confess [1013,"You can't upgrade the Library of Jith. It was left behind by the Great Race."];
-};
+use constant controller_class => 'Lacuna::RPC::Building::LibraryOfJith';
use constant image => 'libraryjith';
View
19 lib/Lacuna/DB/Result/Building/Permanent/MalcudField.pm
@@ -5,23 +5,10 @@ use utf8;
no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building::Permanent';
-use constant controller_class => 'Lacuna::RPC::Building::MalcudField';
-
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build a Malcud Field. It forms naturally."];
-};
+with "Lacuna::Role::Building::UpgradeWithHalls";
+with "Lacuna::Role::Building::CantBuildWithoutPlan";
-around can_upgrade => sub {
- my ($orig, $self) = @_;
- if ($self->body->get_plan(__PACKAGE__, $self->level + 1)) {
- return $orig->($self);
- }
- confess [1013,"You can't upgrade a Malcud Field. It forms naturally."];
-};
+use constant controller_class => 'Lacuna::RPC::Building::MalcudField';
use constant image => 'malcudfield';
View
5 lib/Lacuna/DB/Result/Building/Permanent/MassadsHenge.pm
@@ -6,8 +6,13 @@ no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building::Permanent';
use Lacuna::Util qw(randint);
+#with "Lacuna::Role::Building::UpgradeWithHalls";
+#with "Lacuna::Role::Building::CantBuildWithoutPlan";
+
use constant controller_class => 'Lacuna::RPC::Building::MassadsHenge';
+# When enabled, delete the following around can_build and can_upgrade
+# TODO
around can_build => sub {
my ($orig, $self, $body) = @_;
confess [1013,"You can't build Massad's Henge."];
View
10 lib/Lacuna/DB/Result/Building/Permanent/MetalJunkArches.pm
@@ -5,6 +5,8 @@ use utf8;
no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building::Permanent';
+with "Lacuna::Role::Building::UpgradeWithHalls";
+
use constant controller_class => 'Lacuna::RPC::Building::MetalJunkArches';
around 'build_tags' => sub {
@@ -12,14 +14,6 @@ around 'build_tags' => sub {
return ($orig->($class), qw(Waste Happiness));
};
-around can_upgrade => sub {
- my ($orig, $self) = @_;
- if ($self->body->get_plan(__PACKAGE__, $self->level + 1)) {
- return $orig->($self);
- }
- confess [1013,"You can't upgrade a monument."];
-};
-
use constant image => 'metaljunkarches';
sub image_level {
View
19 lib/Lacuna/DB/Result/Building/Permanent/NaturalSpring.pm
@@ -5,23 +5,10 @@ use utf8;
no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building::Permanent';
-use constant controller_class => 'Lacuna::RPC::Building::NaturalSpring';
-
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build a Natural Spring. It forms naturally."];
-};
+with "Lacuna::Role::Building::UpgradeWithHalls";
+with "Lacuna::Role::Building::CantBuildWithoutPlan";
-around can_upgrade => sub {
- my ($orig, $self) = @_;
- if ($self->body->get_plan(__PACKAGE__, $self->level + 1)) {
- return $orig->($self);
- }
- confess [1013,"You can't upgrade a Natural Spring. It forms naturally."];
-};
+use constant controller_class => 'Lacuna::RPC::Building::NaturalSpring';
use constant image => 'naturalspring';
View
19 lib/Lacuna/DB/Result/Building/Permanent/OracleOfAnid.pm
@@ -5,23 +5,10 @@ use utf8;
no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building::Permanent';
-use constant controller_class => 'Lacuna::RPC::Building::OracleOfAnid';
-
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build the Oracle of Anid."];
-};
+with "Lacuna::Role::Building::UpgradeWithHalls";
+with "Lacuna::Role::Building::CantBuildWithoutPlan";
-around can_upgrade => sub {
- my ($orig, $self) = @_;
- if ($self->body->get_plan(__PACKAGE__, $self->level + 1)) {
- return $orig->($self);
- }
- confess [1013,"You can't upgrade the Oracle of Anid. It was left behind by the Great Race."];
-};
+use constant controller_class => 'Lacuna::RPC::Building::OracleOfAnid';
use constant image => 'oracleanid';
View
20 lib/Lacuna/DB/Result/Building/Permanent/PantheonOfHagness.pm
@@ -5,24 +5,10 @@ use utf8;
no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building::Permanent';
-use constant controller_class => 'Lacuna::RPC::Building::PantheonOfHagness';
-use Lacuna::Util qw(randint);
-
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build the Pantheon Of Hagness. It was left behind by the Great Race."];
-};
+with "Lacuna::Role::Building::UpgradeWithHalls";
+with "Lacuna::Role::Building::CantBuildWithoutPlan";
-around can_upgrade => sub {
- my ($orig, $self) = @_;
- if ($self->body->get_plan(__PACKAGE__, $self->level + 1)) {
- return $orig->($self);
- }
- confess [1013,"You can't upgrade the Pantheon Of Hagness. It was left behind by the Great Race."];
-};
+use constant controller_class => 'Lacuna::RPC::Building::PantheonOfHagness';
use constant image => 'pantheonofhagness';
View
10 lib/Lacuna/DB/Result/Building/Permanent/PyramidJunkSculpture.pm
@@ -5,15 +5,9 @@ use utf8;
no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building::Permanent';
-use constant controller_class => 'Lacuna::RPC::Building::PyramidJunkSculpture';
+with "Lacuna::Role::Building::UpgradeWithHalls";
-around can_upgrade => sub {
- my ($orig, $self) = @_;
- if ($self->body->get_plan(__PACKAGE__, $self->level + 1)) {
- return $orig->($self);
- }
- confess [1013,"You can't upgrade a monument."];
-};
+use constant controller_class => 'Lacuna::RPC::Building::PyramidJunkSculpture';
around 'build_tags' => sub {
my ($orig, $class) = @_;
View
19 lib/Lacuna/DB/Result/Building/Permanent/Ravine.pm
@@ -5,23 +5,10 @@ use utf8;
no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building::Permanent';
-use constant controller_class => 'Lacuna::RPC::Building::Ravine';
-
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build a Ravine. It forms naturally."];
-};
+with "Lacuna::Role::Building::UpgradeWithHalls";
+with "Lacuna::Role::Building::CantBuildWithoutPlan";
-around can_upgrade => sub {
- my ($orig, $self) = @_;
- if ($self->body->get_plan(__PACKAGE__, $self->level + 1)) {
- return $orig->($self);
- }
- confess [1013,"You can't upgrade a Ravine. It forms naturally."];
-};
+use constant controller_class => 'Lacuna::RPC::Building::Ravine';
use constant image => 'ravine';
View
10 lib/Lacuna/DB/Result/Building/Permanent/RockyOutcrop.pm
@@ -5,15 +5,9 @@ use utf8;
no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building::Permanent';
-use constant controller_class => 'Lacuna::RPC::Building::RockyOutcrop';
+with "Lacuna::Role::Building::CantBuildWithoutPlan";
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build a rocky outcropping. It forms naturally."];
-};
+use constant controller_class => 'Lacuna::RPC::Building::RockyOutcrop';
sub can_upgrade {
confess [1013, "You can't upgrade a rocky outcropping. It forms naturally."];
View
10 lib/Lacuna/DB/Result/Building/Permanent/Sand.pm
@@ -5,15 +5,9 @@ use utf8;
no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building::Permanent';
-use constant controller_class => 'Lacuna::RPC::Building::Sand';
+with "Lacuna::Role::Building::CantBuildWithoutPlan";
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build sand. It forms naturally."];
-};
+use constant controller_class => 'Lacuna::RPC::Building::Sand';
use constant image => 'sand';
View
10 lib/Lacuna/DB/Result/Building/Permanent/SpaceJunkPark.pm
@@ -5,15 +5,9 @@ use utf8;
no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building::Permanent';
-use constant controller_class => 'Lacuna::RPC::Building::SpaceJunkPark';
+with "Lacuna::Role::Building::UpgradeWithHalls";
-around can_upgrade => sub {
- my ($orig, $self) = @_;
- if ($self->body->get_plan(__PACKAGE__, $self->level + 1)) {
- return $orig->($self);
- }
- confess [1013,"You can't upgrade a monument."];
-};
+use constant controller_class => 'Lacuna::RPC::Building::SpaceJunkPark';
around 'build_tags' => sub {
my ($orig, $class) = @_;
View
19 lib/Lacuna/DB/Result/Building/Permanent/TempleOfTheDrajilites.pm
@@ -5,23 +5,10 @@ use utf8;
no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building::Permanent';
-use constant controller_class => 'Lacuna::RPC::Building::TempleOfTheDrajilites';
-
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build the Temple of the Drajilites. It was left behind by the Great Race."];
-};
+with "Lacuna::Role::Building::UpgradeWithHalls";
+with "Lacuna::Role::Building::CantBuildWithoutPlan";
-around can_upgrade => sub {
- my ($orig, $self) = @_;
- if ($self->body->get_plan(__PACKAGE__, $self->level + 1)) {
- return $orig->($self);
- }
- confess [1013,"You can't upgrade the Temple of the Drajilites. It was left behind by the Great Race."];
-};
+use constant controller_class => 'Lacuna::RPC::Building::TempleOfTheDrajilites';
after finish_upgrade => sub {
my $self = shift;
View
10 lib/Lacuna/DB/Result/Building/Permanent/TerraformingPlatform.pm
@@ -5,6 +5,8 @@ use utf8;
no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building::Permanent';
+with "Lacuna::Role::Building::CantBuildWithoutPlan";
+
around 'build_tags' => sub {
my ($orig, $class) = @_;
return ($orig->($class), qw(Infrastructure Construction));
@@ -12,14 +14,6 @@ around 'build_tags' => sub {
use constant controller_class => 'Lacuna::RPC::Building::TerraformingPlatform';
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't directly build a Terraforming Platform. You need a terraforming platform ship."];
-};
-
before 'can_demolish' => sub {
my $self = shift;
my $body = $self->body;
View
20 lib/Lacuna/DB/Result/Building/Permanent/Volcano.pm
@@ -5,24 +5,10 @@ use utf8;
no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building::Permanent';
-use constant controller_class => 'Lacuna::RPC::Building::Volcano';
-
-around can_build => sub {
- my ($orig, $self, $body) = @_;
- if ($body->get_plan(__PACKAGE__, 1)) {
- return $orig->($self, $body);
- }
- confess [1013,"You can't build a Volcano. It forms naturally."];
-};
-
-around can_upgrade => sub {
- my ($orig, $self) = @_;
- if ($self->body->get_plan(__PACKAGE__, $self->level + 1)) {
- return $orig->($self);
- }
- confess [1013,"You can't upgrade a Volcano. It forms naturally."];
-};
+with "Lacuna::Role::Building::UpgradeWithHalls";
+with "Lacuna::Role::Building::CantBuildWithoutPlan";
+use constant controller_class => 'Lacuna::RPC::Building::Volcano';
use constant image => 'volcano';
View
12 lib/Lacuna/DB/Result/Building/SAW.pm
@@ -35,18 +35,6 @@ before finish_work => sub {
$self->repair($costs);
};
-# Since we now just spend efficiency and self repair, commented out
-# around spend_efficiency => sub {
-# my ($orig, $self, $amount) = @_;
-# if ($amount * 100 < $self->body->water_stored) {
-# $self->body->spend_water($amount * 100);
-# }
-# else {
-# $orig->($self, $amount);
-# }
-# return $self;
-# };
-
use constant max_instances_per_planet => 10;
use constant controller_class => 'Lacuna::RPC::Building::SAW';
Please sign in to comment.
Something went wrong with that request. Please try again.