From b03f56736942e1d625e4e2520e43c328e6f20469 Mon Sep 17 00:00:00 2001 From: Darin McBride Date: Tue, 19 May 2015 14:52:10 -0600 Subject: [PATCH] Planetary Notes in PCC --- lib/Lacuna/DB/Result/Map/Body.pm | 2 ++ lib/Lacuna/DB/Result/Spies.pm | 1 + lib/Lacuna/RPC/Body.pm | 31 ++++++++++++++++++- lib/Lacuna/Role/Ship/Arrive/Colonize.pm | 1 + .../Role/Ship/Arrive/ConvertToStation.pm | 1 + var/upgrades/3.0912.sql | 1 + var/www/public/changes.txt | 1 + 7 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 var/upgrades/3.0912.sql diff --git a/lib/Lacuna/DB/Result/Map/Body.pm b/lib/Lacuna/DB/Result/Map/Body.pm index ac4c7eb7..96f38011 100644 --- a/lib/Lacuna/DB/Result/Map/Body.pm +++ b/lib/Lacuna/DB/Result/Map/Body.pm @@ -130,6 +130,7 @@ __PACKAGE__->add_columns( unhappy => { data_type => 'tinyint', default_value => 0 }, propaganda_boost => { data_type => 'int', default_value => 0 }, neutral_entry => { data_type => 'datetime', is_nullable => 0, set_on_create => 1 }, + notes => { data_type => 'text', is_nullable => 1 }, ); after 'sqlt_deploy_hook' => sub { @@ -350,6 +351,7 @@ sub get_status { star_name => $self->star->name, zone => $self->zone, id => $self->id, + notes => $self->notes, ); if ($self->star->station_id) { my $station = $self->star->station; diff --git a/lib/Lacuna/DB/Result/Spies.pm b/lib/Lacuna/DB/Result/Spies.pm index 038dd32d..344c2485 100644 --- a/lib/Lacuna/DB/Result/Spies.pm +++ b/lib/Lacuna/DB/Result/Spies.pm @@ -2089,6 +2089,7 @@ sub steal_planet { $self->on_body->unhappy_date(DateTime->now); } $self->on_body->empire_id($self->empire_id); + $self->on_body->notes(undef); $self->on_body->add_happiness(int(abs($planet_happiness) / 10)); $self->on_body->needs_recalc(1); $self->on_body->update; diff --git a/lib/Lacuna/RPC/Body.pm b/lib/Lacuna/RPC/Body.pm index 5855cf24..6596678b 100644 --- a/lib/Lacuna/RPC/Body.pm +++ b/lib/Lacuna/RPC/Body.pm @@ -538,7 +538,36 @@ sub view_laws { } } -__PACKAGE__->register_rpc_method_names(qw(abandon rename get_buildings get_buildable get_status get_body_status repair_list rearrange_buildings view_laws)); +sub set_colony_notes +{ + my ($self, $session_id, $body_id, $opts) = @_; + my $empire = $self->get_empire_by_session($session_id); + my $body = Lacuna->db->resultset('Lacuna::DB::Result::Map::Body') + ->find($body_id); + my $notes = $opts->{notes}; + + #Lacuna::Verify->new(content=>\$notes, throws=>[1000,'Content may not have any of the following characters: @&<>;{}()',$notes]) + # ->no_restricted_chars; + + $body->notes($notes); + $body->update; + + return { + status => $self->format_status($empire, $body), + }; +} + +__PACKAGE__->register_rpc_method_names(qw( + abandon + rename + get_buildings + get_buildable + get_status + get_body_status + repair_list + rearrange_buildings + set_colony_notes + view_laws)); 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 37db31b1..a65b1277 100644 --- a/lib/Lacuna/Role/Ship/Arrive/Colonize.pm +++ b/lib/Lacuna/Role/Ship/Arrive/Colonize.pm @@ -48,6 +48,7 @@ after handle_arrival_procedures => sub { # let's claim this for our very own! else { $planet->lock; + $planet->notes(undef); $planet->found_colony($empire); $empire->send_predefined_message( tags => ['Colonization','Alert'], diff --git a/lib/Lacuna/Role/Ship/Arrive/ConvertToStation.pm b/lib/Lacuna/Role/Ship/Arrive/ConvertToStation.pm index c8c1adc0..1770a110 100644 --- a/lib/Lacuna/Role/Ship/Arrive/ConvertToStation.pm +++ b/lib/Lacuna/Role/Ship/Arrive/ConvertToStation.pm @@ -42,6 +42,7 @@ after handle_arrival_procedures => sub { # let's claim this for our very own! else { $planet->lock; + $planet->notes(undef); $planet->convert_to_station($empire); $empire->send_predefined_message( tags => ['Colonization','Alert'], diff --git a/var/upgrades/3.0912.sql b/var/upgrades/3.0912.sql new file mode 100644 index 00000000..a978e733 --- /dev/null +++ b/var/upgrades/3.0912.sql @@ -0,0 +1 @@ +alter table body add column notes text; diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index b70403c2..61d3895a 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -3,6 +3,7 @@ - Fix: embassy stash could be exploited. - Fix: trade ministry's supply chain tab now works after selecting ship tab. - Add: build_ships API to automatically spread out ship building across multiple yards. + - Add: per-colony notes in PCC 3.0911: - Add: Reduce opacity for less-well-controlled stars. -- 2.51.2