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, hack5 DESC, hack15 DESC, minalert,x,y,z});
32 my ( $self, $c ) = @_;
33 $c->stash( where => qq{AND minalert < 70
34 ORDER BY minalert, max_bank_hack DESC, hack5 DESC, hack15 DESC,x,y,z});
38 sub distwhores : Local {
39 my ( $self, $c ) = @_;
40 $c->stash( where => qq{AND distorters > 0
41 ORDER BY distorters DESC, minalert, x,y,z});
45 sub marktarget : Local {
46 my ( $self, $c, $target ) = @_;
48 my $update = $dbh->prepare(q{INSERT INTO covop_attacks (uid,id,tick) VALUES(?,?,tick())});
50 $update->execute($c->user->id,$target);
52 $c->forward('/redirect');
56 my ( $self, $c ) = @_;
59 my $query = $dbh->prepare(q{SELECT *
60 FROM (SELECT p.id,coords(x,y,z),x,y,z,size, metal,crystal,eonium
62 ,covop_alert(seccents,ds.total,size,guards,gov,0) AS minalert
63 ,covop_alert(seccents,ds.total,size,guards,gov,50) AS maxalert
64 ,max_bank_hack(500000,500000,500000,p.value,c.value,5)
65 ,max_bank_hack(metal,crystal,eonium,p.value,c.value,5) AS hack5
66 ,max_bank_hack(metal,crystal,eonium,p.value,c.value,15) AS hack15
67 , planet_status, relationship,gov,ps.tick AS pstick, ds.tick AS dstick
68 FROM current_planet_stats p
69 LEFT OUTER JOIN current_planet_scans ps ON p.id = ps.planet
70 LEFT OUTER JOIN current_development_scans ds ON p.id = ds.planet
71 CROSS JOIN (SELECT value FROM current_planet_stats WHERE id = $1) c
73 LEFT OUTER JOIN (SELECT id,max(tick) AS lastcovop FROM covop_attacks
74 GROUP BY id) co USING (id)
75 WHERE (metal IS NOT NULL OR distorters IS NOT NULL)
76 AND (NOT planet_status IN ('Friendly','NAP'))
77 AND (relationship IS NULL OR NOT relationship IN ('Friendly','NAP'))
78 } . $c->stash->{where});
79 $query->execute($c->user->planet);
81 $c->stash(targets => $query->fetchall_arrayref({}));
83 $c->stash(template => 'covop/index.tt2');
87 Michael Andreen (harv@ruin.nu)