From 42d0a040fcf31aa28bea491ea224ec03d8962072 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Fri, 14 Jan 2011 18:32:13 -0600 Subject: [PATCH] Can no longer downgrade/demolish Terraforming Platforms or Gas Giant Settlement Platforms unless you have available plots. --- .../Building/Permanent/GasGiantPlatform.pm | 14 ++++++++++++++ .../Building/Permanent/TerraformingPlatform.pm | 16 ++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/lib/Lacuna/DB/Result/Building/Permanent/GasGiantPlatform.pm b/lib/Lacuna/DB/Result/Building/Permanent/GasGiantPlatform.pm index 7dbbbd0e..4f5ed0cf 100644 --- a/lib/Lacuna/DB/Result/Building/Permanent/GasGiantPlatform.pm +++ b/lib/Lacuna/DB/Result/Building/Permanent/GasGiantPlatform.pm @@ -22,6 +22,20 @@ around can_build => sub { 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; + if ($self->body->plots_available < $self->level) { + confess [1013, 'You need to demolish a building before you can demolish this Gas Giant Settlement Platform.']; + } +}; + +before 'can_downgrade' => sub { + my $self = shift; + if ($self->body->plots_available < 1) { + confess [1013, 'You need to demolish a building before you can downgrade this Gas Giant Settlement Platform.']; + } +}; + before has_special_resources => sub { my $self = shift; my $planet = $self->body; diff --git a/lib/Lacuna/DB/Result/Building/Permanent/TerraformingPlatform.pm b/lib/Lacuna/DB/Result/Building/Permanent/TerraformingPlatform.pm index 13d2fe21..6a0ed74e 100644 --- a/lib/Lacuna/DB/Result/Building/Permanent/TerraformingPlatform.pm +++ b/lib/Lacuna/DB/Result/Building/Permanent/TerraformingPlatform.pm @@ -20,6 +20,22 @@ around can_build => sub { 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; + if ($body->plots_available < $self->level && ($body->orbit > $body->empire->max_orbit || $body->orbit < $body->empire->min_orbit)) { + confess [1013, 'You need to demolish a building before you can demolish this Terraforming Platform.']; + } +}; + +before 'can_downgrade' => sub { + my $self = shift; + my $body = $self->body; + if ($body->plots_available < 1 && ($body->orbit > $body->empire->max_orbit || $body->orbit < $body->empire->min_orbit)) { + confess [1013, 'You need to demolish a building before you can downgrade this Terraforming Platform.']; + } +}; + before has_special_resources => sub { my $self = shift; my $planet = $self->body; -- 2.51.2