sub showrange {
my ($min, $max) = @_;
return '' if not defined $min;
- $_ &&= int($_ + .5) for $min, $max; # round halves up
return $min || '-' if !$max or $min == $max;
return "$min-$max";
}
+sub showrangeint {
+ $_ &&= int($_ + .5) for @_; # round halves up
+ return showrange(@_);
+}
+
sub showcost {
my ($row, $unit) = @_;
- my $minmult = 100 / $unit->{capacity}; # cost multiplier
- my $maxmult = $unit->{upgraded}->{capacity} &&
- 100 / $unit->{upgraded}->{capacity};
-
return join(' ',
- sprintf('cost %s%%',
- showrange($row->{cost} * $minmult, $row->{cost} * $maxmult),
+ sprintf('cost %s%%', join '-',
+ map { $_ && sprintf '%.0f', 100 * $row->{cost} / $_ } grep { defined $_ }
+ $unit->{energy},
+ $unit->{upgraded}->{energy},
+ $unit->{capacity},
+ $unit->{upgraded}->{capacity},
),
- !defined $row->{maint} ? () : sprintf('+%.1f%s%%/s',
- $row->{maint} * $minmult,
- !!$maxmult && sprintf('-%.1f', $row->{maint} * $maxmult),
+ !defined $row->{maint} ? () : sprintf('+%s%%/s', join '-',
+ map { sprintf '%.1f', 100 * $row->{maint} / $_ } grep $_,
+ $unit->{capacity},
+ $unit->{upgraded}->{capacity},
),
);
}
$out .= sprintf '<span title="%s">¤</span> ', showcost($attack, $row)
if $attack->{cost};
$out .= sprintf('<small>%s× </small>',
- showrange($attack->{count}, $upattack->{count}),
+ showrangeint($attack->{count}, $upattack->{count}),
) if $attack->{count} > 1;
$out .= '<span class="unit-l" title="explosive">*</span>'
if $attack->{type} eq 'explosive';
} join '_', @bonus),
join(', ', map {(
sprintf('+%s vs %s',
- showrange(
+ showrangeint(
$attack->{bonus}->{$_},
$attack->{bonus}->{$_} + $attack->{bonus}->{"-$_"} * 3,
),
if $attack->{type} eq 'projectile';
$out .= sprintf '<span title="%s">', $attack->{name} if $attack->{name};
- $out .= showrange($damage, $maxdamage);
+ $out .= showrangeint($damage, $maxdamage);
$out .= '</span>' if $attack->{name};
$out .= sprintf('<span class="unit-splash" title="%s">%s</span>',
$attack->{splash} eq 'line' ? ('linear', '+') : ('splash', '⁜')
$out .= '<td class="val hurt hurtrel">';
if ($attack->{dps}) {
# precalculated dps, do not touch
- $out .= showrange($attack->{dps}->[0],
+ $out .= showrangeint($attack->{dps}->[0],
$upattack->{dps}->[-1] // $attack->{dps}->[-1]
);
}
}
$maxdamage *= ($upattack->{count} // $attack->{count} // 1)
/ ($upattack->{cooldown} // $attack->{cooldown});
- $out .= showrange($damage, $maxdamage);
+ $out .= showrangeint($damage, $maxdamage);
}
$out .= '<td class="unit hurt-g">' . '▽' x !!($attack->{anti} & 1);
$out .= '<td class="unit hurt-a">' . '△' x !!($attack->{anti} & 2);
$out .= '<td class="val unit-range">' .
- showrange($attack->{range}, $upattack->{range});
+ showrangeint($attack->{range}, $upattack->{range});
return $out;
}
100 * $_->{shield} / $_->{hp}
) : '<td colspan=2',
' class="val unit-armor">' .
- showrange($_->{armor}, $_->{upgraded}->{armor}),
+ showrangeint($_->{armor}, $_->{upgraded}->{armor}),
showattack($_, 0),
'<td class="val unit-sight">' . sprintf(
$_->{detect} ? '<strong class="unit-detect">%s</strong>' : '%s',
- showrange($_->{sight}, $_->{upgraded}->{sight})
+ 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}),
+ ),
+ ),
),
- '<td class="val unit-speed">' .
- showrange($_->{speed}, $_->{upgraded}->{speed}),
$_->{attr}->{jump}
&& qq'<span class="unit unit-jump" title="$_->{attr}->{jump}">↕</span>',
'<td class="unit-magic">' . showmagic($_),
<dd>targets <span class="hurt-g">▽</span> ground
and/or <span class="hurt-a">△</span> air
<dt>range
- <dd>maximum range of weapon (note siege tank also has a minimum range)
+ <dd>maximum range of weapon (note Sieged Tank also has a minimum range)
<dt>sight
<dd>range in which the unit detects other units
<dd><strong class="unit-detect">emphasis</strong> indicates ability to detect cloaked units
<dt>speed
- <dd>relative speed of movement (when in full motion, startup speed ignored)
+ <dd>top movement speed in hex per second
+ <dd>acceleration and deceleration ignored
<dt>specials
<dd>parentheses () indicate that it needs to be researched first
<dd><span class="magic-perma">passive</span> abilities are always enabled
<dd>hover for description
<dd>range is maximum range required to activate
- <dd>cost is percentage of total energy lost
+ <dd>cost is energy loss percentage on spawn and when fully charged
</dl>
<p>