sc: separate shield and hp values in data
[sheet.git] / sc.plp
diff --git a/sc.plp b/sc.plp
index 44940e5a06bc88f21a884132e647c482321e83a2..9a9a12a2e8af7ac4ff7e9e0e14382ac077404bcd 100644 (file)
--- a/sc.plp
+++ b/sc.plp
@@ -200,8 +200,8 @@ sub showrange {
                elsif ($type eq 'implosive') {
                        $min /= 4;
                }
-               $min = int($min + .5);  # round halves up
        }}
+       $_ = int($_ + .5) for $min, $max;  # round halves up
 
        return $min == $max ? $min : "$min-$max";
 }
@@ -252,7 +252,7 @@ sub showrange {
        if (exists $get{order}) {
                $get{order} ||= '';
                if ($get{order} eq 'size') {
-                       $_->{order} = $_->{unit}*8 + $_->{size} + $_->{hp}/512 + $_->{min}/8192 for @$units;
+                       $_->{order} = $_->{unit}*8 + $_->{suit} + $_->{hp}/512 + $_->{min}/8192 for @$units;
                }
                elsif ($get{order} eq 'cost') {
                        $_->{order} = $_->{gas}*1.5 + $_->{min} + $_->{unit}/8 + $_->{build}/256/8 for @$units;
@@ -269,7 +269,8 @@ sub showrange {
                printf '<tbody id="%s"><tr class="race"><th colspan="18"><h2>%s</h2>'."\n", $race, ucfirst $race
                        if $grouped and $race ne $_->{race};
                $_->{cat} = $_->{race} if not $grouped;
-               my $sizechar = [qw/? s m l/]->[$_->{size}];
+               $_->{hp} += $_->{shield};
+               my $suitchar = [qw/? s m l/]->[$_->{suit}];
                print(
                        '<tr>',
                        sprintf('<t%s class="cat">%s', $cat ne $_->{cat} ? ('h', $cat = $_->{cat}) : ('d', '&nbsp;')),
@@ -280,7 +281,7 @@ sub showrange {
                                !!$_->{base} && '<span class="unit-composed">+</span>',
                                $_->{build} || '0',
                        ),
-                       sprintf('<td class="unit unit-%s">%s', $sizechar, ucfirst $sizechar),
+                       sprintf('<td class="unit unit-%s">%s', $suitchar, ucfirst $suitchar),
                        '<td class="val unit">' . join('',
                                $_->{unit} ? $_->{unit} == .5 ? '½' : $_->{unit} : '&nbsp;',
                                defined $_->{organic} && sprintf(
@@ -291,7 +292,9 @@ sub showrange {
                                ),
                        ),
                        '<td class="val unit-hp">' . $_->{hp},
-                       '<td class="val unit-shield">' . ($_->{shield} ? $_->{shield}.'%' : '&nbsp;'),
+                       '<td class="val unit-shield">' . (
+                               $_->{shield} ? sprintf('%.0f%%', 100 * $_->{shield} / $_->{hp}) : '&nbsp;'
+                       ),
                        '<td class="val unit-armor">' . showrange($_, 'armor'),
                        showattack($_, 'ground'),
                        showattack($_, 'air'),