diff --git a/lib/Lacuna/DB/Result/Spies.pm b/lib/Lacuna/DB/Result/Spies.pm index 55de80df..18db5a9f 100644 --- a/lib/Lacuna/DB/Result/Spies.pm +++ b/lib/Lacuna/DB/Result/Spies.pm @@ -138,12 +138,16 @@ use constant offensive_assignments => ( }, { task =>'Appropriate Technology', - recovery => 60 * 60 * 12, + recovery => 60 * 60 * 18, }, { task =>'Incite Rebellion', recovery => 60 * 60 * 18, }, + { + task =>'Incite Insurrection', + recovery => 60 * 60 * 24, + }, ); use constant defensive_assignments => ( @@ -287,6 +291,7 @@ use constant assignments => ( 'Abduct Operatives', 'Appropriate Technology', 'Incite Rebellion', + 'Incite Insurrection', ); sub assign { @@ -374,7 +379,6 @@ my %skills = ( 'Gather Empire Intelligence' => 'intel_xp', 'Gather Operative Intelligence' => 'intel_xp', 'Hack Network 19' => 'politics_xp', - 'Appropriate Technology' => 'theft_xp', 'Sabotage Probes' => 'mayhem_xp', 'Rescue Comrades' => 'intel_xp', 'Sabotage Resources' => 'mayhem_xp', @@ -383,7 +387,9 @@ my %skills = ( 'Sabotage Infrastructure' => 'mayhem_xp', 'Incite Mutiny' => 'politics_xp', 'Abduct Operatives' => 'intel_xp', + 'Appropriate Technology' => 'theft_xp', 'Incite Rebellion' => 'politics_xp', + 'Incite Insurrection' => 'politics_xp', ); my @offense_tasks = keys %skills; @@ -403,6 +409,7 @@ my %outcomes = ( 'Incite Mutiny' => 'incite_mutany', 'Abduct Operatives' => 'abduct_operatives', 'Incite Rebellion' => 'incite_rebellion', + 'Incite Insurrection' => 'incite_insurrection', ); sub run_mission { @@ -1061,9 +1068,78 @@ sub incite_rebellion_loss { } } +sub incite_insurrection { + my $self = shift; + given (randint(1,1)) { + when (1) { return $self->steal_planet(@_) } + } +} + +sub incite_insurrection_loss { + my $self = shift; + given (randint(1,1)) { + when (1) { return $self->prevent_insurrection(@_) } + } +} # OUTCOMES +sub steal_planet { + my ($self, $defender) = @_; + my $defender_capitol_id = $self->on_body->empire->home_planet_id; + unless ($defender_capitol_id == $self->on_body_id ) { + return $self->empire->send_predefined_message( + tags => ['Correspondence'], + filename => 'cannot_steal_homeworld.txt', + from => $self->empire->lacuna_expanse_corp, + )->id; + } + my $ranks = Lacuna->db->resultset('Lacuna::DB::Result::Log::Empire'); + my $defender_rank = $ranks->search({empire_id => $defender->on_body->empire_id },{rows => 1})->get_column('empire_size_rank')->single; + my $attacker_rank = $ranks->search({empire_id => $self->empire_id },{rows => 1})->get_column('empire_size_rank')->single; + unless ($attacker_rank + 50 > $defender_rank ) { # remember that the rank is inverted 1 is higher than 2. + return $self->empire->send_predefined_message( + tags => ['Correspondence'], + filename => 'cannot_insurrect.txt', + from => $self->empire->lacuna_expanse_corp, + )->id; + } + my $next_colony_cost = $self->empire->next_colony_cost; + my $planet_happiness = $self->on_body->happiness; + my $chance = abs($planet_happiness * 100) / $next_colony_cost; + my $failure = randint(1,100) > $chance; + if ($planet_happiness > 0 || $failure) { # lose + $self->on_body->empire->send_predefined_message( + tags => ['Alert'], + filename => 'insurrection_luck.txt', + params => [$self->on_body_id, $self->on_body->name], + ); + return $self->empire->send_predefined_message( + tags => ['Intelligence'], + filename => 'insurrection_failed.txt', + params => [$self->on_body->x, $self->on_body->y, $self->on_body->name, $self->format_from], + )->id; + } + else { # win + $self->on_body->empire->send_predefined_message( + tags => ['Alert'], + filename => 'lost_planet_to_insurrection.txt', + params => [$self->on_body->name, $self->on_body->x, $self->on_body->y, $self->on_body->name], + ); + $self->on_body->add_news(100,'Led by %s, the citizens of %s have overthrown %s!', $self->name, $self->on_body->name, $self->on_body->empire->name); + Lacuna->db->resultset('Lacuna::DB::Result::Spies')->search({from_body_id => $self->on_body_id})->update({from_body_id => $defender_capitol_id }); + $self->on_body->empire_id($self->empire_id); + $self->on_body->add_happiness(int(abs($planet_happiness) / 10)); + $self->on_body->update; + return $self->empire->send_predefined_message( + tags => ['Intelligence'], + filename => 'insurrection_complete.txt', + params => [$self->on_body_id, $self->on_body->name, $self->format_from], + )->id; + } +} + + sub uprising { my ($self, $defender) = @_; $self->seeds_planted( $self->seeds_planted + 1 ); @@ -1198,6 +1274,26 @@ sub capture_rebel { return $defender->capture_a_spy($self)->id; } +sub prevent_insurrection { + my ($self, $defender) = @_; + return $self->get_spooked->id unless (defined $defender); + $self->on_body->add_news(50,'Officials prevented a coup d\'�tat today on on %s by capturing %s and comrades.', $self->on_body->name, $self->name); + $defender->capture_a_spy($self)->id; + my $alliance_id = $defender->empire->alliance_id; + if ($alliance_id) { + my @member_ids = $defender->empire->alliance->members->get_column('id')->all; + my $conspirators = Lacuna->db->resultset('Lacuna::DB::Result::Spies')->search({ on_body_id => $self->on_body_id, task => { 'not in' => ['Idle','Travelling','Captured'] }, empire_id => { 'in' => \@member_ids } }); + while (my $conspirator = $conspirators->next ) { + $defender->capture_a_spy($conspirator); + } + } + return $defender->on_body->empire->send_predefined_message( + tags => ['Alert'], + filename => 'prevented_insurrection.txt', + params => [$self->on_body_id, $self->on_body->name, $defender->format_from], + ); +} + sub capture_kidnapper { my ($self, $defender) = @_; return $self->get_spooked->id unless (defined $defender); diff --git a/var/messages/cannot_insurrect.txt b/var/messages/cannot_insurrect.txt new file mode 100644 index 00000000..629928cd --- /dev/null +++ b/var/messages/cannot_insurrect.txt @@ -0,0 +1,9 @@ +No Can Do +~~~ +Are you really so cruel as to try to steal a planet from someone who is not within 50 rank of you? + +Pick on someone your own size, or better yet, bigger than you. + +Regards, + +The Lacuna Expanse Dev Team \ No newline at end of file diff --git a/var/messages/cannot_steal_homeworld.txt b/var/messages/cannot_steal_homeworld.txt new file mode 100644 index 00000000..6dac2776 --- /dev/null +++ b/var/messages/cannot_steal_homeworld.txt @@ -0,0 +1,5 @@ +Cannot Steal Capitol +~~~ +You must be short on character. Why would you try to steal someone's capitol? They have to have some refuge from people like you. + +The Lacuna Expanse Dev Team \ No newline at end of file diff --git a/var/messages/insurrection_complete.txt b/var/messages/insurrection_complete.txt new file mode 100644 index 00000000..ec70f26d --- /dev/null +++ b/var/messages/insurrection_complete.txt @@ -0,0 +1,7 @@ +Insurrection Complete +~~~ +We have taken control of {Planet %s %s}, however, our work is far from complete. The planet has regained some happiness because its citizens are glad we have saved them from their former empire, but they are still largely unhappy. In addition, there are likely enemy agents on the planet looking to take it back. + +Regards, + +%s \ No newline at end of file diff --git a/var/messages/insurrection_failed.txt b/var/messages/insurrection_failed.txt new file mode 100644 index 00000000..44225f99 --- /dev/null +++ b/var/messages/insurrection_failed.txt @@ -0,0 +1,7 @@ +Insurrection Failed +~~~ +We have failed in our attempt to take control of {Starmap %s %s %s}, but not for lack of trying. It seems that the people are simply not as dissatisfied with their government as we thought. We can work on that by inciting a rebellion. + +Regards, + +%s \ No newline at end of file diff --git a/var/messages/insurrection_luck.txt b/var/messages/insurrection_luck.txt new file mode 100644 index 00000000..4d670263 --- /dev/null +++ b/var/messages/insurrection_luck.txt @@ -0,0 +1,7 @@ +We Were Lucky +~~~ +We were very lucky today. Some enemy agents attempted to overthrow you on {Planet %s %s} today. Luckily they bungled it. We may not be so lucky going forward. + +Regards, + +Your Humble Assistant diff --git a/var/messages/lost_planet_to_insurrection.txt b/var/messages/lost_planet_to_insurrection.txt new file mode 100644 index 00000000..f88a9fd9 --- /dev/null +++ b/var/messages/lost_planet_to_insurrection.txt @@ -0,0 +1,7 @@ +Lost %s +~~~ +It is a sad day. Today we lost {Starmap %s %s %s} to insurrection. We should work harder to protect the rest of our empire. + +Regards, + +Your Humble Assistant diff --git a/var/messages/prevented_insurrection.txt b/var/messages/prevented_insurrection.txt new file mode 100644 index 00000000..74ca5fc6 --- /dev/null +++ b/var/messages/prevented_insurrection.txt @@ -0,0 +1,10 @@ +Insurrection Stopped +~~~ +We stopped an insurrection on {Planet %s %s} today. Do something quickly to raise the happiness there or we could lose the planet. + +Luckily we were able to capture several of the conspirators, so you have a little time. Use it wisely. + +Regards, + +%s + diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 18240d61..d96677ab 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -1,5 +1,6 @@ 2.4200 - Added "Security Sweep" defensive assignment. + - Added "Insurrection" offensive assignment. - Added "Abduct Operatives" offensive assignment. - You can no longer burn a spy that has been captured. - If you have ships heading to a body that becomes uninhabited while on route, the ships will now turn around and come home instead of falling dead. @@ -13,6 +14,7 @@ - Fixed a bug in the genetics ministry where killed spies didn't get killed. - Fixed a crash bug with fleet movement missions. - Fixed a formatting problem in the "Enemy Captured" email. + - Fixed a formatting problem on plans with extra build levels. 2.4102 - Fixed bleeders and thuds being added to the normal build queue on striking ground.