--- /dev/null
+CREATE OR REPLACE FUNCTION max_bank_hack(metal bigint, crystal bigint, eonium bigint, tvalue integer, value integer, agents integer) RETURNS integer
+ AS $_$
+SELECT LEAST(2000.0*$6*$4/$5, $1*0.10, $6*10000.0)::integer
+ + LEAST(2000.0*$6*$4/$5, $2*0.10, $6*10000.0)::integer
+ + LEAST(2000.0*$6*$4/$5, $3*0.10, $6*10000.0)::integer
+$_$
+ LANGUAGE sql IMMUTABLE;
+
+
+CREATE OR REPLACE FUNCTION max_bank_hack(metal bigint, crystal bigint, eonium bigint, tvalue integer, value integer) RETURNS integer
+ AS $_$
+SELECT LEAST(2000.0*15*$4/$5,$1*0.10, 15*10000.0)::integer
+ + LEAST(2000.0*15*$4/$5,$2*0.10, 15*10000.0)::integer
+ + LEAST(2000.0*15*$4/$5,$3*0.10, 15*10000.0)::integer
+$_$
+ LANGUAGE sql IMMUTABLE;
sub index :Path :Args(0) {
my ( $self, $c ) = @_;
- $c->stash( where => q{AND MaxResHack > 130000
- ORDER BY minalert ASC,MaxResHack DESC});
+ $c->stash( where => q{AND max_bank_hack > 60000
+ ORDER BY max_bank_hack DESC, minalert ASC});
$c->forward('list');
}
, covop_alert(seccents,structures,size,guards,gov,0) AS minalert
, covop_alert(seccents,structures,size,guards,gov,50) AS maxalert
, distorters,gov,pstick,dstick
- , MaxResHack,co.tick AS lastcovop
+ , max_bank_hack,hack15,co.tick AS lastcovop
FROM (SELECT p.id,coords(x,y,z),size, metal,crystal,eonium,guards
,seccents,NULLIF(ds.total::integer,0) AS structures,distorters
- ,max_bank_hack(metal,crystal,eonium,p.value
- ,(SELECT value FROM current_planet_stats WHERE id = ?)) AS MaxResHack
+ ,max_bank_hack(metal,crystal,eonium,p.value,c.value,5)
+ ,max_bank_hack(metal,crystal,eonium,p.value,c.value,15) AS hack15
, planet_status, relationship,gov,ps.tick AS pstick, ds.tick AS dstick
FROM current_planet_stats p
LEFT OUTER JOIN current_planet_scans ps ON p.id = ps.planet
LEFT OUTER JOIN current_development_scans ds ON p.id = ds.planet
+ CROSS JOIN (SELECT value FROM current_planet_stats WHERE id = $1) c
) AS foo
LEFT OUTER JOIN (SELECT id,max(tick) AS tick FROM covop_attacks GROUP BY id) co USING (id)
WHERE (metal IS NOT NULL OR seccents IS NOT NULL)
} . $c->stash->{where});
$query->execute($c->user->planet);
- my @targets;
- while (my $target = $query->fetchrow_hashref){
- push @targets,$target;
- }
- $c->stash(targets => \@targets);
+ $c->stash(targets => $query->fetchall_arrayref({}));
$c->stash(template => 'covop/index.tt2');
}
<tr>
<th>Coords</th><th>Tick</th><th>Metal</th><th>Crystal</th><th>Eonium</th>
<th>Gov</th><th>Alert</th><th>Tick</th><th>Dists</th>
- <th>Max (15 agents)</th><th>Last covop (tick)</th>
+ <th>Max (5 agents)</th><th>(15 agents)</th><th>Last covop (tick)</th>
</tr>
[% debug(targets.size) %]
<td>[% t.minalert %] - [% t.maxalert %]</td>
<td[% PROCESS style tick=t.dstick%]>[% t.dstick %]</td>
<td>[% t.distorters %]</td>
- <td>[% t.maxreshack %]</td>
+ <td>[% t.max_bank_hack %]</td>
+ <td>[% t.hack15 %]</td>
<td>[% t.lastcovop %]</td>
<td><a href="[% c.uri_for('marktarget', t.id) %]">Did CovOp this tick</a></td>
</tr>