Games-Lacuna-Client
view release on metacpan or search on metacpan
examples/glyphinator.pl view on Meta::CPAN
$zone = "$x_zone|$y_zone";
}
push @results, [$dest_name, $row->{x}, $row->{y}, $dist, $zone, $row->{checked_epoch} || 0];
push @$skip, $dest_name;
}
}
return @results;
}
sub update_last_sent {
my ($x, $y) = @_;
my $r = $star_db->do(q{update orbitals set last_excavated = datetime(?,'unixepoch') where x = ? and y = ?}, {}, time(), $x, $y);
unless ($r > 0) {
diag("Warning: could not update orbitals table for body at $x, $y!\n");
}
}
sub mark_orbit_empty {
my ($x, $y) = @_;
examples/map/lib/LacunaMap/DB.pm view on Meta::CPAN
sub max_y {
my $row = LacunaMap::DB->selectrow_arrayref("SELECT MAX(y) FROM stars");
ref($row) && ref($row) eq 'ARRAY' && @$row > 0 && defined($row->[0])
or die "Is the stars database empty? Did you load a database?";
return $row->[0];
}
package LacunaMap::DB::Bodies;
sub update_from_news {
my $class = shift;
my $client = shift;
my $news = shift;
my $updater = sub {
my $news = $_;
my $res = $news->parse_title;
return if not $res;
if ($res->{type} eq 'new colony') {
warn "NEW COLONY";
examples/map/merge_bodies.pl view on Meta::CPAN
process( $old, $new );
$bodies->{ $star_id }{ $name } = $old;
}
else
{
$bodies->{ $star_id }{ $name } = $new;
}
updater( $bodies->{ $star_id }{ $name } );
}
sub updater
{
my $res = shift;
my $bodies = LacunaMap::DB::Bodies->select(
'where star_id = ? and name = ?', $res->{star_id}, $res->{name}
);
if ( not @$bodies )
{
# new entry
delete $res->{updated};
warn "no bodies found in DB, adding\n", Dumper( $res );
examples/merge_probe.pl view on Meta::CPAN
}
return $data;
}
sub ownership_test {
my ($elem, $ename) = @_;
return join(":",$elem->{name}, $elem->{observatory}->{empire},
$elem->{observatory}->{oid}, $elem->{observatory}->{pid}, $ename);
}
sub update_vacate {
my ($curr_m, $updt_m, $curr_e, $updt_e) = @_;
if ($updt_e ne '' and $curr_e ne $updt_e) {
push @{$curr_m}, $updt_e;
}
push @{$curr_m}, @{$updt_m};
my %thash;
for (@{$curr_m}) {
$thash{$_} = 1 if ($_ ne '' and $_ ne "nobody");
}
examples/star_db_util.pl view on Meta::CPAN
output("Inserting star $name at $x, $y\n");
$insert_star ||= $star_db->prepare('insert into stars (id, name, x, y, color, zone, last_checked) values (?,?,?,?,?,?,?)');
$insert_star->execute($id, $name, $x, $y, $color, $zone, $when)
or die "Can't insert star: " . $insert_star->errstr;
}
}
{
my $update_star;
sub update_star {
my ($star) = @_;
my ($x, $y, $name, $color, $zone) = @{$star}{qw/x y name color zone/};
my $when = $star->{last_checked} || strftime "%Y-%m-%d %T", gmtime;
output("Updating star at $x, $y to name $name, color $color, zone $zone\n");
$update_star ||= $star_db->prepare(q{update stars set last_checked = ?, name = ?, color = ?, zone = ? where x = ? and y = ?});
$update_star->execute($when, $name, $color, $zone, $x, $y);
}
}
examples/star_db_util.pl view on Meta::CPAN
$insert_orbital ||= $star_db->prepare($insert_statement);
$insert_orbital->execute(@insert_vars)
or die( "Can't insert orbital: " . $insert_orbital->errstr);
update_empire($body->{empire}) if $body->{empire} and $body->{empire}{name};
}
}
{
my $update_orbital;
sub update_orbital {
my ($body) = @_;
my @body_fields = qw{ type name x y water size };
output(sprintf "Updating %s at %d, %d\n", $body->{'type'}, $body->{'x'}, $body->{'y'});
my $when = $body->{last_checked} || strftime "%Y-%m-%d %T", gmtime;
my $update_statement =
join(", ",
q{update orbitals set last_checked = ? },
examples/star_db_util.pl view on Meta::CPAN
push( @update_vars, $body->{'empire'}->{'id'}, $subtype, $body->{'x'}, $body->{'y'} );
$update_orbital ||= $star_db->prepare($update_statement);
$update_orbital->execute(@update_vars)
or die("Can't update orbital: " . $update_orbital->errstr);
update_empire($body->{empire}) if $body->{empire} and $body->{empire}{name};
}
}
sub update_empire {
my $empire = shift;
return unless defined $empire->{id};
my $exists = $star_db->selectrow_hashref('select * from empires where id = ?', {}, $empire->{id});
unless ($exists) {
output("Inserting empire $empire->{name} ($empire->{id})\n");
$star_db->do('insert into empires (id, name) values (?,?)', {}, $empire->{id}, $empire->{name});
}
}
examples/wr.pl view on Meta::CPAN
---
api_key: the_public_key
empire_name: Name of empire
empire_password: password of empire
server_uri: https://us1.lacunaexpanse.com/
END_USAGE
}
sub update_wr {
my $wr = shift;
my $iwr = shift;
output("checking WR stats for WR $iwr");
my $wr_stat = $wr->view;
my $busy_seconds = $wr_stat->{building}{work}{seconds_remaining};
if ($busy_seconds) {
output("Still busy for $busy_seconds, waiting");
return $busy_seconds+3;
( run in 0.548 second using v1.01-cache-2.11-cpan-4d4bc49f3ae )