From 5a04bceedf6c6f4ed0b09e9e4f95317b18477683 Mon Sep 17 00:00:00 2001 From: Darin McBride Date: Sat, 17 Jan 2015 22:14:54 -0700 Subject: [PATCH] Add build_queue_{size,len} to body stats --- docs/Body.pod | 2 ++ lib/Lacuna/DB/Result/Map/Body/Planet.pm | 27 +++++++++++++++++++------ var/www/public/changes.txt | 1 + 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/docs/Body.pod b/docs/Body.pod index bb35ed2e..3cd5ac82 100644 --- a/docs/Body.pod +++ b/docs/Body.pod @@ -46,6 +46,8 @@ B You should probably B call this method directly, as it is a wast "needs_surface_refresh" : 1, # indicates that the client needs to call get_buildings() because something has changed "building_count" : 7, + "build_queue_size" : 15, # can build 15 at once + "build_queue_len" : 10, # have 10 building now "plots_available" :60, "happiness" : 3939, "happiness_hour" : 25, diff --git a/lib/Lacuna/DB/Result/Map/Body/Planet.pm b/lib/Lacuna/DB/Result/Map/Body/Planet.pm index 54cf08e5..7e6b17bb 100644 --- a/lib/Lacuna/DB/Result/Map/Body/Planet.pm +++ b/lib/Lacuna/DB/Result/Map/Body/Planet.pm @@ -512,6 +512,8 @@ around get_status => sub { $out->{empire}{alignment} = 'self'; $out->{plots_available} = $self->plots_available; $out->{building_count} = $self->building_count; + $out->{build_queue_size}= $self->build_queue_size; + $out->{build_queue_len} = $self->build_queue_length; $out->{population} = $self->population; $out->{water_capacity} = $self->water_capacity; $out->{water_stored} = $self->water_stored; @@ -830,14 +832,27 @@ sub can_build_building { return $self; } +has build_queue_size => ( + is => 'ro', + lazy => 1, + default => sub { + my $self = shift; + my $max = 1; + my $dev_min = $self->development; + $max += $dev_min->effective_level if $dev_min; + $max; + } + ); + +sub build_queue_length { + my $self = shift; + scalar @{$self->builds}; +} + sub has_room_in_build_queue { my ($self) = shift; - my $max = 1; - my $dev_ministry = $self->development; - if (defined $dev_ministry) { - $max += $dev_ministry->effective_level; - } - my $count = @{$self->builds}; + my $max = $self->build_queue_size; + my $count = $self->build_queue_length; if ($count >= $max) { confess [1009, "There's no room left in the build queue.", $max]; } diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 604b7d73..7deb7184 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -19,6 +19,7 @@ - Mod: Disable chat for sitters. - Add: pod_delay returned as part of PCC view - Mod: Minimum flight time: 5 Minutes, Maximum is 2 months. + - Add: Build queue stats (size, len) returned as part of body status. 3.0908: - Mod: trash_messages_where now defaults to not returning deleted message IDs. -- 2.51.2