From 7810138fea7237aa66f022f777392cfa0cfd68a6 Mon Sep 17 00:00:00 2001 From: ian docherty Date: Tue, 20 Mar 2012 04:35:14 -0400 Subject: [PATCH 1/6] Added test script to create AI attack/defense planets --- lib/Lacuna/DB/Result/Empire.pm | 1 + t/410_Fleet_Actions.t | 258 +++++++++++++++++++++++++++++++++ 2 files changed, 259 insertions(+) create mode 100644 t/410_Fleet_Actions.t diff --git a/lib/Lacuna/DB/Result/Empire.pm b/lib/Lacuna/DB/Result/Empire.pm index b68c5f99..02c1ad2d 100644 --- a/lib/Lacuna/DB/Result/Empire.pm +++ b/lib/Lacuna/DB/Result/Empire.pm @@ -91,6 +91,7 @@ sub sqlt_deploy_hook { __PACKAGE__->belongs_to('alliance', 'Lacuna::DB::Result::Alliance', 'alliance_id', { on_delete => 'set null' }); __PACKAGE__->belongs_to('home_planet', 'Lacuna::DB::Result::Map::Body', 'home_planet_id'); +__PACKAGE__->has_many('spies', 'Lacuna::DB::Result::Spies', 'empire_id'); __PACKAGE__->has_many('planets', 'Lacuna::DB::Result::Map::Body', 'empire_id'); __PACKAGE__->has_many('propositions', 'Lacuna::DB::Result::Propositions', 'proposed_by_id'); __PACKAGE__->has_many('votes', 'Lacuna::DB::Result::Votes', 'empire_id'); diff --git a/t/410_Fleet_Actions.t b/t/410_Fleet_Actions.t new file mode 100644 index 00000000..37f031ae --- /dev/null +++ b/t/410_Fleet_Actions.t @@ -0,0 +1,258 @@ +use lib '../lib'; +use Test::More tests => 90; +use 5.010; +use Lacuna; +use DateTime; +use TestHelper; + +# Set up a planet that can be used for AI Attacks, both to and against + +my $tester = TestHelper->new({empire_name => 'TLE Test Empire'}); +my $empire = $tester->empire; +my $session = $empire->start_session({api_key => 'tester'}); + +my ($planet) = Lacuna->db->resultset('Map::Body::Planet')->search({name => 'Test-10'}); + +build_big_colony($tester, $planet); + +sub build_big_colony { + my ($tester, $planet) = @_; + + my $empire = $planet->empire; + $planet->buildings->search({})->delete_all; + $planet->ships->delete_all; + Lacuna->db->resultset('Spies')->search({from_body_id => $planet->id})->delete_all; + + my $layout = { + 'PlanetaryCommand' => [ + { x => 0, y => 0, level => 30 }, + ], + 'SpacePort' => [ + { x => -2, y => -2, level => 22 }, + { x => -1, y => -2, level => 22 }, + { x => 0, y => -2, level => 22 }, + { x => 1, y => -2, level => 22 }, + { x => 2, y => -2, level => 22 }, + { x => -2, y => -1, level => 22 }, + { x => -1, y => -1, level => 22 }, + { x => 0, y => -1, level => 22 }, + { x => 1, y => -1, level => 22 }, + { x => 2, y => -1, level => 22 }, + { x => -2, y => 0, level => 22 }, + { x => -1, y => 0, level => 22 }, + { x => 1, y => 0, level => 22 }, + { x => 2, y => 0, level => 22 }, + { x => -2, y => 1, level => 22 }, + { x => -1, y => 1, level => 22 }, + { x => 0, y => 1, level => 22 }, + { x => 1, y => 1, level => 22 }, + { x => 2, y => 1, level => 22 }, + { x => -2, y => 2, level => 22 }, + { x => -1, y => 2, level => 22 }, + { x => 0, y => 2, level => 22 }, + { x => 1, y => 2, level => 22 }, + { x => 2, y => 2, level => 22 }, + { x => 4, y => -4, level => 22 }, + { x => 4, y => -3, level => 22 }, + { x => 4, y => -2, level => 22 }, + { x => 4, y => -1, level => 22 }, + { x => 4, y => 0, level => 22 }, + { x => 4, y => 1, level => 22 }, + { x => 4, y => 2, level => 22 }, + { x => 4, y => 3, level => 22 }, + { x => 4, y => 4, level => 22 }, + { x => -4, y => -4, level => 22 }, + { x => -4, y => -3, level => 22 }, + { x => -4, y => -2, level => 22 }, + { x => -4, y => -1, level => 22 }, + { x => -4, y => 0, level => 22 }, + { x => -4, y => 1, level => 22 }, + { x => -4, y => 2, level => 22 }, + { x => -4, y => 3, level => 22 }, + { x => -4, y => 4, level => 22 }, + { x => -3, y => -4, level => 22 }, + { x => -2, y => -4, level => 22 }, + { x => -1, y => -4, level => 22 }, + { x => 0, y => -4, level => 22 }, + { x => 1, y => -4, level => 22 }, + { x => 2, y => -4, level => 22 }, + { x => 3, y => -4, level => 22 }, + { x => -3, y => 4, level => 22 }, + { x => -2, y => 4, level => 22 }, + { x => -1, y => 4, level => 22 }, + { x => 0, y => 4, level => 22 }, + { x => 1, y => 4, level => 22 }, + { x => 2, y => 4, level => 22 }, + { x => 3, y => 4, level => 22 }, + ], + 'Permanent::Volcano' => [ { x => 1, y => -3, level => 30 }, ], + 'Permanent::InterDimensionalRift' => [ { x => 2, y => -3, level => 30 }, ], + 'Archaeology' => [ { x => 3, y => -3, level => 30 }, ], + 'Development' => [ { x => 0, y => -3, level => 30 }, ], + 'Permanent::GeoThermalVent' => [ { x => -1, y => -3, level => 30 }, ], + 'Espionage' => [ { x => -2, y => -3, level => 30 }, ], + 'Security' => [ { x => -3, y => -3, level => 30 }, ], + 'Intelligence' => [ { x => -3, y => -2, level => 30 }, ], + 'Embassy' => [ { x => -3, y => 0, level => 30 }, ], + 'Trade' => [ { x => 0, y => 3, level => 30 }, ], + 'Transporter' => [ { x => 3, y => 0, level => 30 }, ], + 'University' => [ { x => 3, y => -1, level => 30 }, ], + 'Observatory' => [ { x => 3, y => -2, level => 30 }, ], + 'TheftTraining' => [ { x => -3, y => 1, level => 30 }, ], + 'IntelTraining' => [ { x => -3, y => 2, level => 30 }, ], + 'MayhemTraining' => [ { x => -3, y => 3, level => 30 }, ], + 'PoliticsTraining' => [ { x => -2, y => 3, level => 30 }, ], + 'Permanent::NaturalSpring' => [ { x => -1, y => 3, level => 30 }, ], + 'Permanent::CrashedShipSite' => [ { x => 1, y => 3, level => 30 }, ], + 'CloakingLab' => [ { x => 2, y => 3, level => 30 }, ], + 'MunitionsLab' => [ { x => 3, y => 3, level => 30 }, ], + 'PilotTraining' => [ { x => 3, y => 2, level => 30 }, ], + 'Propulsion' => [ { x => 3, y => 1, level => 30 }, ], + 'Permanent::DentonBrambles' => [ { x => -5, y => 2, level => 30 }, ], + 'Permanent::AlgaePond' => [ { x => -5, y => 1, level => 30 }, ], + 'MercenariesGuild' => [ { x => -3, y => -1, level => 30 }, ], + 'Permanent::SpaceJunkPark' => [ { x => -5, y => -1, level => 30 }, ], + 'Permanent::PyramidJunkSculpture' => [ { x => -5, y => -2, level => 30 }, ], + 'Permanent::GratchsGauntlet' => [ { x => 5, y => 2, level => 30 }, ], + 'Permanent::Ravine' => [ { x => 5, y => 1, level => 30 }, ], + 'Permanent::JunkHengeSculpture' => [ { x => 5, y => -1, level => 30 }, ], + 'Permanent::MetalJunkArches' => [ { x => 5, y => -2, level => 30 }, ], +# '' => [ { x => , y => , level => 30 }, ], + 'Permanent::GasGiantPlatform' => [ + { x => 5, y => 5, level => 30 }, + { x => 5, y => -5, level => 30 }, + { x => -5, y => 5, level => 30 }, + { x => -5, y => -5, level => 30 }, + ], + 'Shipyard' => [ + { x => -2, y => 5, level => 30 }, + { x => -1, y => 5, level => 30 }, + { x => 1, y => 5, level => 30 }, + { x => 2, y => 5, level => 30 }, + { x => -2, y => -5, level => 30 }, + { x => -1, y => -5, level => 30 }, + { x => 1, y => -5, level => 30 }, + { x => 2, y => -5, level => 30 }, + ], + 'SAW' => [ + { x => -4, y => 5, level => 30 }, + { x => 4, y => 5, level => 30 }, + { x => -4, y => -5, level => 30 }, + { x => 4, y => -5, level => 30 }, + { x => -5, y => 4, level => 30 }, + { x => 5, y => 4, level => 30 }, + { x => -5, y => -4, level => 30 }, + { x => 5, y => -4, level => 30 }, + { x => 0, y => 5, level => 30 }, + { x => 0, y => -5, level => 30 }, + ], + }; + + diag("Generating buildings"); + for my $class (keys %$layout ) { + for my $location (@{$layout->{$class}}) { + my $building = Lacuna->db->resultset('Building')->new({ + x => $location->{x}, + y => $location->{y}, + class => "Lacuna::DB::Result::Building::$class", + level => $location->{level} - 1, + }); + $planet->build_building($building); + $building->finish_upgrade; + } + } + $planet->bauxite_stored(19,000,000,000); + $planet->algae_stored(19,000,000,000); + $planet->energy_stored(19,000,000,000); + $planet->water_stored(19,000,000,000); + $planet->needs_recalc(1); + $planet->update; + $planet->tick; + + # Add ships + my ($shipyard) = $planet->buildings->search({ class => 'Lacuna::DB::Result::Building::Shipyard' }); + diag("Generating ships [".$session->id."][".$shipyard->id."]"); + my $ships = { + excavator => 30, + probe => 20, + sweeper => 1300, + fighter => 500, + hulk => 250, + detonator => 20, + security_ministry_seeker=> 20, + smuggler_ship => 20, + snark3 => 200, + spy_pod => 20, + spy_shuttle => 20, + supply_pod4 => 10, + + }; + for my $ship (keys %$ships) { + # Create one ship as a 'template' + my $result = $tester->post('shipyard', 'build_ship', [$session->id, $shipyard->id, $ship]); + $tester->finish_ships( $shipyard->id ); + if ($ships->{$ship} > 1) { + my $ship_id = $result->{result}{ships_building}[0]{id}; + my $example = Lacuna->db->resultset('Ships')->find($ship_id); + diag("Building more ships of type [$ship] id [$ship_id][$example]"); + + for (1..$ships->{$ship}) { + Lacuna->db->resultset('Ships')->create({ + body_id => $example->body_id, + shipyard_id => $example->shipyard_id, + date_started => $example->date_started, + date_available => $example->date_available, + type => $example->type, + task => $example->task, + name => $example->name, + speed => $example->speed, + stealth => $example->stealth, + combat => $example->combat, + hold_size => $example->hold_size, + payload => $example->payload, + roundtrip => $example->roundtrip, + direction => $example->direction, + foreign_body_id => $example->foreign_body_id, + foreign_star_id => $example->foreign_star_id, + fleet_speed => $example->fleet_speed, + }); + } + } + } + + # Add Spies + diag("Generating Spies"); + for (1..1000) { + my $spy = $empire->add_to_spies({ + name => 'Null', + from_body_id => $planet->id, + on_body_id => $planet->id, + task => 'Counter Espionage', + started_assignment => '2012-01-01 12:00:00', + available_on => '2012-01-01 12:00:00', + offense => 2600, + defense => 2600, + date_created => DateTime->now(), + offense_mission_count => 10 + int(rand(10)), + defense_mission_count => 10 + int(rand(10)), + offense_mission_successes => int(rand(3)), + defense_mission_successes => int(rand(3)), + times_captured => 0, + times_turned => 0, + seeds_planted => 0, + spies_turned => 0, + spies_captured => 0, + spies_killed => 0, + things_destroyed => int(rand(3)), + things_stolen => int(rand(5)), + intel_xp => 95 + int(rand(5)), + mayhem_xp => 95 + int(rand(5)), + politics_xp => 95 + int(rand(5)), + theft_xp => 95 + int(rand(5)), + level => 27 + int(rand(10)), + }); + $spy->name("ICY ".$spy->id); + $spy->update; + } +} + -- 2.51.2 From b4145be2bcce7f5ebcd9340efbc6118af3c560ce Mon Sep 17 00:00:00 2001 From: lemming552 Date: Sat, 24 Mar 2012 09:57:35 -0600 Subject: [PATCH 2/6] sql added for clearing excavators. --- lib/Lacuna.pm | 2 +- lib/Lacuna/DB/Result/Building/Archaeology.pm | 24 +++++++++++++------- var/upgrades/3.0838.sql | 2 +- var/upgrades/3.0845.sql | 1 + var/www/public/changes.txt | 4 ++++ 5 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 var/upgrades/3.0845.sql diff --git a/lib/Lacuna.pm b/lib/Lacuna.pm index 0e62396c..2d6f4f08 100644 --- a/lib/Lacuna.pm +++ b/lib/Lacuna.pm @@ -7,7 +7,7 @@ use Config::JSON; useall __PACKAGE__; -our $VERSION = 3.0844; +our $VERSION = 3.0845; 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/Building/Archaeology.pm b/lib/Lacuna/DB/Result/Building/Archaeology.pm index f3860461..7b7f8d42 100644 --- a/lib/Lacuna/DB/Result/Building/Archaeology.pm +++ b/lib/Lacuna/DB/Result/Building/Archaeology.pm @@ -202,16 +202,24 @@ sub dig_it { if (randint(0,99) < 5) { # This should give an excavator a 1.2% survival each day. Unless on artifact planets. my $message = random_element([ - 'Ph\'nglui Mglw\'nafh Cthulhu R\'lyeh wgah\'nagi fhtagn.', - 'Klaatu Barada Ni*cough*', - 'The brazen temple doors open...', + 'Dave, this conversation can serve no purpose anymore. Goodbye.', + 'Did you notice anything weird a minute ago?', + 'Hasta la vista, baby', + 'Houston.. we have a problem', + 'I say we take off and nuke the site from orbit. It\'s the only way to be sure.', + 'It\'s just a harmless little bunny...', 'It\'s full of stars', - 'This is obviously some strange usage of the word safe that I wasn\'t previously aware of.', + 'Looks like I picked the wrong week to stop sniffing glue.', + 'Klaatu Barada Ni*cough*', 'Oh no, not again.', + 'Oops? What oops? No oops!', + 'Ph\'nglui Mglw\'nafh Cthulhu R\'lyeh wgah\'nagi fhtagn.', 'That\'s it man, game over man, game over!', - 'I say we take off and nuke the site from orbit. It\'s the only way to be sure.', + 'The brazen temple doors open...', + 'There are things in the mist', + 'They\'re here already! You\'re next! You\'re next, You\'re next...!', + 'This is obviously some strange usage of the word safe that I wasn\'t previously aware of.', 'Trust me, I\'m trained to do this.', - 'Oops? What oops? No oops!', ]); $result = { message => $message, @@ -356,9 +364,9 @@ sub can_you_dig_it { my $resource = int(5/2 * $level); # 2-75% my $artifact = 0; if (!$arch && $body->buildings->count) { - $artifact = 15; + $artifact = 14; } - my $destroy = $arch ? 0 : 2; + my $destroy = $arch ? 0 : 1; $destroy += $artifact; my $most = $plan + $glyph + $artifact + $destroy; # resources get cut down if over 100% diff --git a/var/upgrades/3.0838.sql b/var/upgrades/3.0838.sql index e973e7f3..14a22d4a 100644 --- a/var/upgrades/3.0838.sql +++ b/var/upgrades/3.0838.sql @@ -7,4 +7,4 @@ CREATE TABLE `excavators` ( ); alter table empire add column `skip_excavator_artifact` tinyint NOT NULL default 0; alter table empire add column `skip_excavator_destroyed` tinyint NOT NULL default 0; -alter table building add column `last_check` datetime NOT NULL default '2012-01-31 15:00:00'; +alter table building add column `last_check` datetime NOT NULL default '2012-03-23 23:00:00'; diff --git a/var/upgrades/3.0845.sql b/var/upgrades/3.0845.sql new file mode 100644 index 00000000..ddeddd28 --- /dev/null +++ b/var/upgrades/3.0845.sql @@ -0,0 +1 @@ +delete from ships where type = 'excavator'; diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 7d10cb0d..17dc8b93 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -1,3 +1,7 @@ +3.0845: + - Mod: A few more messages added to excavator destroyed. + - Mod: Destruction odds modified down. + 3.0844: - Mod: Excavator plan returns adjusted slightly. - Mod: Trades are 0.1 to 100.0 inclusive. Rounding happens after 1 decimal point. -- 2.51.2 From 177b09c893b02097a77c8bc2aaee94d0a98acc9a Mon Sep 17 00:00:00 2001 From: lemming552 Date: Mon, 26 Mar 2012 23:22:29 -0600 Subject: [PATCH 3/6] Fixed some messages use of it is. --- lib/Lacuna.pm | 2 +- var/messages/excavator_deployed.txt | 2 +- var/messages/excavator_results.txt | 2 +- var/messages/plan_split_by_forge_failure.txt | 2 +- var/www/public/changes.txt | 3 +++ 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/Lacuna.pm b/lib/Lacuna.pm index 2d6f4f08..0143b0e5 100644 --- a/lib/Lacuna.pm +++ b/lib/Lacuna.pm @@ -7,7 +7,7 @@ use Config::JSON; useall __PACKAGE__; -our $VERSION = 3.0845; +our $VERSION = 3.0846; 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/var/messages/excavator_deployed.txt b/var/messages/excavator_deployed.txt index ee0255d6..9390f5f5 100644 --- a/var/messages/excavator_deployed.txt +++ b/var/messages/excavator_deployed.txt @@ -1,7 +1,7 @@ Excavator Deployed ~~~ The Excavator from {Planet %s %s} has deployed on {Starmap %s %s %s}. -It is now operational and will start sending back it's results. +It is now operational and will start sending back its results. Regards, diff --git a/var/messages/excavator_results.txt b/var/messages/excavator_results.txt index 72aba3e4..35765eae 100644 --- a/var/messages/excavator_results.txt +++ b/var/messages/excavator_results.txt @@ -1,6 +1,6 @@ Excavator Results ~~~ -The Archeology Ministry of {Planet %s %s} has received the following results from it's excavator sites. +The Archeology Ministry of {Planet %s %s} has received the following results from its excavator sites. Regards, diff --git a/var/messages/plan_split_by_forge_failure.txt b/var/messages/plan_split_by_forge_failure.txt index 9beed98a..d12aa627 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 it's operation? +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? Regards, diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 17dc8b93..d14e9b21 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -1,3 +1,6 @@ +3.0846: + - Fix: Fixed inapproriate use of it is. + 3.0845: - Mod: A few more messages added to excavator destroyed. - Mod: Destruction odds modified down. -- 2.51.2 From c69893d18c20c82fe1cc4c15a046fdb8dac5a44e Mon Sep 17 00:00:00 2001 From: lemming552 Date: Wed, 28 Mar 2012 07:14:35 -0600 Subject: [PATCH 4/6] Off by one in glyph selection numbers. --- lib/Lacuna/DB/Result/Building/Archaeology.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Lacuna/DB/Result/Building/Archaeology.pm b/lib/Lacuna/DB/Result/Building/Archaeology.pm index 7b7f8d42..c5c4a630 100644 --- a/lib/Lacuna/DB/Result/Building/Archaeology.pm +++ b/lib/Lacuna/DB/Result/Building/Archaeology.pm @@ -335,7 +335,7 @@ sub found_glyph { $ore_total += $ores{$ore}; } my $base = 0; - my $rnum = randint(1,$ore_total); + my $rnum = randint(0,$ore_total); my $glyph = "error"; for my $ore (ORE_TYPES) { if ($rnum < $ores{$ore} + $base) { -- 2.51.2 From 3e654320dc9e784ca21ceee4f93dd95c17b131bc Mon Sep 17 00:00:00 2001 From: lemming552 Date: Fri, 30 Mar 2012 14:03:09 -0600 Subject: [PATCH 5/6] Closed loophole allowing plan making without using up glyphs. --- lib/Lacuna/DB/Result/Building/Archaeology.pm | 7 +++++-- var/www/public/changes.txt | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Lacuna/DB/Result/Building/Archaeology.pm b/lib/Lacuna/DB/Result/Building/Archaeology.pm index c5c4a630..5413d2d6 100644 --- a/lib/Lacuna/DB/Result/Building/Archaeology.pm +++ b/lib/Lacuna/DB/Result/Building/Archaeology.pm @@ -263,7 +263,7 @@ sub found_plan { } } } - elsif ($rand_cat < 10) { + elsif ($rand_cat < 14) { $class = random_element($plan_types->{natural}); $plus = randint(1, int($level/6)+1) if (randint(0,100) < int($level/2)); } @@ -566,7 +566,10 @@ before finish_work => sub { sub make_plan { my ($self, $ids) = @_; unless (ref $ids eq 'ARRAY' && scalar(@{$ids}) < 5) { - confess [1009, 'It is not possible to combine more than 4 glyphs.']; + confess [1009, 'It is not possible to combine more than 4 glyphs.']; + } + if (grep {/\D/} @{$ids}) { + confess [1009, 'Bad data format for glyph ids.']; } my @glyph_names; diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index d14e9b21..900e0016 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -1,5 +1,6 @@ 3.0846: - Fix: Fixed inapproriate use of it is. + - Fix: Closed API loophole. 3.0845: - Mod: A few more messages added to excavator destroyed. -- 2.51.2 From 20cc4e5024a19f9c57583e2fc72a811069c29ca4 Mon Sep 17 00:00:00 2001 From: lemming552 Date: Fri, 30 Mar 2012 15:18:36 -0600 Subject: [PATCH 6/6] Added excavators travelling to view_excavator. --- lib/Lacuna/DB/Result/Building/Archaeology.pm | 10 +++++++--- lib/Lacuna/RPC/Building/Archaeology.pm | 5 ++++- var/www/public/changes.txt | 3 ++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/Lacuna/DB/Result/Building/Archaeology.pm b/lib/Lacuna/DB/Result/Building/Archaeology.pm index 5413d2d6..e1bace8a 100644 --- a/lib/Lacuna/DB/Result/Building/Archaeology.pm +++ b/lib/Lacuna/DB/Result/Building/Archaeology.pm @@ -467,14 +467,18 @@ sub can_add_excavator { confess [1010, $body->name.' was colonized since we launched our excavator.']; } # excavator count for archaeology - my $count = $self->excavators->count; + my $digging = $self->excavators->count; + my $count = $digging; + my $travel; unless ($on_arrival) { - $count += Lacuna->db->resultset('Lacuna::DB::Result::Ships') + $travel = Lacuna->db->resultset('Lacuna::DB::Result::Ships') ->search({type=>'excavator', task=>'Travelling',body_id=>$self->body_id})->count; + $count += $travel; } my $max_e = $self->max_excavators; if ($count >= $max_e) { - confess [1009, 'Already at the maximum number of excavators allowed at this Archaeology level.']; + my $string = "Max Excavators allowed at this Archaeology level is $max_e. You have $digging at sites, and $travel on their way."; + confess [1009, $string]; } # Allowed one per empire per body. diff --git a/lib/Lacuna/RPC/Building/Archaeology.pm b/lib/Lacuna/RPC/Building/Archaeology.pm index dcb594b1..fc539681 100644 --- a/lib/Lacuna/RPC/Building/Archaeology.pm +++ b/lib/Lacuna/RPC/Building/Archaeology.pm @@ -109,6 +109,8 @@ sub view_excavators { resource => $chances->{resource}, }; my $excavators = $building->excavators; + my $travel = Lacuna->db->resultset('Lacuna::DB::Result::Ships') + ->search({type=>'excavator', task=>'Travelling',body_id=>$building->body_id})->count; while (my $excav = $excavators->next) { my $body = $excav->body; my $chances = $building->can_you_dig_it($body, $level, 0); @@ -124,7 +126,8 @@ sub view_excavators { return { excavators => \@sites, max_excavators => $building->max_excavators, - status => $self->format_status($empire, $building->body), + travelling => $travel, + status => $self->format_status($empire, $building->body), }; } diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 900e0016..5691544a 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -1,6 +1,7 @@ 3.0846: - - Fix: Fixed inapproriate use of it is. + - Fix: Fixed inapproriate use of it is in several files. - Fix: Closed API loophole. + - Fix: Added excavators travelling to view_excavator method. 3.0845: - Mod: A few more messages added to excavator destroyed. -- 2.51.2