diff --git a/docs/Parliament.pod b/docs/Parliament.pod index f22b266a..3d6a72dc 100644 --- a/docs/Parliament.pod +++ b/docs/Parliament.pod @@ -392,7 +392,7 @@ A 140 character string that cannot contain special characters or profanity. =head2 propose_rename_asteroid ( session_id, building_id, asteroid_id, name ) -Rename any asteroid in the station's jurisdiction. Usable a parliament level 11. +Rename any asteroid in the station's jurisdiction. Usable a parliament level 12. { "status" : { ... }, @@ -432,6 +432,39 @@ A 30 chararacter string without profanity or special characters. +=head2 propose_members_only_mining_rights ( session_id, building_id ) + +If passed, only members of the alliance would be able to set up new mining platforms on asteroids in this station's jurisdiction. Usable a parliament level 13. + + { + "status" : { ... }, + "proposition" : { + "id" : "id-goes-here", + "name" : "Members Only Mining Rights", + "description" : "Only members of The Federation of Planets should be allowed to mine asteroids in the jurisdiction of this station.", + "votes_needed" : 7, + "votes_yes" : 0, + "votes_no" : 0, + "status" : "Pending", + "date_ends" : "01 31 2010 13:09:05 +0600", + "proposed_by" : { + "id" : "id-goes-here", + "name" : "Klingons", + } + } + } + +=head3 session_id + +A session id. + +=head3 building_id + +The unique id of the parliament. + + + + =head2 propose_fire_bfg ( session_id, building_id, target_x, target_y, reason ) diff --git a/lib/Lacuna/DB/Result/Laws/MembersOnlyMiningRights.pm b/lib/Lacuna/DB/Result/Laws/MembersOnlyMiningRights.pm new file mode 100644 index 00000000..7310646d --- /dev/null +++ b/lib/Lacuna/DB/Result/Laws/MembersOnlyMiningRights.pm @@ -0,0 +1,9 @@ +package Lacuna::DB::Result::Laws::MembersOnlyMiningRights; + +use Moose; +use utf8; +no warnings qw(uninitialized); +extends 'Lacuna::DB::Result::Laws'; + +no Moose; +__PACKAGE__->meta->make_immutable(inline_constructor => 0); diff --git a/lib/Lacuna/DB/Result/Propositions/MembersOnlyMiningRights.pm b/lib/Lacuna/DB/Result/Propositions/MembersOnlyMiningRights.pm new file mode 100644 index 00000000..ce103646 --- /dev/null +++ b/lib/Lacuna/DB/Result/Propositions/MembersOnlyMiningRights.pm @@ -0,0 +1,19 @@ +package Lacuna::DB::Result::Propositions::MembersOnlyMiningRights; + +use Moose; +use utf8; +no warnings qw(uninitialized); +extends 'Lacuna::DB::Result::Propositions'; + +before pass => sub { + my ($self) = @_; + my $law = Lacuna->db->resultset('Lacuna::DB::Result::Laws')->new({ + name => $self->name, + description => $self->description, + type => 'MembersOnlyMiningRights', + station_id => $self->station_id, + })->insert; +}; + +no Moose; +__PACKAGE__->meta->make_immutable(inline_constructor => 0); diff --git a/lib/Lacuna/RPC/Building/Parliament.pm b/lib/Lacuna/RPC/Building/Parliament.pm index 70a74e7d..a8a17ee0 100644 --- a/lib/Lacuna/RPC/Building/Parliament.pm +++ b/lib/Lacuna/RPC/Building/Parliament.pm @@ -382,7 +382,32 @@ sub propose_rename_asteroid { }; } -__PACKAGE__->register_rpc_method_names(qw(propose_rename_asteroid propose_broadcast_on_network19 get_stars_in_jurisdiction propose_rename_star propose_repeal_law propose_seize_star propose_transfer_station_ownership view_propositions view_laws cast_vote propose_fire_bfg propose_writ)); +sub propose_members_only_mining_rights { + my ($self, $session_id, $building_id) = @_; + my $empire = $self->get_empire_by_session($session_id); + if ($empire->current_session->is_sitter) { + confess [1015, 'Sitters cannot create propositions.']; + } + my $building = $self->get_building($empire, $building_id); + unless ($building->level >= 13) { + confess [1013, 'Parliament must be level 13 to propose members only mining rights.',13]; + } + my $proposition = Lacuna->db->resultset('Lacuna::DB::Result::Propositions')->new({ + type => 'MembersOnlyMiningRights', + name => 'Members Only Mining Rights', + description => 'Only members of '.$building->body->alliance->name.' should be allowed to mine asteroids in the jurisdiction of this station.', + proposed_by_id => $empire->id, + }); + $proposition->station($building->body); + $proposition->proposed_by($empire); + $proposition->insert; + return { + status => $self->format_status($empire, $building->body), + proposition => $proposition->get_status($empire), + }; +} + +__PACKAGE__->register_rpc_method_names(qw(propose_members_only_mining_rights propose_rename_asteroid propose_broadcast_on_network19 get_stars_in_jurisdiction propose_rename_star propose_repeal_law propose_seize_star propose_transfer_station_ownership view_propositions view_laws cast_vote propose_fire_bfg propose_writ)); no Moose; __PACKAGE__->meta->make_immutable; diff --git a/lib/Lacuna/Role/Ship/Arrive/DeployMiningPlatform.pm b/lib/Lacuna/Role/Ship/Arrive/DeployMiningPlatform.pm index 782b543c..c8a62c2c 100644 --- a/lib/Lacuna/Role/Ship/Arrive/DeployMiningPlatform.pm +++ b/lib/Lacuna/Role/Ship/Arrive/DeployMiningPlatform.pm @@ -51,6 +51,11 @@ after can_send_to_target => sub { my $ministry = $self->body->mining_ministry; confess [1013, 'Cannot control platforms without a Mining Ministry.'] unless (defined $ministry); $ministry->can_add_platform($target); + if ($target->star->station_id) { + if ($target->star->station->laws->search({type => 'MembersOnlyMiningRights'})->count) { + confess [1010, 'Only '.$target->star->station->alliance->name.' members can mine asteroids in the jurisdiction of the space station.']; + } + } }; 1; diff --git a/t/Parliament.t b/t/Parliament.t index 27e0bcf3..d81b0623 100644 --- a/t/Parliament.t +++ b/t/Parliament.t @@ -75,7 +75,10 @@ $result = $tester->post('parliament', 'propose_broadcast_on_network19', [$sessio is($result->{error}{data}, 9, 'broadcasting on network 19 requires level 9 parliament'); $result = $tester->post('parliament', 'propose_rename_asteroid', [$session_id, $par->id]); -is($result->{error}{data}, 11, 'renaming asteroid requires level 11 parliament'); +is($result->{error}{data}, 12, 'renaming asteroid requires level 12 parliament'); + +$result = $tester->post('parliament', 'propose_members_only_mining_rights', [$session_id, $par->id]); +is($result->{error}{data}, 13, 'members mining rights requires level 13 parliament'); $result = $tester->post('parliament', 'propose_fire_bfg', [$session_id, $par->id]); is($result->{error}{data}, 25, 'firing bfg requires level 25 parliament'); diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index fb2b0717..b561f528 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -11,7 +11,8 @@ - API: Added seizing control of stars at Parliament level 7. - API: Added renaming stars at Parliament level 8, along with a method to get the list of stars in the jurisdiction. - API: Added broadcasting on Network 19 at parliament level 9. - - API: Added renaming asteroids at parliament level 11. + - API: Added renaming asteroids at parliament level 12. + - API: Added members only mining rights at parliament level 13. - API: Added proposing firing the station's BFG at Parliament level 25. - API: Anyone can now view the laws passed by a space station, by simply calling view_laws() on the parliament. - API: The stations list is now populated in the /alliance.view_profile() method.