From: Michael Andreen Date: Tue, 12 Dec 2006 11:26:11 +0000 (+0000) Subject: covop targets X-Git-Url: https://ruin.nu/git/?a=commitdiff_plain;h=1b53b46299c5a8a8a89b1c7d916e1234d9d064a8;p=ndwebbie.git covop targets --- diff --git a/covop.pl b/covop.pl new file mode 100644 index 0000000..180a0a4 --- /dev/null +++ b/covop.pl @@ -0,0 +1,67 @@ +#************************************************************************** +# Copyright (C) 2006 by Michael Andreen * +# * +# This program is free software; you can redistribute it and/or modify * +# it under the terms of the GNU General Public License as published by * +# the Free Software Foundation; either version 2 of the License, or * +# (at your option) any later version. * +# * +# This program is distributed in the hope that it will be useful, * +# but WITHOUT ANY WARRANTY; without even the implied warranty of * +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +# GNU General Public License for more details. * +# * +# You should have received a copy of the GNU General Public License * +# along with this program; if not, write to the * +# Free Software Foundation, Inc., * +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * +#**************************************************************************/ + +use strict; + +$ND::TEMPLATE->param(TITLE => 'CovOp Targets'); + +our $BODY; +our $DBH; +our $LOG; + +die "You don't have access" unless isMember(); + +my $show = q{AND ((planet_status IS NULL OR NOT planet_status IN ('Friendly','NAP')) AND (relationship IS NULL OR NOT relationship IN ('Friendly','NAP')))}; +$show = '' if param('show') eq 'all'; +if (param('covop') =~ /^(\d+)$/){ + my $update = $DBH->prepare('UPDATE covop_targets SET covop_by = ?, last_covop = tick() WHERE planet = ? '); + $update->execute($ND::UID,$1); +} + +my $list = ''; +my $where = ''; +if (param('list') eq 'distwhores'){ + $list = '&list=distwhores'; + $where = qq{WHERE dists > 0 $show +ORDER BY dists DESC,COALESCE(sec_centres::float/structures*100,0)ASC} +}else{ + $where = qq{WHERE MaxResHack > 130000 + $show +ORDER BY COALESCE(sec_centres::float/structures*100,0) ASC,MaxResHack DESC,metal+crystal+eonium DESC}; +} + +my $query = $DBH->prepare(qq{SELECT id, coords, metal, crystal, eonium, sec_centres::float/structures*100 AS secs, dists, last_covop, username, MaxResHack +FROM (SELECT p.id,coords(x,y,z), metal,crystal,eonium, + sec_centres,NULLIF(structures,0) AS structures,dists,last_covop, + u.username,max_bank_hack(metal,crystal,eonium,p.value,(SELECT value FROM + current_planet_stats WHERE id = ?)) AS MaxResHack, planet_status, relationship +FROM covop_targets c JOIN current_planet_stats p ON p.id = c.planet + LEFT OUTER JOIN users u ON u.uid = c.covop_by) AS foo + $where}); +$query->execute($ND::PLANET); + +my @targets; +while (my ($id,$coords,$metal,$crystal,$eonium,$seccents,$dists,$lastcovop,$user,$max) = $query->fetchrow){ + push @targets,{Username => $user, Target => $id, Coords => $coords + , Metal => $metal, Crystal => $crystal, Eonium => $eonium, SecCents => $seccents + , Dists => $dists, MaxResHack => $max, LastCovOp => $lastcovop, List => $list}; +} +$BODY->param(Targets => \@targets); + +1; diff --git a/index.pl b/index.pl index 03f62f1..ddc0da7 100755 --- a/index.pl +++ b/index.pl @@ -66,7 +66,7 @@ while (my ($name,$attack,$gid) = $query->fetchrow()){ our $LOG = $DBH->prepare('INSERT INTO log (uid,text) VALUES(?,?)'); my $page = 'main'; -if (param('page') =~ /^(main|check|motd|points)$/){ +if (param('page') =~ /^(main|check|motd|points|covop)$/){ $page = $1; } diff --git a/points.pl b/points.pl index 18f38c3..c75130c 100644 --- a/points.pl +++ b/points.pl @@ -19,7 +19,7 @@ use strict; -$ND::TEMPLATE->param(TITLE => 'Edit MOTD'); +$ND::TEMPLATE->param(TITLE => 'Top Members'); our $BODY; our $DBH; diff --git a/templates/covop.tmpl b/templates/covop.tmpl new file mode 100644 index 0000000..29d36b1 --- /dev/null +++ b/templates/covop.tmpl @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + +
CoordsMetalCrystalEonium% Sec CentresDistsMax (15 agents)Last covop (tick)
()Did CovOp this tick +
diff --git a/templates/skel.tmpl b/templates/skel.tmpl index f7ab881..f3c9946 100644 --- a/templates/skel.tmpl +++ b/templates/skel.tmpl @@ -19,8 +19,8 @@
  • Top members
  • Add intel/scans
  • Launch confirmation
  • -
  • CovOp targets
  • -
  • Distwhores
  • +
  • CovOp targets
  • +
  • Distwhores
  • Top100 planets
  • Request defense