Permalink
Browse files

Added missing files

  • Loading branch information...
1 parent 99a43a2 commit aac160a9884658dc7a6faa53350fec6fca44103d @icydee icydee committed Mar 17, 2013
@@ -0,0 +1,14 @@
+package Lacuna::Role::Building::CantBuildWithoutPlan;
+
+use Moose::Role;
+
+around can_build => sub {
+ my ($orig, $self, $body) = @_;
+ if ($body->get_plan(__PACKAGE__, 1)) {
+ return $orig->($self, $body);
+ }
+ confess [1013,"You can't build ".$self->name.", unless you have a plan."];
+};
+
+1;
+
@@ -0,0 +1,14 @@
+package Lacuna::Role::Building::FormsNaturally;
+
+use Moose::Role;
+
+around can_build => sub {
+ my ($orig, $self, $body) = @_;
+ if ($body->get_plan(__PACKAGE__, 1)) {
+ return $orig->($self, $body);
+ }
+ confess [1013,"You can't build ".$self->name.". It forms naturally."];
+};
+
+1;
+
@@ -0,0 +1,34 @@
+package Lacuna::Role::Building::UpgradeWithHalls;
+
+use Moose::Role;
+
+use constant build_with_halls => 1;
+
+around can_upgrade => sub {
+ my $orig = shift;
+ my $self = shift;
+
+ my $body = $self->body;
+ if ($body->get_plan(__PACKAGE__, $self->level + 1)) {
+ return $orig->$self(@_);
+ }
+
+ # 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);
+};
+
+1;
+

0 comments on commit aac160a

Please sign in to comment.