sc: option to order by hp
[sheet.git] / sc.plp
diff --git a/sc.plp b/sc.plp
index 8f512164cc4c8a1ab0bcb34d38c3f7f84389b42e..711e4203e82617da25e7f6283889242f07d07717 100644 (file)
--- a/sc.plp
+++ b/sc.plp
@@ -98,7 +98,7 @@ sub coltoggle {
        <th class="val time"><:= coltoggle(qw'build cost') :></th>
        <th class="unit" colspan="2"><:= coltoggle(qw'size size') :></th>
        <th class="unit" colspan="2">attr</th>
        <th class="val time"><:= coltoggle(qw'build cost') :></th>
        <th class="unit" colspan="2"><:= coltoggle(qw'size size') :></th>
        <th class="unit" colspan="2">attr</th>
-       <th class="val unit-hp">HP</th>
+       <th class="val unit-hp"><:= coltoggle(HP => 'hp') :></th>
        <th class="val unit-shield">shield</th>
        <th class="val unit-armor" title="armor">⛨</th>
        <th class="val hurt"><:= coltoggle(attack => 'attack') :></th>
        <th class="val unit-shield">shield</th>
        <th class="val unit-armor" title="armor">⛨</th>
        <th class="val hurt"><:= coltoggle(attack => 'attack') :></th>
@@ -346,6 +346,11 @@ sub showrangeint {
                if ($get{order} eq 'name') {
                        @rows = sort {$a->{name} cmp $b->{name}} @rows;
                }
                if ($get{order} eq 'name') {
                        @rows = sort {$a->{name} cmp $b->{name}} @rows;
                }
+               elsif ($get{order} eq 'hp') {
+                       $_->{order} = (
+                               $_->{hp}*1.01 + $_->{armor} + $_->{shield} + $_->{size}/1024,
+                       ) for @rows;
+               }
                elsif ($get{order} eq 'cost') {
                        $_->{order} = (
                                $_->{gas}*1.5 + $_->{min} + $_->{pop}/8 + $_->{build}/256/8
                elsif ($get{order} eq 'cost') {
                        $_->{order} = (
                                $_->{gas}*1.5 + $_->{min} + $_->{pop}/8 + $_->{build}/256/8