+ sprintf($_->{build} ? '(%s)' : '%s', $_->{abbr}),
+ } grep { defined $_->{abbr} } @{$specials};
+ }
+
+ sub showunitcols {
+ my ($row) = @_;
+ local $_ = $row;
+ $_->{hp} += $_->{shield} if $_->{shield};
+ my $suitchar = '';
+ if ($_->{suit}) {
+ $suitchar = [qw/? s m l/]->[$_->{suit}];
+ }
+ elsif ($_->{cargo} > 0) {
+ $suitchar = [qw/? s m l l h h h h/]->[abs $_->{cargo}];
+ }
+ elsif ($_->{size}) {
+ $suitchar = [qw/s m l h h h/]->[$_->{size}];
+ }
+ elsif ($_->{attr} and $_->{attr}->{light}) {
+ $suitchar = 's';
+ }
+ elsif ($_->{attr} and $_->{attr}->{armored}) {
+ $suitchar = 'l';
+ }
+
+ return (
+ '<td class="val min">' . ($_->{min} // ''),
+ '<td class="val gas">' . ($_->{gas} || ''),
+ !defined $_->{build} ? '<td>' : sprintf('<td class="val time">%s%.0f',
+ !!$_->{base} && '<span class="unit-composed">+</span>',
+ $_->{build} || '0',
+ ),
+ !$suitchar ? '<td>' : sprintf('<td class="unit unit-%s">%s', $suitchar, ucfirst $suitchar),
+ '<td class="val unit">' . (
+ defined $_->{unit} && $_->{unit} == .5 ? '½' : $_->{unit}
+ ),
+ '<td class="unit unit-type">' . join('', grep { $_ }
+ (defined $_->{organic} || $_->{attr}->{organic})
+ && '<span class="unit-o" title="organic">o</span>',
+ (defined $_->{organic} ? !$_->{organic} : $_->{attr}->{mech})
+ && '<span class="unit-u" title="mechanic">m</span>',
+ $_->{attr}->{psionic}
+ && '<span class="unit-p" title="psionic">ψ</span>',
+ ),
+ '<td class="unit unit-attr">' . join('', grep { $_ }
+ $_->{attr}->{armored}
+ && '<span class="unit unit-l" title="armored">A</span>',
+ $_->{attr}->{light}
+ && '<span class="unit unit-s" title="light">L</span>',
+ ),
+ '<td class="val unit-hp">' . $_->{hp} // '',
+ '<td class="val unit-shield">' . (
+ $_->{shield} ? sprintf('%.0f%%', 100 * $_->{shield} / $_->{hp}) : ' '
+ ),
+ '<td class="val unit-armor">' . showval($_, 'armor'),
+ showattack($_, 'ground'),
+ showattack($_, 'air'),
+ '<td class="val unit-range">' . showval($_, 'attack', 'range'),
+ '<td class="val unit-sight">' . sprintf(
+ $_->{detect} ? '<strong class="unit-detect">%s</strong>' : '%s',
+ showval($_, 'sight')
+ ),
+ '<td class="val unit-speed">' . showval($_, 'speed'),
+ $_->{attr}->{massive} && '<span class="unit-massive">☇</span>',
+ '<td class="unit-magic">' . showmagic($_),
+ "\n"
+ );