git.shiar.nl
/
sheet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sc: rename showrange() to prepare for non-integer reuse
[sheet.git]
/
sc.plp
diff --git
a/sc.plp
b/sc.plp
index 28d22d71c56290b57b38df0ed8c7d43002bb975b..5454b637d02d7e0f4f7d59d733df64d58ebdcc75 100644
(file)
--- a/
sc.plp
+++ b/
sc.plp
@@
-114,24
+114,29
@@
sub coltoggle {
sub showrange {
my ($min, $max) = @_;
return '' if not defined $min;
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";
}
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) = @_;
sub showcost {
my ($row, $unit) = @_;
- my $minmult = 100 / $unit->{energy}; # cost multiplier
- my $maxmult = $unit->{upgraded}->{energy} &&
- 100 / $unit->{upgraded}->{energy};
-
return join(' ',
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},
),
);
}
),
);
}
@@
-150,7
+155,7
@@
sub showrange {
$out .= sprintf '<span title="%s">¤</span> ', showcost($attack, $row)
if $attack->{cost};
$out .= sprintf('<small>%s× </small>',
$out .= sprintf '<span title="%s">¤</span> ', showcost($attack, $row)
if $attack->{cost};
$out .= sprintf('<small>%s× </small>',
- showrange($attack->{count}, $upattack->{count}),
+ showrange
int
($attack->{count}, $upattack->{count}),
) if $attack->{count} > 1;
$out .= '<span class="unit-l" title="explosive">*</span>'
if $attack->{type} eq 'explosive';
) if $attack->{count} > 1;
$out .= '<span class="unit-l" title="explosive">*</span>'
if $attack->{type} eq 'explosive';
@@
-168,7
+173,7
@@
sub showrange {
} join '_', @bonus),
join(', ', map {(
sprintf('+%s vs %s',
} join '_', @bonus),
join(', ', map {(
sprintf('+%s vs %s',
- showrange(
+ showrange
int
(
$attack->{bonus}->{$_},
$attack->{bonus}->{$_} + $attack->{bonus}->{"-$_"} * 3,
),
$attack->{bonus}->{$_},
$attack->{bonus}->{$_} + $attack->{bonus}->{"-$_"} * 3,
),
@@
-181,7
+186,7
@@
sub showrange {
if $attack->{type} eq 'projectile';
$out .= sprintf '<span title="%s">', $attack->{name} if $attack->{name};
if $attack->{type} eq 'projectile';
$out .= sprintf '<span title="%s">', $attack->{name} if $attack->{name};
- $out .= showrange($damage, $maxdamage);
+ $out .= showrange
int
($damage, $maxdamage);
$out .= '</span>' if $attack->{name};
$out .= sprintf('<span class="unit-splash" title="%s">%s</span>',
$attack->{splash} eq 'line' ? ('linear', '+') : ('splash', '⁜')
$out .= '</span>' if $attack->{name};
$out .= sprintf('<span class="unit-splash" title="%s">%s</span>',
$attack->{splash} eq 'line' ? ('linear', '+') : ('splash', '⁜')
@@
-190,7
+195,7
@@
sub showrange {
$out .= '<td class="val hurt hurtrel">';
if ($attack->{dps}) {
# precalculated dps, do not touch
$out .= '<td class="val hurt hurtrel">';
if ($attack->{dps}) {
# precalculated dps, do not touch
- $out .= showrange($attack->{dps}->[0],
+ $out .= showrange
int
($attack->{dps}->[0],
$upattack->{dps}->[-1] // $attack->{dps}->[-1]
);
}
$upattack->{dps}->[-1] // $attack->{dps}->[-1]
);
}
@@
-212,14
+217,14
@@
sub showrange {
}
$maxdamage *= ($upattack->{count} // $attack->{count} // 1)
/ ($upattack->{cooldown} // $attack->{cooldown});
}
$maxdamage *= ($upattack->{count} // $attack->{count} // 1)
/ ($upattack->{cooldown} // $attack->{cooldown});
- $out .= showrange($damage, $maxdamage);
+ $out .= showrange
int
($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">' .
}
$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});
+ showrange
int
($attack->{range}, $upattack->{range});
return $out;
}
return $out;
}
@@
-302,14
+307,14
@@
sub showrange {
100 * $_->{shield} / $_->{hp}
) : '<td colspan=2',
' class="val unit-armor">' .
100 * $_->{shield} / $_->{hp}
) : '<td colspan=2',
' class="val unit-armor">' .
- showrange($_->{armor}, $_->{upgraded}->{armor}),
+ showrange
int
($_->{armor}, $_->{upgraded}->{armor}),
showattack($_, 0),
'<td class="val unit-sight">' . sprintf(
$_->{detect} ? '<strong class="unit-detect">%s</strong>' : '%s',
showattack($_, 0),
'<td class="val unit-sight">' . sprintf(
$_->{detect} ? '<strong class="unit-detect">%s</strong>' : '%s',
- showrange($_->{sight}, $_->{upgraded}->{sight})
+ showrange
int
($_->{sight}, $_->{upgraded}->{sight})
),
'<td class="val unit-speed">' .
),
'<td class="val unit-speed">' .
- showrange($_->{speed}, $_->{upgraded}->{speed}),
+ showrange
int
($_->{speed}, $_->{upgraded}->{speed}),
$_->{attr}->{jump}
&& qq'<span class="unit unit-jump" title="$_->{attr}->{jump}">↕</span>',
'<td class="unit-magic">' . showmagic($_),
$_->{attr}->{jump}
&& qq'<span class="unit unit-jump" title="$_->{attr}->{jump}">↕</span>',
'<td class="unit-magic">' . showmagic($_),
@@
-451,7
+456,7
@@
if ($scver{major} > 1) {
<dd>targets <span class="hurt-g">▽</span> ground
and/or <span class="hurt-a">△</span> air
<dt>range
<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 t
ank also has a minimum range)
+ <dd>maximum range of weapon (note
Sieged T
ank 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>sight
<dd>range in which the unit detects other units
<dd><strong class="unit-detect">emphasis</strong> indicates ability to detect cloaked units
@@
-462,7
+467,7
@@
if ($scver{major} > 1) {
<dd><span class="magic-perma">passive</span> abilities are always enabled
<dd>hover for description
<dd>range is maximum range required to activate
<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>
</dl>
<p>