From f9c304fa4880c5d4a3777de83764b770583ceee2 Mon Sep 17 00:00:00 2001 From: lemming552 Date: Mon, 3 Oct 2011 15:08:13 -0600 Subject: [PATCH 1/2] Partial repair needed another tweak. --- lib/Lacuna/DB/Result/Building.pm | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/lib/Lacuna/DB/Result/Building.pm b/lib/Lacuna/DB/Result/Building.pm index 83e8c791..c3f07073 100755 --- a/lib/Lacuna/DB/Result/Building.pm +++ b/lib/Lacuna/DB/Result/Building.pm @@ -899,35 +899,39 @@ sub repair { my ($self, $costs) = @_; $costs ||= $self->get_repair_costs; my $body = $self->body; - my $eff = 100; + my $fix = 100; + my $c_eff = $self->efficiency; unless ($body->food_stored >= $costs->{food} or $costs->{food} == 0) { my $teff = int(($body->food_stored-50)*100/$costs->{food}); - $eff = $teff if ($teff < $eff); + $fix = $teff if ($teff < $fix); } unless ($body->water_stored >= $costs->{water} or $costs->{water} == 0) { my $teff = int($body->water_stored*100/$costs->{water}); - $eff = $teff if ($teff < $eff); + $fix = $teff if ($teff < $fix); } unless ($body->ore_stored >= $costs->{ore} or $costs->{ore} == 0) { my $teff = int(($body->ore_stored-50)*100/$costs->{ore}); - $eff = $teff if ($teff < $eff); + $fix = $teff if ($teff < $fix); } unless ($body->energy_stored >= $costs->{energy} or $costs->{energy} == 0) { my $teff = int($body->energy_stored*100/$costs->{energy}); - $eff = $teff if ($teff < $eff); + $fix = $teff if ($teff < $fix); } - unless ($eff > 0) { + unless ($fix > 0) { confess [1011, 'Not enough resources to do a partial repair.']; } - $self->efficiency($eff); - $costs->{food} = int($eff*$costs->{food}/100); - $costs->{water} = int($eff*$costs->{water}/100); - $costs->{ore} = int($eff*$costs->{ore}/100); - $costs->{energy} = int($eff*$costs->{energy}/100); - if ($eff < 100) { - $eff = $self->efficiency + $eff; - $eff = 100 if ($eff > 100); + $costs->{food} = int($fix*$costs->{food}/100); + $costs->{water} = int($fix*$costs->{water}/100); + $costs->{ore} = int($fix*$costs->{ore}/100); + $costs->{energy} = int($fix*$costs->{energy}/100); + my $n_eff = 100; + if ($fix < 100) { + my $p_add = int( (100 - $c_eff) * $fix/100 + 0.5); + $p_add = 1 if $p_add < 1; + $n_eff = $c_eff + $p_add; + $n_eff = 100 if ($n_eff > 100); } + $self->efficiency($n_eff); $self->update; $body->spend_food($costs->{food}); $body->spend_water($costs->{water}); -- 2.51.2 From 0662782a33f4f391d3bded4390e98b1ecc306473 Mon Sep 17 00:00:00 2001 From: lemming552 Date: Tue, 4 Oct 2011 08:17:34 -0600 Subject: [PATCH 2/2] Spies take travel time --- lib/Lacuna/DB/Result/Spies.pm | 6 ++++-- lib/Lacuna/RPC/Building/SpacePort.pm | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/Lacuna/DB/Result/Spies.pm b/lib/Lacuna/DB/Result/Spies.pm index c98fdca2..82d641c1 100644 --- a/lib/Lacuna/DB/Result/Spies.pm +++ b/lib/Lacuna/DB/Result/Spies.pm @@ -526,6 +526,8 @@ sub run_security_sweep { my $attacker = $self->get_attacker; if (defined $attacker) { $toughness = $attacker->offense + $attacker->$mission_skill; +#XXX +print $attacker->name,"\n"; } my $breakthru = ($power - $toughness + $self->home_field_advantage) + $self->luck; @@ -1374,7 +1376,7 @@ sub capture_rebel { 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); + $self->on_body->add_news(20,'Officials prevented a coup d\'�tat today on on %s by capturing %s and comrades.', $self->on_body->name, $self->name); $self->go_to_jail; my $alliance_id = $self->empire->alliance_id; my @member_ids; @@ -1385,7 +1387,7 @@ sub prevent_insurrection { $member_ids[0] = $self->empire->id; } my $conspirators = Lacuna->db->resultset('Lacuna::DB::Result::Spies')->search({ on_body_id => $self->on_body_id, task => { 'not in' => ['Killed in Action', 'Travelling','Captured'] }, empire_id => { 'in' => \@member_ids } }); - my $count = randint(5,15); + my $count = randint(5,75); while (my $conspirator = $conspirators->next ) { $count--; $conspirator->go_to_jail; diff --git a/lib/Lacuna/RPC/Building/SpacePort.pm b/lib/Lacuna/RPC/Building/SpacePort.pm index 2c880805..20cd6a02 100644 --- a/lib/Lacuna/RPC/Building/SpacePort.pm +++ b/lib/Lacuna/RPC/Building/SpacePort.pm @@ -358,8 +358,9 @@ sub send_spies { my $spy = $spies->find($id); if ($spy->is_available) { if ($spy->empire_id == $empire->id) { + my $arrives = DateTime->now->add(seconds=>$ship->calculate_travel_time($ship->foreign_body)); push @ids_sent, $spy->id; - $spy->send($to_body->id, $ship->date_available)->update; + $spy->send($to_body->id, $arrives)->update; } else { push @ids_not_sent, $spy->id; -- 2.51.2