sc: compare attack order by dps
authorMischa POSLAWSKY <perl@shiar.org>
Sat, 21 Apr 2018 18:24:36 +0000 (20:24 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Thu, 10 May 2018 14:49:06 +0000 (16:49 +0200)
Link by more descriptive "attack" column despite this.

sc.plp

diff --git a/sc.plp b/sc.plp
index 88ff4b1fa4a66a1b6f808231b7ad280c2797b1c6..a721035d215ad2c3ec9a93744b3aa66548efb6dc 100644 (file)
--- a/sc.plp
+++ b/sc.plp
@@ -101,8 +101,8 @@ sub coltoggle {
        <th class="val unit-hp">HP</th>
        <th class="val unit-shield">shield</th>
        <th class="val unit-armor" title="armor">⛨</th>
-       <th class="val hurt">attack</th>
-       <th class="hurt hurtrel"><:= coltoggle(qw'dps attack 1') :></th>
+       <th class="val hurt"><:= coltoggle(attack => 'attack') :></th>
+       <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>
@@ -360,8 +360,10 @@ sub showrangeint {
                elsif ($get{order} eq 'attack') {
                        $_->{order} = $_->{hp} / 1024 + $_->{shield} / 1008 + max(
                                map {
-                                       ($_->{damage} + $_->{upgrade} * 3)
-                                       * ($_->{count} // 1) / ($_->{cooldown} // 1)
+                                       ($_->{dps} ? $_->{dps}->[-1] :
+                                               ($_->{damage} + $_->{upgrade} * 3)
+                                               * ($_->{count} // 1) / ($_->{cooldown} // 1)
+                                       )
                                        * ($_->{splash} ? 1.01 : 1)
                                        * ($_->{type} eq 'implosive' ? .96 : 1)
                                        * ($_->{type} eq 'explosive' ? .98 : 1)