diff --git a/lib/Lacuna/DB/Result/Empire.pm b/lib/Lacuna/DB/Result/Empire.pm index ac8b5316..764f8882 100644 --- a/lib/Lacuna/DB/Result/Empire.pm +++ b/lib/Lacuna/DB/Result/Empire.pm @@ -970,15 +970,46 @@ sub add_observatory_probe { } sub next_colony_cost { - my ($self, $adjustment) = @_; - my $count = $self->planets->count + $adjustment; - $count += Lacuna->db->resultset('Ships')->search( - { type=> { in => [qw(colony_ship short_range_colony_ship space_station)]}, task=>'travelling', direction=>'out', 'body.empire_id' => $self->id}, - { join => 'body' } - )->count; - my $inflation = 1 + INFLATION - ($self->effective_growth_affinity * 5 / 100); -# my $inflation = 1 + INFLATION - ($self->effective_growth_affinity / 100); - my $tally = 100_000 * ($inflation**($count-1)); + my ($self, $type, $adjustment) = @_; + + $adjustment = 0 unless defined $adjustment; + my $tally; + if ($type eq "colony_ship" or $type eq "short_range_colony_ship" or $type eq "spy") { + my $count = $self->planets->search({ class => { '!=' => 'Lacuna::DB::Result::Map::Body::Planet::Station' }})->count; + $count += Lacuna->db->resultset('Ships')->search( + { type=> { in => [qw(colony_ship short_range_colony_ship)]}, task=>'travelling', direction=>'out', 'body.empire_id' => $self->id}, + { join => 'body' } + )->count; + my $srcs = $type eq "short_range_colony_ship" ? 25 : 0; + my $inflation = 1 + INFLATION - (($srcs + $self->effective_growth_affinity * 5) / 100); + $tally = 100_000 * ($inflation**($count-1)); + my $max = 2_700_000_000_000_000 / (1 + (($srcs + $self->effective_growth_affinity * 5) / 100)); + $max *= 250 if $type eq "spy"; + $tally = $max if $tally > $max; + } + elsif ($type eq "space_station" and $self->alliance_id) { + my $count = $self->alliance->stations->count; + my @allies = Lacuna->db->resultset('Empire')->search( + { + alliance_id => $self->alliance_id, + })->get_column('id')->all; + $count += Lacuna->db->resultset('Ships')->search( + { + type=> 'space_station', + task=>'Travelling', + direction=>'out', + 'body.empire_id' => { in => \@allies} + }, + { join => 'body' } + )->count; + my $inflation = 1 + INFLATION - (($self->effective_growth_affinity * 5) / 100); + $tally = 250_000 * ($inflation**($count-1)); + my $max = 1_350_000_000_000_000 / (1 + ($self->effective_growth_affinity * 5 / 100)); + $tally = $max if $tally > $max; + } + else { + $tally = 10_000_000_000_000_000_000; + } return sprintf('%.0f', $tally); } diff --git a/lib/Lacuna/DB/Result/Spies.pm b/lib/Lacuna/DB/Result/Spies.pm index e1c30040..1ba98a13 100644 --- a/lib/Lacuna/DB/Result/Spies.pm +++ b/lib/Lacuna/DB/Result/Spies.pm @@ -1885,9 +1885,9 @@ sub can_conduct_advanced_missions { sub steal_planet { my ($self, $defender) = @_; - my $next_colony_cost = $self->empire->next_colony_cost; + my $next_colony_cost = $self->empire->next_colony_cost("spy"); my $planet_happiness = $self->on_body->happiness; - my $chance = abs($planet_happiness * 100) / $next_colony_cost; + my $chance = int(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( @@ -1901,6 +1901,9 @@ sub steal_planet { params => [$self->on_body->x, $self->on_body->y, $self->on_body->name, + commify(abs($planet_happiness)), + commify($next_colony_cost("spy")), + $chance, $self->format_from], )->id; } diff --git a/lib/Lacuna/RPC/Building/PlanetaryCommand.pm b/lib/Lacuna/RPC/Building/PlanetaryCommand.pm index 61db3cf3..f0c92735 100644 --- a/lib/Lacuna/RPC/Building/PlanetaryCommand.pm +++ b/lib/Lacuna/RPC/Building/PlanetaryCommand.pm @@ -23,7 +23,8 @@ around 'view' => sub { $out->{planet} = $building->body->get_status($empire); $out->{ore} = $building->body->get_ore_status; $out->{food} = $building->body->get_food_status; - $out->{next_colony_cost} = $empire->next_colony_cost; + $out->{next_colony_cost} = $empire->next_colony_cost("colony_ship"); + $out->{next_station_cost} = $empire->next_colony_cost("space_station"); $out->{pod_delay} = $building->pod_delay; return $out; }; diff --git a/lib/Lacuna/RPC/Building/StationCommand.pm b/lib/Lacuna/RPC/Building/StationCommand.pm index feccf7ba..fe68b022 100644 --- a/lib/Lacuna/RPC/Building/StationCommand.pm +++ b/lib/Lacuna/RPC/Building/StationCommand.pm @@ -23,7 +23,8 @@ around 'view' => sub { $out->{planet} = $building->body->get_status($empire); $out->{ore} = $building->body->get_ore_status; $out->{food} = $building->body->get_food_status; - $out->{next_colony_cost} = $empire->next_colony_cost; + $out->{next_colony_cost} = $empire->next_colony_cost("colony_ship"); + $out->{next_station_cost} = $empire->next_colony_cost("space_station"); return $out; }; diff --git a/lib/Lacuna/Role/Ship/Send/SpendNextColonyCost.pm b/lib/Lacuna/Role/Ship/Send/SpendNextColonyCost.pm index 63fea3d1..0f624b86 100644 --- a/lib/Lacuna/Role/Ship/Send/SpendNextColonyCost.pm +++ b/lib/Lacuna/Role/Ship/Send/SpendNextColonyCost.pm @@ -11,7 +11,7 @@ after turn_around => sub { after can_send_to_target => sub { my ($self, $target) = @_; my $empire = $self->body->empire; - my $next_colony_cost = $empire->next_colony_cost; + my $next_colony_cost = $empire->next_colony_cost($self->type); confess [ 1011, 'You do not have enough happiness to colonize another planet. You need '.$next_colony_cost.' happiness.', [$next_colony_cost]] unless ( $self->body->happiness > $next_colony_cost); return 1; }; @@ -19,7 +19,7 @@ after can_send_to_target => sub { after send => sub { my $self = shift; return if ($self->direction eq 'in'); - my $next_colony_cost = $self->body->empire->next_colony_cost(-1); + my $next_colony_cost = $self->body->empire->next_colony_cost($self->type, -1); $self->body->spend_happiness($next_colony_cost)->update; $self->payload({ colony_cost => $next_colony_cost }); $self->update; diff --git a/var/messages/insurrection_failed.txt b/var/messages/insurrection_failed.txt index 44225f99..60868114 100644 --- a/var/messages/insurrection_failed.txt +++ b/var/messages/insurrection_failed.txt @@ -1,7 +1,8 @@ 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. +We currently have them at %s unhappiness and with our chances based off %s giving us a %s% chance of taking control. Regards, -%s \ No newline at end of file +%s diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 825d9f3d..13eb1ffa 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -33,6 +33,7 @@ - Mod: Spies have fewer useless options. - Mod: Invalid login attempts warns. - Mod: Warnings about fissures shouldn't bother as many out of range. + - Mod: Split happiness cost calculation with SS & Colonies 3.0908: - Mod: trash_messages_where now defaults to not returning deleted message IDs.