Skip to content
Browse files

halls_available passed back by API

  • Loading branch information...
1 parent 211ba31 commit 2a99f8511068caa5ee5dbe6e317b2a335b5fd59a @lemming552 lemming552 committed Mar 9, 2013
Showing with 32 additions and 3 deletions.
  1. +2 −1 docs/HallsOfVrbansk.pod
  2. +28 −2 lib/Lacuna/RPC/Building/HallsOfVrbansk.pm
  3. +2 −0 var/www/public/changes.txt
View
3 docs/HallsOfVrbansk.pod
@@ -10,6 +10,7 @@ The list of methods below represents changes and additions to the methods that a
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" : [
{
@@ -56,4 +57,4 @@ The unique id of the Halls of Vrbansk.
The unique id of the building you wish to upgrade.
-=cut
+=cut
View
30 lib/Lacuna/RPC/Building/HallsOfVrbansk.pm
@@ -15,6 +15,24 @@ 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);
@@ -33,9 +51,17 @@ sub get_upgradable_buildings {
url => $building->controller_class->app_url,
};
}
+ 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),
+ buildings => \@buildings,
+ status => $self->format_status($empire, $building->body),
+ halls_available => $total,
};
}
View
2 var/www/public/changes.txt
@@ -1,5 +1,7 @@
3.0883:
- Fix: Library timer was too excessive.
+ - Mod: Gradual increase in TM range from 465 to 900.
+ - Mod: Number of halls available passed pack by Halls API.
3.0882:
- Fix: Timers on int ministries get zeroed on flipped planets.

0 comments on commit 2a99f85

Please sign in to comment.
Something went wrong with that request. Please try again.