sc: lower precedence of hp order
[sheet.git] / sc.plp
diff --git a/sc.plp b/sc.plp
index 6dfa65c3cb1ba57c05d712dacdbc14b19da11412..1c9e7b673f1c4b10108fc8c621e266786ccda8ea 100644 (file)
--- a/sc.plp
+++ b/sc.plp
@@ -24,14 +24,14 @@ my %scvers = (
 
 $Request ||= 'bw';
 $Request = 'lotv' if $Request eq '2';
-my %scver = %{ $scvers{$Request} }
-       or Abort("Requested version $Request not available", '404 unknown');
+my %scver = %{ $scvers{$Request} // {} }
+       or Html(), Abort("Requested version <q>$Request</q> not available", '404 request not found');
 
 my $datafile = "sc-units-$Request.inc.pl";
 
 Html({
        title => "$scver{title} unit cheat sheet",
-       version => '1.1',
+       version => '1.2',
        description => [
                "Reference of $scver{game} unit properties,"
                . " comparing various statistics of all the units in $scver{name}"
@@ -45,8 +45,8 @@ Html({
                $scver{major} < 2 ? qw' bw broodwar brood war ' :
                qw' starcraft2 lotv hots wol ',
        ],
-       stylesheet => [qw'light'],
-       raw => '<link rel="stylesheet" type="text/css" media="all" href="/sc.css?1.1" title="light">',
+       stylesheet => [qw( light dark )],
+       raw => '<link rel="stylesheet" type="text/css" media="all" href="/sc.css?1.2">',
        data => [$datafile],
 });
 
@@ -366,11 +366,6 @@ sub showrangeint {
                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
@@ -391,6 +386,11 @@ sub showrangeint {
                                + $_->{hp}/512 + $_->{min}/8192
                        ) for @rows;
                }
+               elsif ($get{order} eq 'hp') {
+                       $_->{order} = (
+                               $_->{hp}*1.01 + $_->{armor} + $_->{shield} + $_->{size}/1024,
+                       ) for @rows;
+               }
                elsif ($get{order} eq 'attack') {
                        $_->{order} = $_->{hp} / 1024 + $_->{shield} / 1008 + max(
                                map {