From: Michael Andreen Date: Fri, 13 Jun 2008 12:14:51 +0000 (+0200) Subject: Parse factory usage X-Git-Url: https://ruin.nu/git/?p=ndwebbie.git;a=commitdiff_plain;h=1ac7abba88180254eaf3a65e1aded1c6d7c42576 Parse factory usage --- diff --git a/scripts/scans.pl b/scripts/scans.pl index 7eff622..b4fe22d 100755 --- a/scripts/scans.pl +++ b/scripts/scans.pl @@ -78,6 +78,8 @@ my $addpdata = $dbh->prepare(q{INSERT INTO planet_data (id,tick,scan,rid,amount) $dbh->begin_work or die 'No transaction'; $newscans->execute or die $dbh->errstr; $dbh->pg_savepoint('scans') or die "No savepoint"; + +my %production = (None => 0, Low => 35, Medium => 65, High => 100); while (my $scan = $newscans->fetchrow_hashref){ my $file = get("http://game.planetarion.com/showscan.pl?scan_id=$scan->{scan_id}"); next unless defined $file; @@ -115,14 +117,14 @@ while (my $scan = $newscans->fetchrow_hashref){ $addpdata->execute($planet,$tick,$scan->{id} ,'resource',$1, $res) or die $dbh->errstr; } - #if($file =~ m{"center">([^<]+)([^<]+)([^<]+)}){ - # $addpdata->execute($planet,$tick,$scan->{id} - # ,'planet','Light Usage', $1) or die $dbh->errstr; - # $addpdata->execute($planet,$tick,$scan->{id} - # ,'planet','Medium Usage', $2) or die $dbh->errstr; - # $addpdata->execute($planet,$tick,$scan->{id} - # ,'planet','Heavy Usage', $3) or die $dbh->errstr; - #} + if($file =~ m{([A-Z][a-z]+)([A-Z][a-z]+)([A-Z][a-z]+)}){ + $addpdata->execute($planet,$tick,$scan->{id} + ,'planet','Light Usage', $production{$1}) or die $dbh->errstr; + $addpdata->execute($planet,$tick,$scan->{id} + ,'planet','Medium Usage', $production{$2}) or die $dbh->errstr; + $addpdata->execute($planet,$tick,$scan->{id} + ,'planet','Heavy Usage', $production{$3}) or die $dbh->errstr; + } if($file =~ m{([\d,]+)}){ my $res = $1; $res =~ s/,//g;