Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

glyphinator: make 3.01 compatible

 * No more captcha!
 * Attack ships are no longer necessary to avoid inhabited planets.
 * No RPC is required to determine inhabited status anymore.
  • Loading branch information...
commit d33b02a2ee7759300a6f5c765a2d853e3caeeb89 1 parent 5fdb219
Dave Olszewski cxreg authored b2gills committed

Showing 1 changed file with 10 additions and 67 deletions. Show diff stats Hide diff stats

  1. +10 67 examples/glyphinator.pl
77 examples/glyphinator.pl
@@ -161,7 +161,6 @@
161 161 $glc = Games::Lacuna::Client->new(
162 162 cfg_file => $opts{config} || "$FindBin::Bin/../lacuna.yml",
163 163 rpc_sleep => 1,
164   - prompt_captcha => 1,
165 164 );
166 165
167 166 output("Starting up at " . localtime() . "\n");
@@ -192,9 +191,6 @@
192 191 }
193 192
194 193 if (defined $opts{continuous}) {
195   - diag("WARNING!!!!! Captcha prompt will cause script hang if you are not here to answer!\n")
196   - if $opts{'send-excavators'};
197   -
198 194 my $sleep = $opts{continuous} || 360;
199 195
200 196 if ($opts{'do-digs'} and $status->{digs}) {
@@ -696,15 +692,6 @@ sub determine_ore {
696 692
697 693 ## Excavators ##
698 694
699   -my %attack_ships;
700   -BEGIN {
701   - %attack_ships = map { $_ => 1 } qw/
702   - bleeder observatory_seeker spaceport_seeker
703   - placebo placebo2 placebo3 placebo4 placebo5 placebo6
704   - scow security_ministry_seeker
705   - snark snark2 snark3 spy_pod spy_shuttle thud
706   - /;
707   -}
708 695 sub send_excavators {
709 696 PLANET:
710 697
@@ -757,62 +744,10 @@ sub send_excavators {
757 744 for (@dests) {
758 745 my ($dest_name, $x, $y, $distance, $zone, $checked_epoch) = @$_;
759 746
760   - my $recently_checked = time() - $checked_epoch < $RECENT_CHECK;
  747 + # Get the next available excavator
761 748 my $ex = $status->{ready}{$planet}[0];
762 749
763   - # Check even harder to see if inhabited, if we want to avoid those
764   - if (!$recently_checked and !$batch->{'inhabited-ok'}) {
765   - my $ships;
766   - my $ok = eval {
767   - $ships = $port->get_ships_for($status->{planets}{$planet}, {x => $x, y => $y});
768   - return 1;
769   - };
770   - unless ($ok) {
771   - if (my $e = Exception::Class->caught('LacunaRPCException')) {
772   - if ($e->code eq '1002') {
773   - # Empty orbit, update db and try again
774   - output("$dest_name is an empty orbit, trying again...\n");
775   - mark_orbit_empty($x, $y);
776   -
777   - $need_more++;
778   - next;
779   - }
780   -
781   - diag("Unknown error sending excavator from $planet to $dest_name: $e\n");
782   - }
783   - else {
784   - my $e = Exception::Class->caught();
785   - diag("Unknown error sending excavator from $planet to $dest_name: $e\n");
786   - }
787   - }
788   -
789   - my @avail_attack_ships = grep { $attack_ships{$_->{type}} }
790   - @{$ships->{available}};
791   - my @unavail_attack_ships = grep { $attack_ships{$_->{ship}{type}} }
792   - @{$ships->{unavailable}};
793   -
794   - if (@avail_attack_ships) {
795   - output("$dest_name is an occupied planet, trying again...\n");
796   - mark_orbit_occupied($x, $y);
797   - $need_more++;
798   - next;
799   - } elsif(@unavail_attack_ships) {
800   - # 1013 - Can only be sent to inhabited planets (uninhabited planet)
801   - # 1009 - Can only be sent to planets and stars (asteroid)
802   - if (!grep { $_->{reason}[0] eq '1013' or $_->{reason}[0] eq '1009'}
803   - @unavail_attack_ships) {
804   - output("$dest_name is an occupied planet, trying again...\n");
805   - mark_orbit_occupied($x, $y);
806   - $need_more++;
807   - next;
808   - }
809   - } else {
810   - unless ($warned_cant_verify++) {
811   - diag("$planet has no spy pods, scows, or attack ships, cannot verify if this planet is inhabited!\n");
812   - }
813   - }
814   - }
815   -
  750 + # Only try each destination once
816 751 $skip{$dest_name}++;
817 752
818 753 if ($opts{'dry-run'}) {
@@ -845,6 +780,14 @@ sub send_excavators {
845 780 $need_more++;
846 781 next;
847 782 }
  783 +
  784 + if ($e->code eq '1016' and !$batch->{'inhabited-ok'}) {
  785 + # Don't mark as inhabited because we don't actually know if the destination was
  786 + # inhabited, or just protected
  787 + output("$dest_name would have triggered defenses, trying again...\n");
  788 + $need_more++;
  789 + next;
  790 + }
848 791 }
849 792 else {
850 793 my $e = Exception::Class->caught();

0 comments on commit d33b02a

Please sign in to comment.
Something went wrong with that request. Please try again.