Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Romoved the Halls of Vrbansk

  • Loading branch information...
commit f4e7ed34aeb46000c23c8223b88377016e5b6e6f 1 parent 389af25
@icydee icydee authored
View
54 docs/HallsOfVrbansk.pod
@@ -4,57 +4,5 @@ Halls Of Vrbansk is accessible via the URL C</hallsofvrbansk>.
The list of methods below represents changes and additions to the methods that all L<Buildings> share.
-
-=head2 get_upgradable_buildings ( session_id, building_id )
-
-Returns a list of buildings that can be upgraded by the Halls of Vrbansk.
-
- {
- "halls_available" : 231, # Includes total of plans and built Halls.
- "status" : { ... },
- "buildings" : [
- {
- "name" : "Oracle of Anid",
- "id" : "id-goes-here",
- "x" : -3,
- "y" : 2,
- "image" : "oracleanid1",
- "level" : 1,
- "url" : "/oracleofanid"
- },
- ...
- ]
- }
-
-=head3 session_id
-
-A session id.
-
-=head3 building_id
-
-The unique id of the Halls of Vrbansk.
-
-
-=head2 sacrifice_to_upgrade ( session_id, building_id, upgrade_building_id )
-
-Sacrifices a number of the Halls of Vrbansk to upgrade a building.
-
- {
- "status" : { ... }
- }
-
-B<NOTE:> In all likelyhood the Halls of Vrbansk that the player is looking at when they call this method will be destroyed. The building will return a status, but then you should close whatever screen you have open for it and refresh the planet surface. The C<needs_surface_refresh> flag will be set in the body status on the return. You should wait for the return to close the building though, in case of an exception.
-
-=head3 session_id
-
-A session id.
-
-=head3 building_id
-
-The unique id of the Halls of Vrbansk.
-
-=head3 upgrade_building_id
-
-The unique id of the building you wish to upgrade.
-
=cut
+
View
52 lib/Lacuna/DB/Result/Building/Permanent/HallsOfVrbansk.pm
@@ -11,54 +11,32 @@ with "Lacuna::Role::Building::CantBuildWithoutPlan";
use constant controller_class => 'Lacuna::RPC::Building::HallsOfVrbansk';
-sub can_upgrade {
- confess [1013, "You can't upgrade the Halls of Vrbansk."];
-}
-
-use constant image => 'hallsofvrbansk';
+around can_build => sub {
+ confess [1013,"You can't build the Halls of Vrbansk."];
+};
-sub image_level {
- my ($self) = @_;
- return $self->image.'1';
-}
+around can_upgrade => sub {
+ confess [1013,"You can't upgrade the Halls of Vrbansk."];
+};
-after finish_upgrade => sub {
- my $self = shift;
- $self->body->add_news(30, sprintf('The ancient wisdom of the Great Race is still alive on %s.', $self->body->name));
+around can_downgrade => sub {
+ confess [1013,"You can't downgrade the Halls of Vrbansk."];
};
-sub get_halls {
- my $self = shift;
- my @halls = grep {$_->is_upgrading == 0} $self->body->get_buildings_of_class('Lacuna::DB::Result::Building::Permanent::HallsOfVrbansk');
- return @halls;
-}
+around can_demolish => sub {
+ confess [1013,"You can't demolish the Halls of Vrbansk."];
+};
-sub get_upgradable_buildings {
- my ($self) = @_;
- my $body = $self->body;
- $body->update;
- # The max_level is represented by the number of halls already
- # built, plus the number of hall plans
- my $halls = $self->get_halls;
- my ($plan) = grep {$_->class eq 'Lacuna::DB::Result::Building::Permanent::HallsOfVrbansk'} @{$body->plan_cache};
- my $plans = defined $plan ? $plan->quantity : 0;
- my $max_level = $halls + $plans;
- $max_level = 30 if $max_level > 30;
+use constant image => 'hallsofvrbansk';
- my @buildings = grep {
- ($_->level < $max_level) and
- ($_->class =~ /Permanent/) and
- ($_->class ne 'Lacuna::DB::Result::Building::Permanent::TheDillonForge') and
- ($_->class ne 'Lacuna::DB::Result::Building::Permanent::HallsOfVrbansk') and
- ($_->is_upgrading == 0)
- } @{$self->body->building_cache};
- return \@buildings;
+sub image_level {
+ my ($self) = @_;
+ return $self->image.'1';
}
use constant name => 'Halls of Vrbansk';
use constant time_to_build => 0;
-
no Moose;
__PACKAGE__->meta->make_immutable(inline_constructor => 0);
View
108 lib/Lacuna/RPC/Building/HallsOfVrbansk.pm
@@ -15,113 +15,7 @@ sub model_class {
return 'Lacuna::DB::Result::Building::Permanent::HallsOfVrbansk';
}
-around 'view' => sub {
- my ($orig, $self, $session_id, $building_id) = @_;
- my $empire = $self->get_empire_by_session($session_id);
- my $building = $self->get_building($empire, $building_id, skip_offline => 1);
- my $out = $orig->($self, $empire, $building);
- my $body = $building->body;
-
- my @halls = $building->get_halls;
- my $halls_placed = scalar @halls;
- my $total = $halls_placed;
- my ($plans) = grep {$_->class eq 'Lacuna::DB::Result::Building::Permanent::HallsOfVrbansk'} @{$body->plan_cache};
- if ($plans) {
- $total += $plans->quantity;
- }
- $out->{halls_available} = $total;
- return $out;
-};
-
-sub get_upgradable_buildings {
- my ($self, $session_id, $building_id) = @_;
- my $empire = $self->get_empire_by_session($session_id);
- my $building = $self->get_building($empire, $building_id);
- my @buildings;
- my @upgradable = @{$building->get_upgradable_buildings};
- foreach my $building_chk (@upgradable) {
- next if ($building_chk->level > $empire->university_level);
- push @buildings, {
- id => $building_chk->id,
- name => $building_chk->name,
- x => $building_chk->x,
- y => $building_chk->y,
- level => $building_chk->level,
- image => $building_chk->image_level,
- url => $building_chk->controller_class->app_url,
- };
- }
- my $body = $building->body;
- my @halls = $building->get_halls;
- my $halls_placed = scalar @halls;
- my $total = $halls_placed;
- my ($plans) = grep {$_->class eq 'Lacuna::DB::Result::Building::Permanent::HallsOfVrbansk'} @{$body->plan_cache};
- if ($plans) {
- $total += $plans->quantity;
- }
- return {
- buildings => \@buildings,
- status => $self->format_status($empire, $building->body),
- halls_available => $total,
- };
-}
-
-sub sacrifice_to_upgrade {
- my ($self, $session_id, $building_id, $upgrade_id) = @_;
- my $empire = $self->get_empire_by_session($session_id);
- my $building = $self->get_building($empire, $building_id);
- my ($upgrade) = grep {$_->id == $upgrade_id} @{$building->body->building_cache};
- unless (defined $upgrade) {
- confess [1002, 'Could not find the building to upgrade.'];
- }
- my $is_upgradable = grep {$_->id == $upgrade->id} @{$building->get_upgradable_buildings};
- unless ($is_upgradable) {
- confess [1009, 'The Halls of Vrbansk do not have the knowledge necessary to upgrade the '.$upgrade->name];
- }
- my $needed = $upgrade->level + 1;
-
- my $body = $building->body;
- $body->has_room_in_build_queue;
- $upgrade->body($body);
- $upgrade->start_upgrade;
- # get the number of built halls
- my @halls = $building->get_halls;
- my $halls_placed = scalar @halls;
- my $total = $halls_placed;
- # and the number of plans
- my ($plans) = grep {$_->class eq 'Lacuna::DB::Result::Building::Permanent::HallsOfVrbansk'} @{$body->plan_cache};
- if ($plans) {
- $total += $plans->quantity;
- }
- if ($total < $needed) {
- confess [1009, 'The Halls of Vrbansk do not have the knowledge necessary to upgrade the '.$upgrade->name];
- }
- # Leave one hall standing if not needed for upgrade.
- if ($total > $needed) {
- @halls = sort { ($a->id != $building_id) <=> ($b->id != $building_id) } @halls;
- shift(@halls);
- }
- while ($needed) {
- my $hall = shift(@halls);
- if ($hall) {
- $hall->delete
- }
- else {
- last;
- }
- $needed--;
- }
- if ($plans) {
- my $to_delete = min($plans->quantity, $needed);
- $body->delete_many_plans($plans, $to_delete);
- $needed -= $to_delete;
- }
- $body->needs_surface_refresh(1);
- $body->update;
- return { status => $self->format_status($empire, $body) };
-}
-
-__PACKAGE__->register_rpc_method_names(qw(get_upgradable_buildings sacrifice_to_upgrade));
+__PACKAGE__->register_rpc_method_names();
no Moose;
__PACKAGE__->meta->make_immutable;
Please sign in to comment.
Something went wrong with that request. Please try again.