Permalink
Browse files

Prevent Permanent E-Veins from having an Upgrade button

  • Loading branch information...
1 parent d221b0f commit f7ad444e58d3a5384536753754ef0ad43f50f18c @icydee icydee committed Mar 23, 2013
Showing with 33 additions and 1 deletion.
  1. +32 −1 lib/Lacuna/DB/Result/Building/Permanent/EssentiaVein.pm
  2. +1 −0 var/www/public/changes.txt
View
33 lib/Lacuna/DB/Result/Building/Permanent/EssentiaVein.pm
@@ -7,13 +7,44 @@ extends 'Lacuna::DB::Result::Building::Permanent';
use constant controller_class => 'Lacuna::RPC::Building::EssentiaVein';
-with "Lacuna::Role::Building::UpgradeWithHalls";
with "Lacuna::Role::Building::CantBuildWithoutPlan";
sub can_downgrade {
confess [1013, "You can't downgrade an Essentia Vein."];
}
+around can_upgrade => sub {
+ my $orig = shift;
+ my $self = shift;
+
+ # Can't upgrade a permanent e-vein (i.e. one that is not working
+ if (not $self->is_working) {
+ confess [1013, "You can't upgrade a permanent Essentia Vein."];
+ }
+
+ my $body = $self->body;
+ if ($body->get_plan(ref $self, $self->level + 1)) {
+ return $self->$orig(@_);
+ }
+
+ # Do we have enough hall (plans) to upgrade?
+ my ($plan) = grep {$_->class eq 'Lacuna::DB::Result::Building::Permanent::HallsOfVrbansk'} @{$body->plan_cache};
+ my $plans = defined $plan ? $plan->quantity : 0;
+
+ if ($plans < $self->level + 1) {
+ confess [1013, "You can't upgrade ".$self->name.", you don't have enough Halls of Vrbansk plans."];
+ }
+ return $self->$orig(@_);
+};
+
+before start_upgrade => sub {
+ my ($self, $cost) = @_;
+
+ my ($plans) = grep {$_->class eq 'Lacuna::DB::Result::Building::Permanent::HallsOfVrbansk'} @{$self->body->plan_cache};
+ $self->body->delete_many_plans($plans, $self->level + 1);
+};
+
+
use constant image => 'essentiavein';
sub image_level {
View
1 var/www/public/changes.txt
@@ -5,6 +5,7 @@
- Mod: Glyph buildings can now be upgraded (with halls) via update button
- Mod: All Halls of Vrbansk building have been replaced with hall plans
- Mod: The Halls of Vrbansk can no longer be built from a plan.
+ - Mod: Disable upgrade button on Permanent E-Veins
3.0882:
- Fix: Timers on int ministries get zeroed on flipped planets.

0 comments on commit f7ad444

Please sign in to comment.