]> ruin.nu Git - ndwebbie.git/commitdiff
Updated covop page to show 5 man bank hack + accurate values
authorMichael Andreen <harv@ruin.nu>
Mon, 17 Nov 2008 20:33:22 +0000 (21:33 +0100)
committerMichael Andreen <harv@ruin.nu>
Mon, 17 Nov 2008 20:33:22 +0000 (21:33 +0100)
database/covophack.sql [new file with mode: 0644]
lib/NDWeb/Controller/CovOp.pm
root/src/covop/index.tt2

diff --git a/database/covophack.sql b/database/covophack.sql
new file mode 100644 (file)
index 0000000..2914840
--- /dev/null
@@ -0,0 +1,16 @@
+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;
index d114726bd440525899d205ad9e62fefe25b751c7..8ccc41689ee1082f6967add2e639c3a54ca37236 100644 (file)
@@ -23,8 +23,8 @@ Catalyst Controller.
 
 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');
 }
 
@@ -53,15 +53,16 @@ sub list : Private {
                , 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)
@@ -70,11 +71,7 @@ sub list : Private {
                } . $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');
 }
index 542f318a76ef41acd491cd100361f50cabe78d37..89f2871472f81d80ca35e842eca19b6d1540a792 100644 (file)
@@ -15,7 +15,7 @@
        <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) %]
@@ -30,7 +30,8 @@
        <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>