diff --git a/docs/Parliament.pod b/docs/Parliament.pod index a0efb8b2..c268c876 100644 --- a/docs/Parliament.pod +++ b/docs/Parliament.pod @@ -334,7 +334,7 @@ The id of an empire within the alliance that wants control over the station. =head2 propose_seize_star ( session_id, building_id, star_id ) -Take control of a star. Usable a parliament level 7. +Take control of a star. Usable at parliament level 7. { "status" : { ... }, @@ -370,7 +370,7 @@ The id of a star the station should control. =head2 propose_rename_star ( session_id, building_id, star_id, name ) -Rename a star. Usable a parliament level 8. +Rename a star. Usable at parliament level 8. { "status" : { ... }, @@ -410,7 +410,7 @@ The new name of the star. =head2 propose_broadcast_on_network19 ( session_id, building_id, message ) -Broadcast any message you like on Network 19. Usable a parliament level 9. +Broadcast any message you like on Network 19. Usable at parliament level 9. { "status" : { ... }, @@ -448,7 +448,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 12. +Rename any asteroid in the station's jurisdiction. Usable at parliament level 12. { "status" : { ... }, @@ -490,7 +490,7 @@ A 30 chararacter string without profanity or special characters. =head2 propose_rename_uninhabited ( session_id, building_id, planet_id, name ) -Rename any uninhabited planet in the station's jurisdiction. Usable a parliament level 17. +Rename any uninhabited planet in the station's jurisdiction. Usable at parliament level 17. { "status" : { ... }, @@ -532,7 +532,7 @@ 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. +If passed, only members of the alliance would be able to set up new mining platforms on asteroids in this station's jurisdiction. Usable at parliament level 13. { "status" : { ... }, @@ -565,7 +565,7 @@ The unique id of the parliament. =head2 propose_evict_mining_platform ( session_id, building_id, platform_id ) -Destroys a mining platform on an asteroid. Usable a parliament level 14. +Destroys a mining platform on an asteroid. Usable at parliament level 14. { "status" : { ... }, @@ -601,6 +601,39 @@ The unique id of a mining platform. See Cadd_columns( __PACKAGE__->typecast_map(type => { Jurisdiction => 'Lacuna::DB::Result::Laws::Jurisdiction', + MembersOnlyColonization => 'Lacuna::DB::Result::Laws::MembersOnlyColonization', MembersOnlyMiningRights => 'Lacuna::DB::Result::Laws::MembersOnlyMiningRights', Writ => 'Lacuna::DB::Result::Laws::Writ', }); diff --git a/lib/Lacuna/DB/Result/Laws/MembersOnlyColonization.pm b/lib/Lacuna/DB/Result/Laws/MembersOnlyColonization.pm new file mode 100644 index 00000000..4c8d5b6a --- /dev/null +++ b/lib/Lacuna/DB/Result/Laws/MembersOnlyColonization.pm @@ -0,0 +1,9 @@ +package Lacuna::DB::Result::Laws::MembersOnlyColonization; + +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.pm b/lib/Lacuna/DB/Result/Propositions.pm index 5eeb4a4d..0a736ed2 100644 --- a/lib/Lacuna/DB/Result/Propositions.pm +++ b/lib/Lacuna/DB/Result/Propositions.pm @@ -32,6 +32,7 @@ __PACKAGE__->typecast_map(type => { EvictMiningPlatform => 'Lacuna::DB::Result::Propositions::EvictMiningPlatform', FireBfg => 'Lacuna::DB::Result::Propositions::FireBfg', InstallModule => 'Lacuna::DB::Result::Propositions::InstallModule', + MembersOnlyColonization => 'Lacuna::DB::Result::Propositions::MembersOnlyColonization', MembersOnlyMiningRights => 'Lacuna::DB::Result::Propositions::MembersOnlyMiningRights', RenameAsteroid => 'Lacuna::DB::Result::Propositions::RenameAsteroid', RenameStar => 'Lacuna::DB::Result::Propositions::RenameStar', diff --git a/lib/Lacuna/DB/Result/Propositions/MembersOnlyColonization.pm b/lib/Lacuna/DB/Result/Propositions/MembersOnlyColonization.pm new file mode 100644 index 00000000..f4ff7334 --- /dev/null +++ b/lib/Lacuna/DB/Result/Propositions/MembersOnlyColonization.pm @@ -0,0 +1,19 @@ +package Lacuna::DB::Result::Propositions::MembersOnlyColonization; + +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 => 'MembersOnlyColonization', + 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 8dd248ce..986ae81c 100644 --- a/lib/Lacuna/RPC/Building/Parliament.pm +++ b/lib/Lacuna/RPC/Building/Parliament.pm @@ -507,6 +507,31 @@ sub propose_members_only_mining_rights { }; } +sub propose_members_only_colonization { + 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 >= 18) { + confess [1013, 'Parliament must be level 18 to propose members only colonization.',18]; + } + my $proposition = Lacuna->db->resultset('Lacuna::DB::Result::Propositions')->new({ + type => 'MembersOnlyColonization', + name => 'Members Only Colonization', + description => 'Only members of {Alliance '.$building->body->alliance_id.' '.$building->body->alliance->name.'} should be allowed to colonize planets 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), + }; +} + sub propose_evict_mining_platform { my ($self, $session_id, $building_id, $platform_id) = @_; my $empire = $self->get_empire_by_session($session_id); @@ -543,7 +568,7 @@ sub propose_evict_mining_platform { }; } -__PACKAGE__->register_rpc_method_names(qw(get_bodies_for_star_in_jurisdiction get_mining_platforms_for_asteroid_in_jurisdiction propose_evict_mining_platform propose_members_only_mining_rights propose_rename_asteroid propose_rename_uninhabited 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)); +__PACKAGE__->register_rpc_method_names(qw(get_bodies_for_star_in_jurisdiction get_mining_platforms_for_asteroid_in_jurisdiction propose_evict_mining_platform propose_members_only_mining_rights propose_members_only_colonization propose_rename_asteroid propose_rename_uninhabited 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/Colonize.pm b/lib/Lacuna/Role/Ship/Arrive/Colonize.pm index be135be5..ddbfdb2e 100644 --- a/lib/Lacuna/Role/Ship/Arrive/Colonize.pm +++ b/lib/Lacuna/Role/Ship/Arrive/Colonize.pm @@ -51,6 +51,11 @@ after can_send_to_target => sub { my $empire = $self->body->empire; confess [1009, 'Can only be sent to habitable planets.'] if ($target->isa('Lacuna::DB::Result::Map::Body::Planet::GasGiant') && $empire->university_level < 19); confess [ 1009, 'Your species cannot survive on that planet.' ] if ($empire->university_level < 18 && ($target->orbit > $empire->max_orbit || $target->orbit < $empire->min_orbit)); + if ($target->star->station_id) { + if ($target->star->station->laws->search({type => 'MembersOnlyColonization'})->count) { + confess [1010, 'Only '.$target->star->station->alliance->name.' members can colonize planets in the jurisdiction of the space station.']; + } + } return 1; }; diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 9beed8d4..0c219f00 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -1,5 +1,6 @@ 3.0500 - API: Added proposing renaming uninhabited planets at Parliament level 17. + - API: Added proposing members only colonization at Parliament level 18. - Fix: Police Station docs now show up under Modules instead of Buildings. - Fix: view_ships_orbiting will now return the ships that are orbiting your planet instead of just the count.