X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=scripts%2Fstats.pl;h=bcac7fe8f81274b2d182b71b677db8728e64b436;hb=721d34ecc1ac357cd325c08790ca41c6218de7d5;hp=3d4222e13ea300a6bc13a0c295d2e37c47d42d0f;hpb=c643b311c8f134a59625192b900aa28b3f12d4f1;p=ndwebbie.git diff --git a/scripts/stats.pl b/scripts/stats.pl index 3d4222e..bcac7fe 100755 --- a/scripts/stats.pl +++ b/scripts/stats.pl @@ -26,28 +26,24 @@ use DBI; use DBD::Pg qw(:pg_types); use LWP::Simple; +use lib qw{/var/www/ndawn/}; +use ND::DB; + +our $dbh = ND::DB::DB(); -$0 =~ /(.*\/)[^\/]/; -my $dir = $1; -our $dbh; -for my $file ("/home/whale/db.pl") -{ - unless (my $return = do $file){ - warn "couldn't parse $file: $@" if $@; - warn "couldn't do $file: $!" unless defined $return; - warn "couldn't run $file" unless $return; - } -} $dbh->do("SET CLIENT_ENCODING TO 'LATIN1';"); +my %classes = (Fighter => 'Fi', Corvette => 'Co', Frigate => 'Fr', Destroyer => 'De', Cruiser => 'Cr', Battleship => 'Bs'); + my $file = get("http://game.planetarion.com/manual.php?page=stats"); $dbh->begin_work; -my $st = $dbh->prepare(q{INSERT INTO ship_stats (name,"class",target,"type",init,guns,armor,damage,eres,metal,crystal,eonium,race) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)}); -while ($file =~ /((?:\w| )+)<\/td>