+ sub showunitcols {
+ my ($row) = @_;
+ local $_ = $row;
+ $_->{hp} += $_->{shield} if $_->{shield};
+
+ 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',
+ ),
+ sprintf('<td class="unit unit-%s" title="%3$s">%s',
+ $_->{cargo} < 0 ? ('supply', T => 'transport') :
+ $_->{attr}->{flying} ? ('air', F => 'flying') :
+ $_->{attr}->{structure} ? ('x', B => 'building') :
+ ([qw( x s m l l h h h h )]->[ $_->{cargo} ], $_->{cargo} || '-', ''),
+ ),
+ sprintf('<td class="val unit%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>',
+ ),
+ '<td class="val unit-hp">' . $_->{hp} // '',
+ $_->{shield} ? sprintf('<td class="val unit-shield">%.0f%%<td',
+ 100 * $_->{shield} / $_->{hp}
+ ) : '<td colspan=2',
+ ' class="val unit-armor">' .
+ showrange($_->{armor}, $_->{upgraded}->{armor}),
+ showattack($_, 0),
+ '<td class="val unit-sight">' . sprintf(
+ $_->{detect} ? '<strong class="unit-detect">%s</strong>' : '%s',
+ showrange($_->{sight}, $_->{upgraded}->{sight})
+ ),
+ '<td class="val unit-speed">' .
+ showrange($_->{speed}, $_->{upgraded}->{speed}),
+ $_->{attr}->{jump}
+ && qq'<span class="unit unit-jump" title="$_->{attr}->{jump}">↕</span>',
+ $_->{attr}->{flying}
+ && qq'<span class="unit unit-jump" title="flying">↑</span>',
+ '<td class="unit-magic">' . showmagic($_),
+ !$_->{attack}->[1] ? () : (
+ '<tr><td colspan=12>', showattack($_, 1), '<td colspan=3>'
+ ),
+ !$_->{attack}->[2] ? () : (
+ '<tr><td colspan=12>', showattack($_, 2), '<td colspan=3>'
+ ),
+ "\n"
+ );
+ }
+
+ my $grouped = 1; # race headers