diff --git a/lib/Lacuna/DB/Result/Building/Permanent/EssentiaVein.pm b/lib/Lacuna/DB/Result/Building/Permanent/EssentiaVein.pm index b133a605..c25fc5e1 100644 --- a/lib/Lacuna/DB/Result/Building/Permanent/EssentiaVein.pm +++ b/lib/Lacuna/DB/Result/Building/Permanent/EssentiaVein.pm @@ -8,6 +8,7 @@ extends 'Lacuna::DB::Result::Building::Permanent'; use constant controller_class => 'Lacuna::RPC::Building::EssentiaVein'; with "Lacuna::Role::Building::CantBuildWithoutPlan"; +with "Lacuna::Role::Building::UpgradeWithHalls"; sub can_downgrade { confess [1013, "You can't downgrade an Essentia Vein."]; @@ -22,30 +23,9 @@ around can_upgrade => sub { 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}; - if ($cost->{halls}) { - $self->body->delete_many_plans($plans, $cost->{halls}); - } -}; - use constant image => 'essentiavein'; sub image_level { diff --git a/lib/Lacuna/Role/Building/UpgradeWithHalls.pm b/lib/Lacuna/Role/Building/UpgradeWithHalls.pm index e41ecfb3..68cf1dd4 100644 --- a/lib/Lacuna/Role/Building/UpgradeWithHalls.pm +++ b/lib/Lacuna/Role/Building/UpgradeWithHalls.pm @@ -18,7 +18,10 @@ around can_upgrade => sub { 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."]; + confess [1013, + sprintf ("You can't upgrade this %s, you have %d Halls of Vrbansk plan%s but need %d.", + $self->name, $plans, $plans == 1 ? "" : "s", $self->level + 1), + ]; } return $self->$orig(@_); };