From 4fe6e2abb4dcd5c2081041028350309b37723f80 Mon Sep 17 00:00:00 2001 From: Mark Lemming Date: Tue, 24 Dec 2013 11:12:05 -0700 Subject: [PATCH] More tweaks on forge. --- .../DB/Result/Building/Permanent/TheDillonForge.pm | 12 +++++++++--- lib/Lacuna/RPC/Building/TheDillonForge.pm | 1 + var/messages/plan_split_by_forge.txt | 2 +- var/messages/plan_split_by_forge_failure.txt | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/Lacuna/DB/Result/Building/Permanent/TheDillonForge.pm b/lib/Lacuna/DB/Result/Building/Permanent/TheDillonForge.pm index 5f607389..99a4111f 100644 --- a/lib/Lacuna/DB/Result/Building/Permanent/TheDillonForge.pm +++ b/lib/Lacuna/DB/Result/Building/Permanent/TheDillonForge.pm @@ -93,7 +93,8 @@ sub split_plan { my $num_glyphs = scalar @$glyphs; my $base = ($num_glyphs * $halls * 30 * 3600) / ($self->level * 4); - my $build_secs = int($base + ($base * log($quantity))/log(2) + 0.5); +# my $pow_two = int(log($work->{quantity})/log(2)+0.5); + my $build_secs = int($base * (1.5 ** (log($quantity)/log(2))) + 0.5); $self->start_work({task => 'split_plan', class => $class, level => $level, extra_build_level => $extra_build_level, quantity => $quantity}, $build_secs)->update; } @@ -160,6 +161,10 @@ before finish_work => sub { # calculate the probability of success my $success_percent = $self->level * 3; my $halls = $self->equivalent_halls($work->{level}, $work->{extra_build_level}); + + my $pow_two = int(log($work->{quantity})/log(2)+0.5); + $success_percent -= 2 * $pow_two; + $success_percent = 5 if ($success_percent < 5); if ($plan_class =~ m/HallsOfVrbansk$/) { # create a random A,B,C or D hall @@ -197,11 +202,12 @@ before finish_work => sub { my @report = map { [ $glyphs_built->{$_}, $_ ]} keys %$glyphs_built; unshift (@report, ['Quantity','Glyph']); + my $s_place = $work->{quantity} > 1 ? "s" : ""; if ($total_glyphs > 0) { $empire->send_predefined_message( tags => ['Alert'], filename => 'plan_split_by_forge.txt', - params => [$body->id, $body->name, $work->{level}, $work->{extra_build_level}, $plan_class->name], + params => [$body->id, $body->name, $work->{quantity}, $work->{level}, $work->{extra_build_level}, $plan_class->name, $s_place], attachments => { table => \@report }, ); $body->add_news(100, sprintf('%s used the Dillon Forge to split a %s level %s + %s plan into %s glyphs today on %s', $empire->name, $plan_class->name, $work->{level}, $work->{extra_build_level}, $total_glyphs, $body->name)); @@ -210,7 +216,7 @@ before finish_work => sub { $empire->send_predefined_message( tags => ['Alert'], filename => 'plan_split_by_forge_failure.txt', - params => [$body->id, $body->name, $work->{level}, $work->{extra_build_level}, $plan_class->name], + params => [$body->id, $body->name, $work->{quantity}, $work->{level}, $work->{extra_build_level}, $plan_class->name, $s_place], ); $body->add_news(100, sprintf('%s failed miserably in an attempt to run the Dillon Forge today on %s', $empire->name, $body->name)); } diff --git a/lib/Lacuna/RPC/Building/TheDillonForge.pm b/lib/Lacuna/RPC/Building/TheDillonForge.pm index 834a9573..5a7cc719 100644 --- a/lib/Lacuna/RPC/Building/TheDillonForge.pm +++ b/lib/Lacuna/RPC/Building/TheDillonForge.pm @@ -87,6 +87,7 @@ PLAN: class => $class, level => $plan->level, extra_build_level => $plan->extra_build_level, + quantity => $plan->quantity, fail_chance => 100 - ($building->level * 3), reset_seconds => int(($num_glyphs * $halls * 30 * 3600) / ($building->level * 4)), }; diff --git a/var/messages/plan_split_by_forge.txt b/var/messages/plan_split_by_forge.txt index 44cf9cda..075400b4 100644 --- a/var/messages/plan_split_by_forge.txt +++ b/var/messages/plan_split_by_forge.txt @@ -1,6 +1,6 @@ Dillon Forge Splits Plan ~~~ -The Dillon Forge on {Planet %s %s} today split a level %s+%s %s plan and created the following glyphs. +The Dillon Forge on {Planet %s %s} today split %s level %s+%s %s plan%s and created the following glyphs. Regards, diff --git a/var/messages/plan_split_by_forge_failure.txt b/var/messages/plan_split_by_forge_failure.txt index d12aa627..92b73628 100644 --- a/var/messages/plan_split_by_forge_failure.txt +++ b/var/messages/plan_split_by_forge_failure.txt @@ -1,6 +1,6 @@ Dillon Forge Failure ~~~ -The Dillon Forge on {Planet %s %s} failed to split a level %s %s plan, perhaps your scientists need to do further research into its operation? +The Dillon Forge on {Planet %s %s} failed to split %s level %s %s plan%s, perhaps your scientists need to do further research into its operation? Regards, -- 2.51.2