From e995abe09ce1e8c63bb61170b8c23b4eb3bbfeea Mon Sep 17 00:00:00 2001 From: Mark Lemming Date: Sat, 1 Feb 2014 11:40:32 -0700 Subject: [PATCH] Updated jackpot routines. --- bin/jackpot/hourly_update.pl | 2 +- bin/run_hourly.sh | 3 +- lib/Lacuna/AI/Jackpot.pm | 119 +++++++++++++++++++++++++++++++--- lib/Lacuna/DB/Result/Spies.pm | 2 +- 4 files changed, 112 insertions(+), 14 deletions(-) diff --git a/bin/jackpot/hourly_update.pl b/bin/jackpot/hourly_update.pl index 1b196d0b..d188ca26 100644 --- a/bin/jackpot/hourly_update.pl +++ b/bin/jackpot/hourly_update.pl @@ -15,7 +15,7 @@ out('Started'); my $start = time; out('Loading AI'); -my $ai = Lacuna::AI::Saben->new; +my $ai = Lacuna::AI::Jackpot->new; out('Running Updates'); $ai->run_all_hourly_colony_updates; diff --git a/bin/run_hourly.sh b/bin/run_hourly.sh index 30401aac..894dd770 100755 --- a/bin/run_hourly.sh +++ b/bin/run_hourly.sh @@ -3,13 +3,12 @@ export PATH=/data/apps/bin:$PATH cd /data/Lacuna-Server/bin perl clean_up_empires.pl >>/tmp/hourly.log 2>>/tmp/hourly.log perl sanitize_ss.pl >>/tmp/hourly.log 2>>/tmp/hourly.log -# perl summarize_server.pl >>/tmp/hourly.log 2>>/tmp/hourly.log perl summarize_economy.pl >>/tmp/hourly.log 2>>/tmp/hourly.log perl generate_news_feeds.pl >>/tmp/news_feeds.log 2>>/tmp/news_feeds.log -#perl tick_spies.pl >>/tmp/hourly.log 2>>/tmp/hourly.log perl tick_parliament.pl >>/tmp/hourly.log 2>>/tmp/hourly.log perl add_missions.pl >>/tmp/hourly.log 2>>/tmp/hourly.log perl clean_up_market.pl >>/tmp/hourly.log 2>>/tmp/hourly.log +perl jackpot/hourly_update.pl >>/tmp/hourly.log 2>>/tmp/hourly.log perl trelvestian/hourly_update.pl >>/tmp/hourly.log 2>>/tmp/hourly.log perl diablotin/hourly_update.pl >>/tmp/hourly.log 2>>/tmp/hourly.log perl saben/hourly_update.pl >>/tmp/hourly.log 2>>/tmp/hourly.log diff --git a/lib/Lacuna/AI/Jackpot.pm b/lib/Lacuna/AI/Jackpot.pm index 3f9e1313..e07d2b56 100644 --- a/lib/Lacuna/AI/Jackpot.pm +++ b/lib/Lacuna/AI/Jackpot.pm @@ -5,6 +5,7 @@ use utf8; no warnings qw(uninitialized); extends 'Lacuna::AI'; +use Lacuna::Constants qw(ORE_TYPES); use constant empire_id => -4; has viable_colonies => ( @@ -43,15 +44,15 @@ sub empire_defaults { sub colony_structures { return ( - ['Lacuna::DB::Result::Building::Waste::Sequestration', 16], + ['Lacuna::DB::Result::Building::Waste::Sequestration', 20], ['Lacuna::DB::Result::Building::Intelligence', 10], ['Lacuna::DB::Result::Building::Security', 15], ['Lacuna::DB::Result::Building::Shipyard', 10], - ['Lacuna::DB::Result::Building::SpacePort', 20], - ['Lacuna::DB::Result::Building::SpacePort', 20], - ['Lacuna::DB::Result::Building::SpacePort', 20], - ['Lacuna::DB::Result::Building::SpacePort', 20], - ['Lacuna::DB::Result::Building::SpacePort', 20], + ['Lacuna::DB::Result::Building::SpacePort', 15], + ['Lacuna::DB::Result::Building::SpacePort', 15], + ['Lacuna::DB::Result::Building::SpacePort', 15], + ['Lacuna::DB::Result::Building::SpacePort', 15], + ['Lacuna::DB::Result::Building::SpacePort', 15], ['Lacuna::DB::Result::Building::Observatory',15], ['Lacuna::DB::Result::Building::Archaeology',10], ['Lacuna::DB::Result::Building::Trade', 15], @@ -59,9 +60,9 @@ sub colony_structures { ['Lacuna::DB::Result::Building::SAW',20], ['Lacuna::DB::Result::Building::SAW',20], ['Lacuna::DB::Result::Building::SAW',20], - ['Lacuna::DB::Result::Building::SAW',20], ['Lacuna::DB::Result::Building::Permanent::Volcano',15], ['Lacuna::DB::Result::Building::Permanent::NaturalSpring',15], + ['Lacuna::DB::Result::Building::Permanent::GratchsGauntlet',15], ['Lacuna::DB::Result::Building::Permanent::InterDimensionalRift',15], ['Lacuna::DB::Result::Building::Permanent::GeoThermalVent',15], ['Lacuna::DB::Result::Building::Permanent::KalavianRuins',15], @@ -104,6 +105,7 @@ sub ship_building_priorities { sub run_hourly_colony_updates { my ($self, $colony) = @_; $self->demolish_bleeders($colony); + $self->reject_badspy($colony); $self->set_defenders($colony); $self->pod_check($colony, 10); $self->reset_stuff($colony); @@ -115,15 +117,112 @@ sub run_hourly_colony_updates { sub reset_stuff { my ($self, $colony) = @_; - my %structures = map { $_[0] => $_[1] } $self->colony_structures; + print "Resetting Buildings\n"; + my %structures = map { $_->[0] => $_->[1] } $self->colony_structures; foreach my $building (@{$colony->building_cache}) { if ($structures{$building->class} and $structures{$building->class} > $building->level ) { - $building->level = $structures{$building->class}; + print "Resetting ".$building->class." to ".$structures{$building->class}." from ".$building->level.".\n"; + $building->level($structures{$building->class}); $building->update; } } -#place plans? + print "Resetting Glyphs\n"; + my $glyphs = $colony->glyph; + my %ghash = map {$_ => 0 } (ORE_TYPES); + while (my $glyph = $glyphs->next) { + $ghash{$glyph->type} += $glyph->quantity; + } + for my $type (ORE_TYPES) { + if ($ghash{$type} < 250) { + $colony->add_glyph($type, 250 - $ghash{$type}); + } + } + print "Resetting Plans\n"; + my $plans = $colony->plan_cache; + my %phash; + for my $plan (@{$plans}) { + my $key = join(":",$plan->class,$plan->level,$plan->extra_build_level); + $phash{$key} = $plan->quantity; + } + print "Checking Plans\n"; + my $qplans = plan_list(); + for my $plan (@{$qplans}) { + my $key = join(":",$plan->{class},$plan->{level},$plan->{extra}); + if (!defined $phash{$key} or $phash{$key} < $plan->{quantity}) { + printf "Adding %d %s\n", $plan->{quantity} - $phash{$key}, $key; + $colony->add_plan($plan->{class}, $plan->{level}, $plan->{extra}, $plan->{quantity} - $phash{$key}); + } + } +} + +sub reject_badspy { + my ($self, $colony) = @_; + + print "Jailing Spies that are too advanced\n"; + my $spies = Lacuna->db->resultset('Spies')->search({ + 'me.on_body_id' => $colony->id, + 'me.empire_id' => {'!=' => $colony->empire_id }, + 'empire.university_level' => { '>' => 15 }, + },{ + join => 'empire', + }); + while (my $spy = $spies->next) { + $spy->go_to_jail; + } +} + +sub plan_list { +return ([ + { "class" => "Lacuna::DB::Result::Building::Permanent::AlgaePond", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::AmalgusMeadow", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::Beach1", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::Beach10", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::Beach11", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::Beach12", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::Beach13", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::Beach2", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::Beach3", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::Beach4", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::Beach5", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::Beach6", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::Beach7", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::Beach8", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::Beach9", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::BeeldebanNest", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::BlackHoleGenerator", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::CitadelOfKnope", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::CrashedShipSite", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::Crater", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::DentonBrambles", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::GasGiantPlatform", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::GeoThermalVent", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::GratchsGauntlet", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::GreatBallOfJunk", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::Grove", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::HallsOfVrbansk", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::InterDimensionalRift", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::JunkHengeSculpture", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::KalavianRuins", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::Lagoon", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::Lake", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::LapisForest", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::LibraryOfJith", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::MalcudField", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::MetalJunkArches", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::NaturalSpring", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::OracleOfAnid", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::PantheonOfHagness", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::PyramidJunkSculpture", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::Ravine", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::RockyOutcrop", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::Sand", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::SpaceJunkPark", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::TempleOfTheDrajilites", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::TerraformingPlatform", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::TheDillonForge", "level" => "1", "extra" => "0", "quantity" => "25" }, + { "class" => "Lacuna::DB::Result::Building::Permanent::Volcano", "level" => "1", "extra" => "0", "quantity" => "25" } +]); } no Moose; diff --git a/lib/Lacuna/DB/Result/Spies.pm b/lib/Lacuna/DB/Result/Spies.pm index 0072599c..0b36d11d 100644 --- a/lib/Lacuna/DB/Result/Spies.pm +++ b/lib/Lacuna/DB/Result/Spies.pm @@ -197,7 +197,7 @@ sub offensive_assignments { skill => 'politics', }, ); - if (eval{$self->can_conduct_advanced_missions}) { + if (eval{$self->can_conduct_advanced_missions} or $self->on_body->empire_id == -4) { push @assignments, ( { task =>'Appropriate Technology', -- 2.51.2