sc: option to order by speed
authorMischa POSLAWSKY <perl@shiar.org>
Sat, 21 Apr 2018 18:25:23 +0000 (20:25 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Thu, 10 May 2018 14:49:06 +0000 (16:49 +0200)
sc.plp

diff --git a/sc.plp b/sc.plp
index a721035d215ad2c3ec9a93744b3aa66548efb6dc..8f512164cc4c8a1ab0bcb34d38c3f7f84389b42e 100644 (file)
--- a/sc.plp
+++ b/sc.plp
@@ -105,7 +105,7 @@ sub coltoggle {
        <th class="hurt hurtrel">dps</th>
        <th class="val unit-range" colspan=3>range</th>
        <th class="val unit-sight">sight</th>
-       <th class="val unit-speed">speed</th>
+       <th class="val unit-speed"><:= coltoggle(speed => 'speed') :></th>
        <th class="unit-magic">specials</th>
 </tr></thead>
 <:
@@ -370,6 +370,12 @@ sub showrangeint {
                                } @{ $_->{attack} }
                        ) for @rows;
                }
+               elsif ($get{order} eq 'speed') {
+                       $_->{order} = (
+                               ($_->{upgraded}->{speed} // $_->{speed}*1.01)
+                               + $_->{sight}/1024 + $_->{detect}/2048
+                       ) for @rows;
+               }
                @rows = sort {$a->{order} <=> $b->{order}} @rows if exists $rows[0]->{order};
        }