1 package NDWeb::Controller::CovOp;
5 use parent 'Catalyst::Controller';
9 NDWeb::Controller::CovOp - Catalyst Controller
24 sub index :Path :Args(0) {
25 my ( $self, $c ) = @_;
26 $c->stash( where => q{AND max_bank_hack > 60000
27 ORDER BY max_bank_hack DESC, minalert ASC});
31 sub distwhores : Local {
32 my ( $self, $c ) = @_;
33 $c->stash( where => qq{AND distorters > 0
34 ORDER BY distorters DESC, minalert ASC});
38 sub marktarget : Local {
39 my ( $self, $c, $target ) = @_;
41 my $update = $dbh->prepare(q{INSERT INTO covop_attacks (uid,id,tick) VALUES(?,?,tick())});
43 $update->execute($c->user->id,$target);
45 $c->forward('/redirect');
49 my ( $self, $c ) = @_;
52 my $query = $dbh->prepare(q{SELECT id, coords, metal, crystal, eonium
53 , covop_alert(seccents,structures,size,guards,gov,0) AS minalert
54 , covop_alert(seccents,structures,size,guards,gov,50) AS maxalert
55 , distorters,gov,pstick,dstick
56 , max_bank_hack,hack15,co.tick AS lastcovop
57 FROM (SELECT p.id,coords(x,y,z),size, metal,crystal,eonium,guards
58 ,seccents,NULLIF(ds.total::integer,0) AS structures,distorters
59 ,max_bank_hack(metal,crystal,eonium,p.value,c.value,5)
60 ,max_bank_hack(metal,crystal,eonium,p.value,c.value,15) AS hack15
61 , planet_status, relationship,gov,ps.tick AS pstick, ds.tick AS dstick
62 FROM current_planet_stats p
63 LEFT OUTER JOIN current_planet_scans ps ON p.id = ps.planet
64 LEFT OUTER JOIN current_development_scans ds ON p.id = ds.planet
65 CROSS JOIN (SELECT value FROM current_planet_stats WHERE id = $1) c
67 LEFT OUTER JOIN (SELECT id,max(tick) AS tick FROM covop_attacks GROUP BY id) co USING (id)
68 WHERE (metal IS NOT NULL OR seccents IS NOT NULL)
69 AND (NOT planet_status IN ('Friendly','NAP'))
70 AND (relationship IS NULL OR NOT relationship IN ('Friendly','NAP'))
71 } . $c->stash->{where});
72 $query->execute($c->user->planet);
74 $c->stash(targets => $query->fetchall_arrayref({}));
76 $c->stash(template => 'covop/index.tt2');
80 Michael Andreen (harv@ruin.nu)