Skip to content

Commit

Permalink
Make laws visible to all.
Browse files Browse the repository at this point in the history
  • Loading branch information
lemming552 committed Dec 8, 2014
1 parent d0cc05c commit 9150b51
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 29 deletions.
25 changes: 25 additions & 0 deletions docs/Body.pod
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,32 @@ A session id.

The unique id of the body you wish to abandon. You cannot abandon your home planet.

=head2 view_laws (session_id, body_id )

B<NOTE:> Pass in a the id of the station, not the id of the parliament building. This is because anyone that wants to should be able to view the laws in this jurisdiction.

Returns a list of the laws.

{
"status" : { ... },
"laws" : [
{
"id" : "id-goes-here",
"name" : "Censure of Jamie Vrbsky",
"description" : "Jamie Vrbsky is bad at playing Lacuna!",
"date_enacted" : "01 31 2010 13:09:05 +0600"
},
...
]
}

=head3 session_id

A session id.

=head3 body_id

The unique id of the space station.

=cut

19 changes: 1 addition & 18 deletions docs/Parliament.pod
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,7 @@ The list of methods below represents changes and additions to the methods that a

=head2 view_laws (session_id, body_id )

B<NOTE:> Pass in a the id of the station, not the id of the parliament building. This is because anyone that wants to should be able to view the laws in this jurisdiction.

Returns a list of the laws.

{
"status" : { ... },
"laws" : [
{
"id" : "id-goes-here",
"name" : "Censure of Jamie Vrbsky",
"description" : "Jamie Vrbsky is bad at playing Lacuna!",
"date_enacted" : "01 31 2010 13:09:05 +0600"
},
...
]
}
While still usable, replaced by a body call instead of via the station. See Body for details.

=head3 session_id

Expand All @@ -34,8 +19,6 @@ The unique id of the space station.





=head2 view_propositions (session_id, building_id )

Returns a list of the pending propositions.
Expand Down
26 changes: 24 additions & 2 deletions lib/Lacuna/RPC/Body.pm
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,31 @@ sub get_buildable {

return {buildable=>\%out, build_queue => { max => $max_items_in_build_queue, current => $items_in_build_queue}, status=>$self->format_status($empire, $body)};
}
sub view_laws {
my ($self, $session_id, $body_id) = @_;
my $empire = $self->get_empire_by_session($session_id);
my $body = Lacuna->db->resultset('Lacuna::DB::Result::Map::Body')
->find($body_id);
if ($body->isa('Lacuna::DB::Result::Map::Body::Planet::Station')) {
my @out;
my $laws = $body->laws;
while (my $law = $laws->next) {
push @out, $law->get_status($empire);
}
return {
status => $self->format_status($empire, $body),
laws => \@out,
};
}
else {
return {
status => $self->format_status($empire, $body),
laws => [ { name => "Not a Station", descripition => "Not a Station", date_enacted => "00 00 0000 00:00:00 +0000", id => 0 } ],
},
}
}


__PACKAGE__->register_rpc_method_names(qw(abandon rename get_buildings get_buildable get_status get_body_status repair_list rearrange_buildings));
__PACKAGE__->register_rpc_method_names(qw(abandon rename get_buildings get_buildable get_status get_body_status repair_list rearrange_buildings view_laws));

no Moose;
__PACKAGE__->meta->make_immutable;
Expand Down
27 changes: 18 additions & 9 deletions lib/Lacuna/RPC/Building/Parliament.pm
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,25 @@ sub get_mining_platforms_for_asteroid_in_jurisdiction {
sub view_laws {
my ($self, $session_id, $body_id) = @_;
my $empire = $self->get_empire_by_session($session_id);
my $body = $self->get_body($empire, $body_id);
my @out;
my $laws = $body->laws;
while (my $law = $laws->next) {
push @out, $law->get_status($empire);
my $body = Lacuna->db->resultset('Lacuna::DB::Result::Map::Body')
->find($body_id);
if ($body->isa('Lacuna::DB::Result::Map::Body::Planet::Station')) {
my @out;
my $laws = $body->laws;
while (my $law = $laws->next) {
push @out, $law->get_status($empire);
}
return {
status => $self->format_status($empire, $body),
laws => \@out,
};
}
else {
return {
status => "Not a station",
laws => [],
},
}
return {
status => $self->format_status($empire, $body),
laws => \@out,
};
}

sub cast_vote {
Expand Down
2 changes: 2 additions & 0 deletions var/www/public/changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
- Mod: trash_messages_where now defaults to not returning deleted message IDs.
- Mod: Firing BFG now requires captcha.
- Fix: Jump Zone for BHG can now find needles in haystacks.
- UI : Reasons for not being able to use a BHG function now always displayed for every task.
- Fix: Instead of going via parliament, go via body to view_laws. This allows everyone access to passed laws by a station.

3.0907:
- Add: Timer added to colony object preventing passage into Neutral Zone.
Expand Down

0 comments on commit 9150b51

Please sign in to comment.