+ (map { $_ && " ($_)" } join ', ',
+ #TODO: apply upgrades
+ $_->{range} ? "range $_->{range}" : (),
+ $_->{cost} ? showcost($_, $row) :
+ $_->{cooldown} ? "cooldown $_->{cooldown}s" : (),
+ ),
+ ),
+ sprintf($_->{build} ? '(%s)' : '%s', $_->{abbr}),
+ } grep { defined $_->{abbr} } @{$specials};
+ }
+
+ sub showunitcols {
+ my ($row) = @_;
+ local $_ = $row;
+ $_->{hp} += $_->{shield} if $_->{shield};
+
+ return (
+ '<td class="val unit-min">' . ($_->{min} // ''),
+ '<td class="val unit-gas">' . ($_->{gas} || ''),
+ defined $_->{transform} ? sprintf('<td class="val time">%.0f',
+ $_->{transform},
+ ) :
+ !defined $_->{build} ? '<td>' : sprintf('<td class="val time"%s>%s%.0f',
+ defined $_->{warp} && sprintf(' title="%.0f without warpgate"', $_->{build}),
+ !!$_->{base} && sprintf(
+ '<span class="unit-composed" title="%s">+</span>',
+ 'from '.join('+', @{ $_->{base} }),
+ ),
+ $_->{warp} // $_->{build} || '0',
+ ),
+ sprintf('<td class="unit unit-%s" title="%4$s%3$s">%s',
+ $_-> {cargo} < 0 ? ('supply', T => 'transport') :
+ $_->{upgraded}->{cargo} < 0 ? ('supply magic-opt', T => 'optional transport') :
+ $_-> {attr}->{flying} ? ('air', F => 'flying') :
+ $_->{upgraded}->{attr}->{flying} ? ('air magic-opt', F => 'potentially flying') :
+ $_->{attr}->{structure} ? ('x', B => 'building') :
+ (
+ [qw( x s m l l h h h h )]->[ $_->{cargo} ],
+ $_->{cargo} || '-',
+ $_->{cargo} ? 'transportable' : 'untransportable',
+ ),
+ defined $_->{size} && sprintf('⌀%.1f ', $_->{size}),
+ ),
+ sprintf('<td class="val unit unit-pop%s">%s',
+ defined $_->{pop} && $_->{pop} < 0 && ' unit-supply',
+ defined $_->{pop} && $_->{pop} == .5 ? '½' : $_->{pop},
+ ),
+ '<td class="unit unit-type">' . join('', grep { $_ }
+ (defined $_->{organic} ? !$_->{organic} : $_->{attr}->{mech})
+ && '<span class="unit-u" title="mechanic">m</span>',
+ ($_->{organic} || $_->{attr}->{organic})
+ && '<span class="unit-o" title="organic">o</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>',
+ $_->{suit} && sprintf(
+ '<span class="unit unit-%s" title="%3$s">%s</span>',
+ map { @{$_} } [
+ [qw( x ? unknown )],
+ [qw( s S small )],
+ [qw( m M medium )],
+ [qw( l L large )],
+ ]->[ $_->{suit} ],
+ ),
+ $_->{attr}->{massive}
+ && '<span class="unit-massive" title="massive">⚓</span>',
+ ),
+ $_->{hp} < 0 ? '<td class="val unit-hp" title="invulnerable">∞' :
+ '<td class="val unit-hp">' . showrangeint($_->{hp}, $_->{upgraded}->{hp}),
+ $_->{shield} ? sprintf('<td class="val unit-shield">%.0f%%<td',
+ 100 * $_->{shield} / $_->{hp}
+ ) : '<td colspan=2',
+ ' class="val unit-armor">' .
+ showrangeint($_->{armor}, $_->{upgraded}->{armor}),
+ showattack($_, 0),
+ '<td class="val unit-sight">' . sprintf(
+ $_->{detect} ? '<strong class="unit-detect">%s</strong>' : '%s',
+ showrangeint($_->{sight}, $_->{upgraded}->{sight})
+ ),
+ sprintf('<td class="val unit-speed"%2$s>%s',
+ showrange(
+ map { $_ && sprintf '%.1f', $_ }
+ $_->{speed}, $_->{upgraded}->{speed}
+ ),
+ defined $_->{creep} && sprintf(' title="%s on creep"',
+ $_->{creep} == 1 ? 'same' : showrange(
+ map { $_ && sprintf '%.1f', $_ }
+ $_->{speed} * $_->{creep},
+ $_->{upgraded}->{speed} && $_->{upgraded}->{speed} *
+ ($_->{upgraded}->{creep} // $_->{creep}),
+ ),