diff --git a/var/messages/space_station_destroyed.txt b/var/messages/space_station_destroyed.txt index 14643fe5..c3e56d55 100644 --- a/var/messages/space_station_destroyed.txt +++ b/var/messages/space_station_destroyed.txt @@ -1,7 +1,6 @@ Space Station Destroyed ~~~ We have just received word that our station named {Planet %s %s} has been destroyed. -Dev Note: Temporary fix for seeing if we can track down the SS destruction bug. Contact an admin, so we can check the state of your station if you got this message. Regards, -- 2.51.2 From b1584dd8ccb68b1564601ab0f1b8dcaa17265301 Mon Sep 17 00:00:00 2001 From: lemming552 Date: Thu, 27 Sep 2012 20:17:35 -0600 Subject: [PATCH 2/6] Insurrection will reset shipyard timers after deleting ships. --- lib/Lacuna/DB/Result/Spies.pm | 15 ++++++++++++++- lib/Lacuna/Role/Ship/Arrive/CaptureWithSpies.pm | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/Lacuna/DB/Result/Spies.pm b/lib/Lacuna/DB/Result/Spies.pm index a9573fc2..050951ea 100644 --- a/lib/Lacuna/DB/Result/Spies.pm +++ b/lib/Lacuna/DB/Result/Spies.pm @@ -485,12 +485,14 @@ has home_field_advantage => ( my $self = shift; my $body = $self->on_body; my $building = 'Security'; + my $div = 2; if ($body->isa('Lacuna::DB::Result::Map::Body::Planet::Station')) { $building = 'Module::PoliceStation'; + $div = 1; } my $hq = $body->get_building_of_class('Lacuna::DB::Result::Building::'.$building); if (defined $hq) { - return $hq->level * $hq->efficiency / 2; + return $hq->level * $hq->efficiency / $div; } else { return 0; @@ -1501,7 +1503,18 @@ sub steal_planet { $ship->delete; } } +# Shipyards have had all ships that were building destroyed, so stop timers. + my $on_body = $self->on_body; + my @shipyards = grep { + ($_->class eq 'Lacuna::DB::Result::Building::Shipyard') + } + @{$self->on_body->building_cache}; + for my $shipyard (@shipyards) { + $shipyard->is_working = 0; + $shipyard->update; + } +# Probes Lacuna->db->resultset('Lacuna::DB::Result::Probes') ->search({body_id => $self->on_body_id}) ->update({empire_id => $self->empire_id, alliance_id => $self->empire->alliance_id}); diff --git a/lib/Lacuna/Role/Ship/Arrive/CaptureWithSpies.pm b/lib/Lacuna/Role/Ship/Arrive/CaptureWithSpies.pm index 669f851b..f3d0e8a0 100644 --- a/lib/Lacuna/Role/Ship/Arrive/CaptureWithSpies.pm +++ b/lib/Lacuna/Role/Ship/Arrive/CaptureWithSpies.pm @@ -38,7 +38,7 @@ after handle_arrival_procedures => sub { # lets see if we can detect the ship my $security_detection = ($security->level * 700) * ( $security->efficiency / 100 ); if ($body->isa('Lacuna::DB::Result::Map::Body::Planet::Station')) { - $security_detection *= 1.25; + $security_detection *= 1.5; } return unless $security_detection > $self->stealth; -- 2.51.2 From 94ff23801d726edc817fbccc25f555e5b320753f Mon Sep 17 00:00:00 2001 From: lemming552 Date: Thu, 4 Oct 2012 10:17:59 -0600 Subject: [PATCH 3/6] Update changes.txt and fix the is_working. --- lib/Lacuna.pm | 2 +- lib/Lacuna/DB/Result/Spies.pm | 2 +- var/www/public/changes.txt | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/Lacuna.pm b/lib/Lacuna.pm index f1a72de1..ee9ef2f4 100644 --- a/lib/Lacuna.pm +++ b/lib/Lacuna.pm @@ -7,7 +7,7 @@ use Config::JSON; useall __PACKAGE__; -our $VERSION = 3.0870; +our $VERSION = 3.0871; my $config = Config::JSON->new('/data/Lacuna-Server/etc/lacuna.conf'); my $db = Lacuna::DB->connect($config->get('db/dsn'),$config->get('db/username'),$config->get('db/password'), { mysql_enable_utf8 => 1}); diff --git a/lib/Lacuna/DB/Result/Spies.pm b/lib/Lacuna/DB/Result/Spies.pm index 050951ea..4bb7477d 100644 --- a/lib/Lacuna/DB/Result/Spies.pm +++ b/lib/Lacuna/DB/Result/Spies.pm @@ -1510,7 +1510,7 @@ sub steal_planet { } @{$self->on_body->building_cache}; for my $shipyard (@shipyards) { - $shipyard->is_working = 0; + $shipyard->is_working(0); $shipyard->update; } diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 5215940f..0f7f2f9a 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -1,3 +1,8 @@ +3.0871: + - Mod: Police Stations get an upgrade. + - Fix: Shipyards on captured planets have is_working flag turned off. + - Fix: Dev note taken out of space station destroyed email. + 3.0870: - Add: Black Hole Generator can now be subsidized both for accuracy and cooldown - Fix: List of stars to rename in Parliament are now sorted -- 2.51.2 From 35fef198ccf6ef8cd0a0d62b5e93b3c09d3429b2 Mon Sep 17 00:00:00 2001 From: lemming552 Date: Thu, 4 Oct 2012 14:22:00 -0600 Subject: [PATCH 4/6] Training gets slowed down by being unhappy. --- lib/Lacuna/DB/Result/Building/IntelTraining.pm | 14 ++++++++++++-- lib/Lacuna/DB/Result/Building/Intelligence.pm | 5 +++++ lib/Lacuna/DB/Result/Building/MayhemTraining.pm | 14 ++++++++++++-- lib/Lacuna/DB/Result/Building/PoliticsTraining.pm | 14 ++++++++++++-- lib/Lacuna/DB/Result/Building/TheftTraining.pm | 14 ++++++++++++-- var/www/public/changes.txt | 1 + 6 files changed, 54 insertions(+), 8 deletions(-) diff --git a/lib/Lacuna/DB/Result/Building/IntelTraining.pm b/lib/Lacuna/DB/Result/Building/IntelTraining.pm index a49dbcf0..52f17517 100644 --- a/lib/Lacuna/DB/Result/Building/IntelTraining.pm +++ b/lib/Lacuna/DB/Result/Building/IntelTraining.pm @@ -98,7 +98,12 @@ sub training_costs { my $spy = $self->get_spy($spy_id); my $train_time = sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100)); - $train_time = 3600 if ($train_time < 3600); + if ($self->body->happiness < 0) { + my $unhappy_workers = abs($self->body->happiness)/100_000; + $train_time = int($train_time * $unhappy_workers); + } + $train_time = 5184000 if ($train_time > 5184000); # Max time per spy is 60 days + $train_time = 3600 if ($train_time < 3600); # Min time is 5 min $costs->{time} = $train_time; } else { @@ -106,7 +111,12 @@ sub training_costs { while (my $spy = $spies->next) { my $train_time = sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100)); - $train_time = 3600 if ($train_time < 3600); + if ($self->body->happiness < 0) { + my $unhappy_workers = abs($self->body->happiness)/100_000; + $train_time = int($train_time * $unhappy_workers); + } + $train_time = 5184000 if ($train_time > 5184000); # Max time per spy is 60 days + $train_time = 3600 if ($train_time < 3600); # Min time is 5 min push @{$costs->{time}}, { spy_id => $spy->id, name => $spy->name, diff --git a/lib/Lacuna/DB/Result/Building/Intelligence.pm b/lib/Lacuna/DB/Result/Building/Intelligence.pm index 1bc52b7e..800a846e 100644 --- a/lib/Lacuna/DB/Result/Building/Intelligence.pm +++ b/lib/Lacuna/DB/Result/Building/Intelligence.pm @@ -178,6 +178,11 @@ sub train_spy { unless ($time_to_train) { $time_to_train = $self->training_costs->{time}; } + if ($self->body->happiness < 0) { + my $unhappy_workers = abs($self->body->happiness)/100_000; + $time_to_train = int($time_to_train * $unhappy_workers); + } + $time_to_train = 5184000 if ($time_to_train > 5184000); # Max time per spy is 60 days my $latest = $self->latest_spy; my $available_on = (defined $latest) ? $latest->available_on->clone : DateTime->now; $available_on->add(seconds => $time_to_train ); diff --git a/lib/Lacuna/DB/Result/Building/MayhemTraining.pm b/lib/Lacuna/DB/Result/Building/MayhemTraining.pm index 1f56a2ad..68516a0d 100644 --- a/lib/Lacuna/DB/Result/Building/MayhemTraining.pm +++ b/lib/Lacuna/DB/Result/Building/MayhemTraining.pm @@ -100,14 +100,24 @@ sub training_costs { if ($spy_id) { my $spy = $self->get_spy($spy_id); my $train_time = sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100)); - $train_time = 3600 if ($train_time < 3600); + if ($self->body->happiness < 0) { + my $unhappy_workers = abs($self->body->happiness)/100_000; + $train_time = int($train_time * $unhappy_workers); + } + $train_time = 5184000 if ($train_time > 5184000); # Max time per spy is 60 days + $train_time = 3600 if ($train_time < 3600); # Min time is 5 min $costs->{time} = $train_time; } else { my $spies = $self->get_spies->search({ task => { in => ['Counter Espionage','Idle'] } }); while (my $spy = $spies->next) { my $train_time = sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100)); - $train_time = 3600 if ($train_time < 3600); + if ($self->body->happiness < 0) { + my $unhappy_workers = abs($self->body->happiness)/100_000; + $train_time = int($train_time * $unhappy_workers); + } + $train_time = 5184000 if ($train_time > 5184000); # Max time per spy is 60 days + $train_time = 3600 if ($train_time < 3600); # Min time is 5 min push @{$costs->{time}}, { spy_id => $spy->id, name => $spy->name, diff --git a/lib/Lacuna/DB/Result/Building/PoliticsTraining.pm b/lib/Lacuna/DB/Result/Building/PoliticsTraining.pm index 463b3670..b03fcd6d 100644 --- a/lib/Lacuna/DB/Result/Building/PoliticsTraining.pm +++ b/lib/Lacuna/DB/Result/Building/PoliticsTraining.pm @@ -97,14 +97,24 @@ sub training_costs { if ($spy_id) { my $spy = $self->get_spy($spy_id); my $train_time = sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100)); - $train_time = 3600 if ($train_time < 3600); + if ($self->body->happiness < 0) { + my $unhappy_workers = abs($self->body->happiness)/100_000; + $train_time = int($train_time * $unhappy_workers); + } + $train_time = 5184000 if ($train_time > 5184000); # Max time per spy is 60 days + $train_time = 3600 if ($train_time < 3600); # Min time is 5 min $costs->{time} = $train_time; } else { my $spies = $self->get_spies->search({ task => { in => ['Counter Espionage','Idle'] } }); while (my $spy = $spies->next) { my $train_time = sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100)); - $train_time = 3600 if ($train_time < 3600); + if ($self->body->happiness < 0) { + my $unhappy_workers = abs($self->body->happiness)/100_000; + $train_time = int($train_time * $unhappy_workers); + } + $train_time = 5184000 if ($train_time > 5184000); # Max time per spy is 60 days + $train_time = 3600 if ($train_time < 3600); # Min time is 5 min push @{$costs->{time}}, { spy_id => $spy->id, name => $spy->name, diff --git a/lib/Lacuna/DB/Result/Building/TheftTraining.pm b/lib/Lacuna/DB/Result/Building/TheftTraining.pm index e15a5323..73a56103 100644 --- a/lib/Lacuna/DB/Result/Building/TheftTraining.pm +++ b/lib/Lacuna/DB/Result/Building/TheftTraining.pm @@ -97,14 +97,24 @@ sub training_costs { if ($spy_id) { my $spy = $self->get_spy($spy_id); my $train_time = sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100)); - $train_time = 3600 if ($train_time < 3600); + if ($self->body->happiness < 0) { + my $unhappy_workers = abs($self->body->happiness)/100_000; + $train_time = int($train_time * $unhappy_workers); + } + $train_time = 5184000 if ($train_time > 5184000); # Max time per spy is 60 days + $train_time = 3600 if ($train_time < 3600); # Min time is 5 min $costs->{time} = $train_time; } else { my $spies = $self->get_spies->search({ task => { in => ['Counter Espionage','Idle'] } }); while (my $spy = $spies->next) { my $train_time = sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100)); - $train_time = 3600 if ($train_time < 3600); + if ($self->body->happiness < 0) { + my $unhappy_workers = abs($self->body->happiness)/100_000; + $train_time = int($train_time * $unhappy_workers); + } + $train_time = 5184000 if ($train_time > 5184000); # Max time per spy is 60 days + $train_time = 3600 if ($train_time < 3600); # Min time is 5 min push @{$costs->{time}}, { spy_id => $spy->id, name => $spy->name, diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 0f7f2f9a..ebc0381d 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -2,6 +2,7 @@ - Mod: Police Stations get an upgrade. - Fix: Shipyards on captured planets have is_working flag turned off. - Fix: Dev note taken out of space station destroyed email. + - Fix: Unhappy spies take longer to train. 3.0870: - Add: Black Hole Generator can now be subsidized both for accuracy and cooldown -- 2.51.2 From a94e14fadaae3ad1f9a2cbedad698441408611c3 Mon Sep 17 00:00:00 2001 From: lemming552 Date: Thu, 4 Oct 2012 14:42:19 -0600 Subject: [PATCH 5/6] Cosmetic fix for displaying train time in intmin. --- lib/Lacuna/DB/Result/Building/Intelligence.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/Lacuna/DB/Result/Building/Intelligence.pm b/lib/Lacuna/DB/Result/Building/Intelligence.pm index 800a846e..94f0238e 100644 --- a/lib/Lacuna/DB/Result/Building/Intelligence.pm +++ b/lib/Lacuna/DB/Result/Building/Intelligence.pm @@ -137,13 +137,20 @@ has training_multiplier => ( sub training_costs { my $self = shift; my $multiplier = $self->training_multiplier; + my $time_to_train = sprintf('%.0f', 2060 * $multiplier / $self->body->empire->management_affinity); + if ($self->body->happiness < 0) { + my $unhappy_workers = abs($self->body->happiness)/100_000; + $time_to_train = int($time_to_train * $unhappy_workers); + } + $time_to_train = 5184000 if ($time_to_train > 5184000); # Max time per spy is 60 days + $time_to_train = 3600 if ($time_to_train < 3600); # Min time is 5 minutes return { water => 1100 * $multiplier, waste => 40 * $multiplier, energy => 100 * $multiplier, food => 1000 * $multiplier, ore => 10 * $multiplier, - time => sprintf('%.0f', 2060 * $multiplier / $self->body->empire->management_affinity), + time => $time_to_train, }; } -- 2.51.2 From 5b78b3ad99468d320e71f85674be334c10d9ad46 Mon Sep 17 00:00:00 2001 From: lemming552 Date: Thu, 4 Oct 2012 15:01:03 -0600 Subject: [PATCH 6/6] Fixed double charging on training time. --- lib/Lacuna/DB/Result/Building/Intelligence.pm | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/Lacuna/DB/Result/Building/Intelligence.pm b/lib/Lacuna/DB/Result/Building/Intelligence.pm index 94f0238e..b115f5b2 100644 --- a/lib/Lacuna/DB/Result/Building/Intelligence.pm +++ b/lib/Lacuna/DB/Result/Building/Intelligence.pm @@ -143,7 +143,7 @@ sub training_costs { $time_to_train = int($time_to_train * $unhappy_workers); } $time_to_train = 5184000 if ($time_to_train > 5184000); # Max time per spy is 60 days - $time_to_train = 3600 if ($time_to_train < 3600); # Min time is 5 minutes + $time_to_train = 300 if ($time_to_train < 300); # Min time is 5 minutes return { water => 1100 * $multiplier, waste => 40 * $multiplier, @@ -185,11 +185,6 @@ sub train_spy { unless ($time_to_train) { $time_to_train = $self->training_costs->{time}; } - if ($self->body->happiness < 0) { - my $unhappy_workers = abs($self->body->happiness)/100_000; - $time_to_train = int($time_to_train * $unhappy_workers); - } - $time_to_train = 5184000 if ($time_to_train > 5184000); # Max time per spy is 60 days my $latest = $self->latest_spy; my $available_on = (defined $latest) ? $latest->available_on->clone : DateTime->now; $available_on->add(seconds => $time_to_train );