From c8a15920d3fb9baff737969e8ab0cf279b19adca Mon Sep 17 00:00:00 2001 From: Mark Lemming Date: Fri, 3 Apr 2015 14:02:41 -0600 Subject: [PATCH] Basics of new props added. --- docs/Parliament.pod | 67 ++++++++++++++++++- lib/Lacuna/DB/Result/Laws.pm | 2 + lib/Lacuna/DB/Result/Laws/BHGPassport.pm | 9 +++ .../DB/Result/Laws/MembersOnlyStations.pm | 9 +++ lib/Lacuna/DB/Result/Propositions.pm | 2 + .../DB/Result/Propositions/BHGPassport.pm | 19 ++++++ .../Propositions/MembersOnlyStations.pm | 19 ++++++ lib/Lacuna/RPC/Building/Parliament.pm | 65 +++++++++++++++++- var/www/public/changes.txt | 2 + 9 files changed, 191 insertions(+), 3 deletions(-) create mode 100644 lib/Lacuna/DB/Result/Laws/BHGPassport.pm create mode 100644 lib/Lacuna/DB/Result/Laws/MembersOnlyStations.pm create mode 100644 lib/Lacuna/DB/Result/Propositions/BHGPassport.pm create mode 100644 lib/Lacuna/DB/Result/Propositions/MembersOnlyStations.pm diff --git a/docs/Parliament.pod b/docs/Parliament.pod index b027dee5..30ab72a5 100644 --- a/docs/Parliament.pod +++ b/docs/Parliament.pod @@ -837,9 +837,40 @@ A session id. The unique id of the parliament. +=head2 propose_members_only_stations ( session_id, building_id ) + +If passed, only members of the alliance would be able to set up new stations in this station's jurisdiction. Usable at parliament level 18. + + { + "status" : { ... }, + "proposition" : { + "id" : "id-goes-here", + "name" : "Members Only Stations", + "description" : "Only members of The Federation of Planets should be allowed to setup new stations 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_neutralize_bhg ( session_id, building_id ) -If passed, Black Hole Generators will not be able to be used on or from systems in the jurisdiction of this station. +If passed, Black Hole Generators will not be able to be used on or from systems in the jurisdiction of this station by members outside the alliance. Usable at parliament level 23. { "status" : { ... }, @@ -906,4 +937,38 @@ A planet to fire at. See C for details. An explict reason why the BFG should be fired upon the target. Same rules as an L message body apply here. +=head2 allow_bhg_by_alliance ( session_id, building_id, alliance_id ) + +If passed, Black Hole Generators of members of another alliance are allowed to use their BHGs in this stations jurisdiction. Will also ignore Members Only Colonies & Stations. Usable at parliament level 28. + + { + "status" : { ... }, + "proposition" : { + "id" : "id-goes-here", + "name" : "BHG Passport", + "description" : "Black Hole Generators of alliance Star Fleet are allowed to be used 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. + +=head3 alliance_id + +The unique id of the alliance to be allowed to use their BHGs. + =cut diff --git a/lib/Lacuna/DB/Result/Laws.pm b/lib/Lacuna/DB/Result/Laws.pm index f9822f1e..e1a72154 100644 --- a/lib/Lacuna/DB/Result/Laws.pm +++ b/lib/Lacuna/DB/Result/Laws.pm @@ -21,7 +21,9 @@ __PACKAGE__->add_columns( __PACKAGE__->typecast_map(type => { BHGNeutralized => 'Lacuna::DB::Result::Laws::BHGNeutralized', + BHGPassport => 'Lacuna::DB::Result::Laws::BHGPassport', MembersOnlyColonization => 'Lacuna::DB::Result::Laws::MembersOnlyColonization', + MembersOnlyStations => 'Lacuna::DB::Result::Laws::MembersOnlyStations', MembersOnlyMiningRights => 'Lacuna::DB::Result::Laws::MembersOnlyMiningRights', MembersOnlyExcavation => 'Lacuna::DB::Result::Laws::MembersOnlyExcavation', Taxation => 'Lacuna::DB::Result::Laws::Taxation', diff --git a/lib/Lacuna/DB/Result/Laws/BHGPassport.pm b/lib/Lacuna/DB/Result/Laws/BHGPassport.pm new file mode 100644 index 00000000..62cda21f --- /dev/null +++ b/lib/Lacuna/DB/Result/Laws/BHGPassport.pm @@ -0,0 +1,9 @@ +package Lacuna::DB::Result::Laws::BHGPassport; + +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/Laws/MembersOnlyStations.pm b/lib/Lacuna/DB/Result/Laws/MembersOnlyStations.pm new file mode 100644 index 00000000..818b6104 --- /dev/null +++ b/lib/Lacuna/DB/Result/Laws/MembersOnlyStations.pm @@ -0,0 +1,9 @@ +package Lacuna::DB::Result::Laws::MembersOnlyStations; + +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 b1cfb91d..dd7e6970 100644 --- a/lib/Lacuna/DB/Result/Propositions.pm +++ b/lib/Lacuna/DB/Result/Propositions.pm @@ -26,6 +26,7 @@ __PACKAGE__->add_columns( __PACKAGE__->typecast_map(type => { AbandonStation => 'Lacuna::DB::Result::Propositions::AbandonStation', BHGNeutralized => 'Lacuna::DB::Result::Propositions::BHGNeutralized', + BHGPassport => 'Lacuna::DB::Result::Propositions::BHGPassport', BroadcastOnNetwork19 => 'Lacuna::DB::Result::Propositions::BroadcastOnNetwork19', DemolishModule => 'Lacuna::DB::Result::Propositions::DemolishModule', DowngradeModule => 'Lacuna::DB::Result::Propositions::DowngradeModule', @@ -39,6 +40,7 @@ __PACKAGE__->typecast_map(type => { InductMember => 'Lacuna::DB::Result::Propositions::InductMember', InstallModule => 'Lacuna::DB::Result::Propositions::InstallModule', MembersOnlyColonization => 'Lacuna::DB::Result::Propositions::MembersOnlyColonization', + MembersOnlyStations => 'Lacuna::DB::Result::Propositions::MembersOnlyStations', MembersOnlyExcavation => 'Lacuna::DB::Result::Propositions::MembersOnlyExcavation', MembersOnlyMiningRights => 'Lacuna::DB::Result::Propositions::MembersOnlyMiningRights', RenameAsteroid => 'Lacuna::DB::Result::Propositions::RenameAsteroid', diff --git a/lib/Lacuna/DB/Result/Propositions/BHGPassport.pm b/lib/Lacuna/DB/Result/Propositions/BHGPassport.pm new file mode 100644 index 00000000..b823ed3c --- /dev/null +++ b/lib/Lacuna/DB/Result/Propositions/BHGPassport.pm @@ -0,0 +1,19 @@ +package Lacuna::DB::Result::Propositions::BHGNeutralized; + +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 => 'BHGPassport', + station_id => $self->station_id, + })->insert; +}; + +no Moose; +__PACKAGE__->meta->make_immutable(inline_constructor => 0); diff --git a/lib/Lacuna/DB/Result/Propositions/MembersOnlyStations.pm b/lib/Lacuna/DB/Result/Propositions/MembersOnlyStations.pm new file mode 100644 index 00000000..02507bb2 --- /dev/null +++ b/lib/Lacuna/DB/Result/Propositions/MembersOnlyStations.pm @@ -0,0 +1,19 @@ +package Lacuna::DB::Result::Propositions::MembersOnlyStations; + +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 => 'MembersOnlyStations', + 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 6a30c48b..2ce139d5 100644 --- a/lib/Lacuna/RPC/Building/Parliament.pm +++ b/lib/Lacuna/RPC/Building/Parliament.pm @@ -548,6 +548,35 @@ sub propose_members_only_colonization { }; } + +sub propose_members_only_stations { + 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->effective_level >= 18) { + confess [1013, 'Parliament must be level 18 to propose members only stations.',18]; + } + unless ($building->effective_level > 0 and $building->effective_efficiency == 100) { + confess [1003, "You must have a functional Parliament!"]; + } + my $proposition = Lacuna->db->resultset('Lacuna::DB::Result::Propositions')->new({ + type => 'MembersOnlyStations', + name => 'Members Only Stations', + description => 'Only members of {Alliance '.$building->body->alliance_id.' '.$building->body->alliance->name.'} should be allowed to deploy new stations in the jurisdiction of {Starmap '.$building->body->x.' '.$building->body->y.' '.$building->body->name.'}.', + 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_neutralize_bhg { my ($self, $session_id, $building_id) = @_; my $empire = $self->get_empire_by_session($session_id); @@ -564,7 +593,39 @@ sub propose_neutralize_bhg { my $proposition = Lacuna->db->resultset('Lacuna::DB::Result::Propositions')->new({ type => 'BHGNeutralized', name => 'BHG Neutralized', - description => 'All Black Hole Generators will cease to operate within and on planets in the jurisdiction of {Starmap '.$building->body->x.' '.$building->body->y.' '.$building->body->name.'}.', + description => 'All non-alliance Black Hole Generators will cease to operate within and on planets in the jurisdiction of {Starmap '.$building->body->x.' '.$building->body->y.' '.$building->body->name.'}.', + 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 allow_bhg_by_alliance { + my ($self, $session_id, $building_id, $alliance_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->effective_level >= 28) { + confess [1013, 'Parliament must be level 28 to propose to neutralize black hole generators.',28]; + } + unless ($building->effective_level > 0 and $building->effective_efficiency == 100) { + confess [1003, "You must have a functional Parliament!"]; + } + my $alliance = Lacuna->db->resultset('Lacuna::DB::Result::Map::Alliance')->find($alliance_id); + unless (defined $alliance) { + confess [1002, 'Could not find alliance.']; + } + my $proposition = Lacuna->db->resultset('Lacuna::DB::Result::Propositions')->new({ + type => 'BHGPassport', + name => 'BHG Passport', + description => '{Alliance '.$alliance->id.' '.$alliance->name.' is allowed to use their BHG in the jurisdiction of {Starmap '.$building->body->x.' '.$building->body->y.' '.$building->body->name.'}.', proposed_by_id => $empire->id, }); $proposition->station($building->body); @@ -894,7 +955,7 @@ sub view_taxes_collected { -__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_transfer_station_ownership view_propositions view_laws cast_vote propose_fire_bfg propose_writ propose_elect_new_leader propose_induct_member propose_expel_member propose_taxation view_taxes_collected propose_foreign_aid propose_evict_excavator propose_members_only_excavation propose_neutralize_bhg)); +__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_transfer_station_ownership view_propositions view_laws cast_vote propose_fire_bfg propose_writ propose_elect_new_leader propose_induct_member propose_expel_member propose_taxation view_taxes_collected propose_foreign_aid propose_evict_excavator propose_members_only_excavation propose_members_only_stations allow_bhg_by_alliance propose_neutralize_bhg)); no Moose; __PACKAGE__->meta->make_immutable; diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 5faddb9b..6c6c2002 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -8,6 +8,8 @@ - Fix: Offline Essentia veins can be repaired again in UI. - Mod: Stations sort to bottom of UI list. - Fix: Allied fighters let allies past. + - Add: Members Only Station law added. + - Add: BHG Passport law added. 3.0909: - Add: Admin UI to set alliance logo. -- 2.51.2