From 5841ddb48131a34d011f024cf73e4c15da290fbf Mon Sep 17 00:00:00 2001 From: Ian Docherty Date: Sun, 25 Sep 2011 01:08:12 +0100 Subject: [PATCH] Fixed bugs, 0010 - Gratch's Gauntlet cannot be upgraded with plan, 0011 - Essentia Vein can be downgraded --- .../Result/Building/Permanent/EssentiaVein.pm | 4 +++ .../Building/Permanent/GratchsGauntlet.pm | 10 +++++-- .../0010_GratchGauntletCannotUpgradeViaPlan.t | 29 +++++++++++++++++++ t/bugs/0011_EssentiaVeinCanBeDowngraded.t | 24 +++++++++++++++ 4 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 t/bugs/0010_GratchGauntletCannotUpgradeViaPlan.t create mode 100644 t/bugs/0011_EssentiaVeinCanBeDowngraded.t diff --git a/lib/Lacuna/DB/Result/Building/Permanent/EssentiaVein.pm b/lib/Lacuna/DB/Result/Building/Permanent/EssentiaVein.pm index 627cfacb..88408931 100644 --- a/lib/Lacuna/DB/Result/Building/Permanent/EssentiaVein.pm +++ b/lib/Lacuna/DB/Result/Building/Permanent/EssentiaVein.pm @@ -19,6 +19,10 @@ sub can_upgrade { confess [1013, "You can't upgrade an Essentia Vein. It forms naturally."]; } +sub can_downgrade { + confess [1013, "You can't downgrade an Essentia Vein."]; +} + use constant image => 'essentiavein'; sub image_level { diff --git a/lib/Lacuna/DB/Result/Building/Permanent/GratchsGauntlet.pm b/lib/Lacuna/DB/Result/Building/Permanent/GratchsGauntlet.pm index 46c8b1df..0468e578 100644 --- a/lib/Lacuna/DB/Result/Building/Permanent/GratchsGauntlet.pm +++ b/lib/Lacuna/DB/Result/Building/Permanent/GratchsGauntlet.pm @@ -16,9 +16,13 @@ around can_build => sub { confess [1013,"You can't build Gratch's Gauntlet."]; }; -sub can_upgrade { - confess [1013, "You can't upgrade an Gratch's Gauntlet."]; -} +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 image => 'gratchsgauntlet'; diff --git a/t/bugs/0010_GratchGauntletCannotUpgradeViaPlan.t b/t/bugs/0010_GratchGauntletCannotUpgradeViaPlan.t new file mode 100644 index 00000000..7db7b07b --- /dev/null +++ b/t/bugs/0010_GratchGauntletCannotUpgradeViaPlan.t @@ -0,0 +1,29 @@ +use lib '..','../../lib'; +use Test::More tests => 2; +use Test::Deep; +use 5.010; + +use strict; +use warnings; + +use TestHelper; +TestHelper->clear_all_test_empires; + +# BUG Bleeders continue to upgrade above level 30 + +my $tester = TestHelper->new({ big_producer => 1 })->generate_test_empire->build_infrastructure; +my $tester_session_id = $tester->session->id; +my $empire = $tester->empire; +my $home = $empire->home_planet; + +my $gratchs_gauntlet = $tester->build_building('Lacuna::DB::Result::Building::Permanent::GratchsGauntlet', 2); + +$home->add_plan('Lacuna::DB::Result::Building::Permanent::GratchsGauntlet', 1); +$home->add_plan('Lacuna::DB::Result::Building::Permanent::GratchsGauntlet', 2); + +$home->add_plan('Lacuna::DB::Result::Building::Permanent::GratchsGauntlet', 3); +$home->add_plan('Lacuna::DB::Result::Building::Permanent::GratchsGauntlet', 4); + +END { +# TestHelper->clear_all_test_empires; +} diff --git a/t/bugs/0011_EssentiaVeinCanBeDowngraded.t b/t/bugs/0011_EssentiaVeinCanBeDowngraded.t new file mode 100644 index 00000000..0b649773 --- /dev/null +++ b/t/bugs/0011_EssentiaVeinCanBeDowngraded.t @@ -0,0 +1,24 @@ +use lib '..','../../lib'; +use Test::More tests => 2; +use Test::Deep; +use 5.010; + +use strict; +use warnings; + +use TestHelper; +TestHelper->clear_all_test_empires; + +# BUG Essentia vein can be downgraded + +my $tester = TestHelper->new({ big_producer => 1 })->generate_test_empire->build_infrastructure; +my $tester_session_id = $tester->session->id; +my $empire = $tester->empire; +my $home = $empire->home_planet; + +my $essentia_vein = $tester->build_building('Lacuna::DB::Result::Building::Permanent::EssentiaVein', 2); + + +END { +# TestHelper->clear_all_test_empires; +} -- 2.51.2