Skip to content

Commit

Permalink
Updated jackpot routines.
Browse files Browse the repository at this point in the history
  • Loading branch information
lemming552 committed Feb 1, 2014
1 parent 99bde85 commit e995abe
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 14 deletions.
2 changes: 1 addition & 1 deletion bin/jackpot/hourly_update.pl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
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;
Expand Down
3 changes: 1 addition & 2 deletions bin/run_hourly.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
119 changes: 109 additions & 10 deletions lib/Lacuna/AI/Jackpot.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 => (
Expand Down Expand Up @@ -43,25 +44,25 @@ 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],
['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::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],
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/Lacuna/DB/Result/Spies.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit e995abe

Please sign in to comment.