+ sub showunitcols {
+ my ($row) = @_;
+ local $_ = $row;
+ my $suitchar = '';
+ if ($_->{suit}) {
+ $suitchar = [qw/? s m l/]->[$_->{suit}];
+ }
+
+ 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">' . join('',
+ defined $_->{unit} && $_->{unit} == .5 ? '½' : $_->{unit},
+ defined $_->{organic} && sprintf(
+ '<span class="unit-%s" title="%s">%s</span>',
+ $_->{organic} ? 'o' : 'u',
+ $_->{organic} ? 'organic' : 'mechanic',
+ $_->{organic} ? 'o' : 'm',
+ ),
+ ),
+ '<td class="val unit-hp">' . $_->{hp} // '',
+ '<td class="val unit-shield">' . (
+ $_->{shield} ? sprintf('%.0f%%', 100 * $_->{shield} / $_->{hp}) : ' '
+ ),
+ '<td class="val unit-armor">' . showrange($_, 'armor'),
+ showattack($_, 'ground'),
+ showattack($_, 'air'),
+ '<td class="val unit-range">' . showrange($_, 'attack', 'range'),
+ '<td class="val unit-sight">' . sprintf(
+ $_->{detect} ? '<strong class="unit-detect">%s</strong>' : '%s',
+ showrange($_, 'sight')
+ ),
+ '<td class="val unit-speed">' . showrange($_, 'speed'),
+ '<td class="unit-magic">' . showmagic($_),
+ "\n"
+ );
+ }
+
+ my $units = do $datafile;
+ die "Cannot open unit data: $_\n" for $@ || $! || ();