diff --git a/docs/Body.pod b/docs/Body.pod index 7032f009..c8f4afae 100644 --- a/docs/Body.pod +++ b/docs/Body.pod @@ -72,10 +72,15 @@ B You should probably B call this method directly, as it is a wast "x" : 143, "y" : -27, "name" : "The Death Star" - } - "alliance" : { # only shows up if type is "space station" + }, + # ----- if the body is a station the follwing information will be included + "alliance" : { "id" : "id-goes-here", "name" : "Imperial Empire" + }, + "influence" : { + "total" : 0, + "spent" : 0 } } } diff --git a/lib/Lacuna/DB/Result/Map/Body/Planet/Station.pm b/lib/Lacuna/DB/Result/Map/Body/Planet/Station.pm index 95edd990..006f0504 100644 --- a/lib/Lacuna/DB/Result/Map/Body/Planet/Station.pm +++ b/lib/Lacuna/DB/Result/Map/Body/Planet/Station.pm @@ -31,7 +31,11 @@ around get_status => sub { $out->{alliance} = { id => $self->alliance->id, name => $self->alliance->name, - } + }; + $out->{influence} = { + spent => $self->influence_spent, + total => $self->total_influence, + }; } return $out; }; @@ -60,7 +64,7 @@ has command => ( lazy => 1, default => sub { my $self = shift; - my $building = $self->get_building_of_class('Lacuna::DB::Result::Building::StationCommand'); + my $building = $self->get_building_of_class('Lacuna::DB::Result::Building::Module::StationCommand'); return undef unless defined $building; $building->body($self); return $building; @@ -100,11 +104,51 @@ sub in_jurisdiction { confess [1009, 'Target is not in the station\'s jurisdiction.']; } +has total_influence => ( + is => 'rw', + lazy => 1, + default => sub { + my $self = shift; + return $self->buildings + ->search({ class => { in => ['Lacuna::DB::Result::Building::Module::OperaHouse','Lacuna::DB::Result::Building::Module::CulinaryInstitute','Lacuna::DB::Result::Building::Module::ArtMuseum'] }}) + ->get_column('level') + ->sum; + }, +); + +has influence_spent => ( + is => 'rw', + lazy => 1, + default => sub { + my $self = shift; + return $self->stars->count; + }, +); + +sub influence_remaining { + my $self = shift; + return $self->total_influence - $self->influence_remaining; +} + +has range_of_influence => ( + is => 'rw', + lazy => 1, + default => sub { + my $self = shift; + return $self->buildings + ->search({ class => 'Lacuna::DB::Result::Building::Module::IBS'}) + ->get_column('level') + ->sum + * 1000; + }, +); + sub in_range_of_influence { my ($self, $target) = @_; confess [1009, 'Target is not in the station\'s range of influence.']; } + no Moose; __PACKAGE__->meta->make_immutable(inline_constructor => 0); diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 4dfff930..a2a155e1 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -3,7 +3,7 @@ - Rule: SAWs now cost less in upkeep. - Rule: Station modules cannot be upgraded past the station command level. - API: Added "station" element to the status of bodies and probed stars. - - API: Added "alliance" element to the status of bodies that are space stations. + - API: Added "alliance" and "influence" elements to the status of bodies that are space stations. - API: Added proposing enacting writs at Parliament level 4. - API: Added transfering ownership of stations at Parliament level 5. - API: Added proposing firing the station's BFG at Parliament level 30.