From 44f85e5ab7b1b349f681429e13a289de3664f2e1 Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Thu, 14 Apr 2011 19:54:13 -0500 Subject: [PATCH 1/3] API: Added profile settings to disable excavator, probe detected, and spy recovery messages. --- bin/tick_spies.pl | 12 ++--- lib/Lacuna/DB/Result/Empire.pm | 20 ++++++--- lib/Lacuna/RPC/Empire.pm | 45 +++++++++++++++++++ lib/Lacuna/Role/Ship/Arrive/Excavate.pm | 58 ++++++++++++++----------- var/upgrades/3.0600.sql | 7 +++ var/www/public/changes.txt | 1 + 6 files changed, 107 insertions(+), 36 deletions(-) diff --git a/bin/tick_spies.pl b/bin/tick_spies.pl index 5e460884..5a43900e 100644 --- a/bin/tick_spies.pl +++ b/bin/tick_spies.pl @@ -27,11 +27,13 @@ foreach my $id (@ids) { my $starting_task = $spy->task; $spy->is_available; if ($spy->task eq 'Idle' && $starting_task ne 'Idle') { - $spy->empire->send_predefined_message( - tags => ['Intelligence'], - filename => 'ready_for_assignment.txt', - params => [$spy->name, $spy->from_body->id, $spy->from_body->name], - ); + if (!$spy->empire->skip_spy_recovery) { + $spy->empire->send_predefined_message( + tags => ['Intelligence'], + filename => 'ready_for_assignment.txt', + params => [$spy->name, $spy->from_body->id, $spy->from_body->name], + ); + } } } diff --git a/lib/Lacuna/DB/Result/Empire.pm b/lib/Lacuna/DB/Result/Empire.pm index 2b61a3e0..46ce11d2 100644 --- a/lib/Lacuna/DB/Result/Empire.pm +++ b/lib/Lacuna/DB/Result/Empire.pm @@ -70,6 +70,12 @@ __PACKAGE__->add_columns( skip_facebook_wall_posts => { data_type => 'tinyint', default_value => 0 }, is_admin => { data_type => 'tinyint', default_value => 0 }, is_mission_curator => { data_type => 'tinyint', default_value => 0 }, + skip_found_nothing => { data_type => 'tinyint', default_value => 0 }, + skip_excavator_resources => { data_type => 'tinyint', default_value => 0 }, + skip_excavator_glyph => { data_type => 'tinyint', default_value => 0 }, + skip_excavator_plan => { data_type => 'tinyint', default_value => 0 }, + skip_spy_recovery => { data_type => 'tinyint', default_value => 0 }, + skip_probe_detected => { data_type => 'tinyint', default_value => 0 }, ); sub sqlt_deploy_hook { @@ -643,12 +649,14 @@ sub add_probe { while (my $probe = $probes->next) { my $that_empire = $probe->empire; next unless defined $that_empire; - $that_empire->send_predefined_message( - filename => 'probe_detected.txt', - tags => ['Probe','Alert'], - from => $that_empire, - params => [$star->x, $star->y, $star->name, $self->id, $self->name], - ); + if (!$that_empire->skip_probe_detected) { + $that_empire->send_predefined_message( + filename => 'probe_detected.txt', + tags => ['Probe','Alert'], + from => $that_empire, + params => [$star->x, $star->y, $star->name, $self->id, $self->name], + ); + } } $self->clear_probed_stars; diff --git a/lib/Lacuna/RPC/Empire.pm b/lib/Lacuna/RPC/Empire.pm index 4475c00d..bc2f0800 100644 --- a/lib/Lacuna/RPC/Empire.pm +++ b/lib/Lacuna/RPC/Empire.pm @@ -399,7 +399,14 @@ sub view_profile { skip_happiness_warnings => $empire->skip_happiness_warnings, skip_facebook_wall_posts=> $empire->skip_facebook_wall_posts, medals => \%my_medals, + skip_found_nothing => $empire->skip_found_nothing, + skip_excavator_resources => $empire->skip_excavator_resources, + skip_excavator_glyph => $empire->skip_excavator_glyph, + skip_excavator_plan => $empire->skip_excavator_plan, + skip_spy_recovery => $empire->skip_spy_recovery, + skip_probe_detected => $empire->skip_probe_detected, ); + return { profile => \%out, status => $self->format_status($empire) }; } @@ -493,6 +500,44 @@ sub edit_profile { } $empire->skip_pollution_warnings($profile->{skip_pollution_warnings}); } + + if (exists $profile->{skip_found_nothing}) { + if ($profile->{skip_found_nothing} < 0 || $profile->{skip_found_nothing} > 1) { + confess [1009, 'Skip Found Nothing must be a 1 or a 0.', 'skip_found_nothing'] + } + $empire->skip_found_nothing($profile->{skip_found_nothing}); + } + if (exists $profile->{skip_excavator_resources}) { + if ($profile->{skip_excavator_resources} < 0 || $profile->{skip_excavator_resources} > 1) { + confess [1009, 'Skip Excavator Resources must be a 1 or a 0.', 'skip_excavator_resources'] + } + $empire->skip_excavator_resources($profile->{skip_excavator_resources}); + } + if (exists $profile->{skip_excavator_glyph}) { + if ($profile->{skip_excavator_glyph} < 0 || $profile->{skip_excavator_glyph} > 1) { + confess [1009, 'Skip Excavator Glyph must be a 1 or a 0.', 'skip_excavator_glyph'] + } + $empire->skip_excavator_glyph($profile->{skip_excavator_glyph}); + } + if (exists $profile->{skip_excavator_plan}) { + if ($profile->{skip_excavator_plan} < 0 || $profile->{skip_excavator_plan} > 1) { + confess [1009, 'Skip Excavator Plan must be a 1 or a 0.', 'skip_excavator_plan'] + } + $empire->skip_excavator_plan($profile->{skip_excavator_plan}); + } + if (exists $profile->{skip_spy_recovery}) { + if ($profile->{skip_spy_recovery} < 0 || $profile->{skip_spy_recovery} > 1) { + confess [1009, 'Skip Spy Recovery must be a 1 or a 0.', 'skip_spy_recovery'] + } + $empire->skip_spy_recovery($profile->{skip_spy_recovery}); + } + if (exists $profile->{skip_probe_detected}) { + if ($profile->{skip_probe_detected} < 0 || $profile->{skip_probe_detected} > 1) { + confess [1009, 'Skip Probe Detected must be a 1 or a 0.', 'skip_probe_detected'] + } + $empire->skip_probe_detected($profile->{skip_probe_detected}); + } + if (exists $profile->{skype}) { Lacuna::Verify->new(content=>\$profile->{skype}, throws=>[1005,'Skype must be no longer than 100 characters, and cannot contain special characters or profanity.', 'skype']) ->length_lt(101) diff --git a/lib/Lacuna/Role/Ship/Arrive/Excavate.pm b/lib/Lacuna/Role/Ship/Arrive/Excavate.pm index 552411e3..67c0c785 100644 --- a/lib/Lacuna/Role/Ship/Arrive/Excavate.pm +++ b/lib/Lacuna/Role/Ship/Arrive/Excavate.pm @@ -52,28 +52,32 @@ after handle_arrival_procedures => sub { Lacuna::DB::Result::Building::Permanent::Volcano )]); my $plan = $body->add_plan($class, 1, ($find == 1) ? randint(1,4) : 0); - $empire->send_predefined_message( - tags => ['Excavator','Alert'], - filename => 'plan_discovered_by_excavator.txt', - params => [$remote_body->x, $remote_body->y, $remote_body->name, ($plan->level + $plan->extra_build_level), $class->name, $body->id, $body->name], - ); + if (!$empire->skip_excavator_plan) { + $empire->send_predefined_message( + tags => ['Excavator','Alert'], + filename => 'plan_discovered_by_excavator.txt', + params => [$remote_body->x, $remote_body->y, $remote_body->name, ($plan->level + $plan->extra_build_level), $class->name, $body->id, $body->name], + ); + } } # found a glyph elsif ($find < 16) { my $ore = random_element([ORE_TYPES]); $body->add_glyph($ore); - $empire->send_predefined_message( - tags => ['Excavator','Alert'], - filename => 'glyph_discovered_by_excavator.txt', - params => [$remote_body->x, $remote_body->y, $remote_body->name, $ore, $body->id, $body->name], - attachments => { - image => { - title => $ore, - url => 'https://d16cbq0l6kkf21.cloudfront.net/assets/glyphs/'.$ore.'.png', + if (!$empire->skip_excavator_glyph) { + $empire->send_predefined_message( + tags => ['Excavator','Alert'], + filename => 'glyph_discovered_by_excavator.txt', + params => [$remote_body->x, $remote_body->y, $remote_body->name, $ore, $body->id, $body->name], + attachments => { + image => { + title => $ore, + url => 'https://d16cbq0l6kkf21.cloudfront.net/assets/glyphs/'.$ore.'.png', + } } - } - ); + ); + } $empire->add_medal($ore.'_glyph'); $body->add_news(70, sprintf('%s has uncovered a rare and ancient %s glyph on %s.',$empire->name, $ore, $remote_body->name)); } @@ -84,20 +88,24 @@ after handle_arrival_procedures => sub { my $type = random_element([ORE_TYPES, FOOD_TYPES, qw(water energy)]); my $amount = randint(100 + $distance_modifier, 2500 + $distance_modifier); $body->add_type($type, $amount)->update; - $empire->send_predefined_message( - tags => ['Excavator','Alert'], - filename => 'resources_discovered_by_excavator.txt', - params => [$remote_body->x, $remote_body->y, $remote_body->name, $amount, $type, $body->id, $body->name], - ); + if (!$empire->skip_excavator_resources) { + $empire->send_predefined_message( + tags => ['Excavator','Alert'], + filename => 'resources_discovered_by_excavator.txt', + params => [$remote_body->x, $remote_body->y, $remote_body->name, $amount, $type, $body->id, $body->name], + ); + } } # wha wha wha wahaa - nothing! else { - $empire->send_predefined_message( - tags => ['Excavator','Alert'], - filename => 'glyph_not_discovered_by_excavator.txt', - params => [$remote_body->x, $remote_body->y, $remote_body->name, $body->id, $body->name], - ); + if (!$empire->skip_found_nothing) { + $empire->send_predefined_message( + tags => ['Excavator','Alert'], + filename => 'glyph_not_discovered_by_excavator.txt', + params => [$remote_body->x, $remote_body->y, $remote_body->name, $body->id, $body->name], + ); + } } # all pow diff --git a/var/upgrades/3.0600.sql b/var/upgrades/3.0600.sql index 17b0c17a..2193bc46 100644 --- a/var/upgrades/3.0600.sql +++ b/var/upgrades/3.0600.sql @@ -1,2 +1,9 @@ alter table message add column has_trashed tinyint not null default 0; +alter table empire add column `skip_found_nothing` tinyint NOT NULL default 0; +alter table empire add column `skip_excavator_resources` tinyint NOT NULL default 0; +alter table empire add column `skip_excavator_glyph` tinyint NOT NULL default 0; +alter table empire add column `skip_excavator_plan` tinyint NOT NULL default 0; +alter table empire add column `skip_spy_recovery` tinyint NOT NULL default 0; +alter table empire add column `skip_probe_detected` tinyint NOT NULL default 0; + diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index eda900c5..ef751d09 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -2,6 +2,7 @@ - API: Added trash methods to the Inbox. - API: Parliament messages will be tagged as such instead of Correspondence. - API: Added Alliance, Attack, Colonization, Complaint, Excavator, Mission, Parliament, Probe, Spies, and Trade tags to the Inbox. + - API: Added profile settings to disable excavator, probe detected, and spy recovery messages. - Rule: Archived messages will no longer be deleted. Trashed messages will be purged thirty days after they were sent. - Fix: Corrected documentation for the rename method in Body. -- 2.51.2 From 03f86e1635ea6f06cac5d9354365dce47db98957 Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Thu, 14 Apr 2011 20:21:46 -0500 Subject: [PATCH 2/3] Updated docs --- docs/Empire.pod | 28 ++++++++++++++++++++++++++++ docs/Inbox.pod | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/docs/Empire.pod b/docs/Empire.pod index 85225167..b018315e 100644 --- a/docs/Empire.pod +++ b/docs/Empire.pod @@ -270,6 +270,12 @@ Provides a list of the editable properties of the current empire's profile. See "skip_pollution_warnings" : 0, "skip_medal_messages" : 0, "skip_facebook_wall_posts" : 0, + "skip_found_nothing + "skip_excavator_resources" : 0, + "skip_excavator_glyph" : 0, + "skip_excavator_plan" : 0, + "skip_spy_recovery" : 0, + "skip_probe_detected" : 0, "email" : "joe@example.com", "sitter_password" : "abcdefgh" # never give out your real password, use the sitter password }, @@ -363,7 +369,29 @@ Defaults to 0. Set to 1 if the user no longer wants to receive messages about th Defaults to 0. Set to 1 if the user no longer wants messages to be posted to their Facebook wall. +=head4 skip_found_nothing +Defaults to 0. Set to 1 if the user no longer wants to receive messages when excavators find nothing. + +=head4 skip_excavator_resources + +Defaults to 0. Set to 1 if the user no longer wants to receive messages when excavators find resources. + +=head4 skip_excavator_glyph + +Defaults to 0. Set to 1 if the user no longer wants to receive messages when excavators find glyphs. + +=head4 skip_excavator_plan + +Defaults to 0. Set to 1 if the user no longer wants to receive messages when excavators find plans. + +=head4 skip_spy_recovery + +Defaults to 0. Set to 1 if the user no longer wants to receive spy recovery messages. ("I'm ready to work. What do you need from me?") + +=head4 skip_probe_detected + +Defaults to 0. Set to 1 if the user no longers wants to receive messages when a probe is detected. =head2 view_public_profile (session_id, empire_id) diff --git a/docs/Inbox.pod b/docs/Inbox.pod index 660cb348..1a3e69bd 100644 --- a/docs/Inbox.pod +++ b/docs/Inbox.pod @@ -51,6 +51,42 @@ Reports gathered from spies. Messages letting you know something dire about your empire, usually sabotage by spies. +=item Attack + +Messages informing you about attacks (offensive and defensive). + +=item Colonization + +Messages concerning staking and colonizing planets (including space station conversions). + +=item Complaint + +Messages regarding planetary complaints (happiness, resource, and pollution warnings). + +=item Excavator + +Messages about excavator findings (nothing, resources, glyph, plan). + +=item Mission + +Messages from the Mission Curators. + +=item Parliament + +Messages that tell you about Parliamentary proceedings (votes needed, votes passed, votes failed, etc). + +=item Probe + +Messages concerning detected probes. + +=item Spies + +Non-intelligence related spy reports. + +=item Trade + +Messages related to trades. + =back Throws 1002, 1006. -- 2.51.2 From 5c52c2e9a1ae7b2a4098e5257450ae9523699f48 Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Thu, 14 Apr 2011 22:54:28 -0500 Subject: [PATCH 3/3] Archived and trashed messages are marked as read. --- docs/Inbox.pod | 5 +++++ lib/Lacuna/RPC/Inbox.pm | 2 ++ var/www/public/changes.txt | 1 + 3 files changed, 8 insertions(+) diff --git a/docs/Inbox.pod b/docs/Inbox.pod index 1a3e69bd..8e44f797 100644 --- a/docs/Inbox.pod +++ b/docs/Inbox.pod @@ -142,6 +142,7 @@ Retrieves a message. Marks it read if it hasn't been already. "has_read" : 1, "has_replied" : 0, "has_archived" : 0, + "has_trashed" : 0, "in_reply_to" : "", "recipients" : ["John Stewart"], "tags" : ["Correspondence"], @@ -200,6 +201,8 @@ Archives a list of messages. Returns: "status" : { ... } } +Archived messages are marked as read. + B You cannot archive sent messages. You'll get a failure if the message is either already archived, or it's a message that cannot be archived, like a message in your sent folder. =head3 session_id @@ -216,6 +219,8 @@ An array reference of message ids. =head2 trash_messages ( session_id, message_ids ) +Trashed messages are marked as read. + Trashes a list of messages. Returns: { diff --git a/lib/Lacuna/RPC/Inbox.pm b/lib/Lacuna/RPC/Inbox.pm index 4aabe4b7..98360372 100644 --- a/lib/Lacuna/RPC/Inbox.pm +++ b/lib/Lacuna/RPC/Inbox.pm @@ -54,6 +54,7 @@ sub archive_messages { foreach my $id (@{$message_ids}) { my $message = $messages->find($id); if (defined $message && $empire->id eq $message->to_id && !$message->has_archived) { + $message->has_read(1); $message->has_archived(1); $message->has_trashed(0); $message->update; @@ -75,6 +76,7 @@ sub trash_messages { foreach my $id (@{$message_ids}) { my $message = $messages->find($id); if (defined $message && $empire->id eq $message->to_id && !$message->has_trashed) { + $message->has_read(1); $message->has_archived(0); $message->has_trashed(1); $message->update; diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index ef751d09..79074a8c 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -3,6 +3,7 @@ - API: Parliament messages will be tagged as such instead of Correspondence. - API: Added Alliance, Attack, Colonization, Complaint, Excavator, Mission, Parliament, Probe, Spies, and Trade tags to the Inbox. - API: Added profile settings to disable excavator, probe detected, and spy recovery messages. + - API: Archived and trashed messages are marked as read. - Rule: Archived messages will no longer be deleted. Trashed messages will be purged thirty days after they were sent. - Fix: Corrected documentation for the rename method in Body. -- 2.51.2