Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Trying to write a useful script FAR TOO EARLY!
- use strict;
- use warnings;
- use Data::Dumper;
- use FindBin;
- use lib "$FindBin::Bin/../../lib";
- use List::Util qw(min max);
- use List::MoreUtils qw( uniq );
- use Games::Lacuna::Client ();
- my $cfg_file = shift(@ARGV) || '../lacuna.yml';
- unless ( $cfg_file and -e $cfg_file ) {
- $cfg_file = eval{
- require File::HomeDir;
- require File::Spec;
- my $dist = File::HomeDir->my_dist_config('Games-Lacuna-Client');
- File::Spec->catfile(
- $dist,
- 'login.yml'
- ) if $dist;
- };
- unless ( $cfg_file and -e $cfg_file ) {
- die "Did not provide a config file";
- }
- }
- my $client = Games::Lacuna::Client->new(
- cfg_file => $cfg_file,
- # debug => 1,
- );
- # Load the planets
- my $empire = $client->empire->get_status->{empire};
- # reverse hash, to key by name instead of id
- my %planets = map { $empire->{planets}{$_}, $_ } keys %{ $empire->{planets} };
- # Scan each planet
- foreach my $name ( sort keys %planets ) {
- # Load planet data
- my $planet = $client->body( id => $planets{$name} );
- my $result = $planet->get_buildings;
- my $body = $result->{status}->{body};
- my $buildings = $result->{buildings};
- my $arch = List::Util::first {
- $buildings->{$_}->{url} eq '/archaeology'
- }
- keys %$buildings;
- next unless defined $arch;
- my $level = $buildings->{$arch}{level};
- # Print out the planet name and archaeology level
- print "$name\n";
- print "$level\n";
- my @build;
- push @build, $buildings->{$arch} if $level < 15;
- }
Add Comment
Please, Sign In to add comment