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: reusable function to display cast cost
[sheet.git]
/
sc.plp
diff --git
a/sc.plp
b/sc.plp
index ec79a7c310550e7d4bdd040673fe95500bd8ceb5..d1c6fc8cddfff288cf41e28c0cc1e2755dd9b019 100644
(file)
--- a/
sc.plp
+++ b/
sc.plp
@@
-95,8
+95,8
@@
sub coltoggle {
<thead><tr>
<th></th>
<th><:= coltoggle('name', '') :></th>
<thead><tr>
<th></th>
<th><:= coltoggle('name', '') :></th>
- <th class="val min"
><img src="/minerals.png" alt="min">
</th>
- <th class="val gas">
<img src="/gas.png" alt="gas">
</th>
+ <th class="val min"
title=minerals>cost
</th>
+ <th class="val gas">
gas
</th>
<th class="val time"><:= coltoggle(qw'build cost') :></th>
<th class="unit" colspan="2"><:= coltoggle(qw'size size') :></th>
<th class="unit" colspan="2">attr</th>
<th class="val time"><:= coltoggle(qw'build cost') :></th>
<th class="unit" colspan="2"><:= coltoggle(qw'size size') :></th>
<th class="unit" colspan="2">attr</th>
@@
-119,6
+119,15
@@
sub showrange {
return "$min-$max";
}
return "$min-$max";
}
+ sub showcost {
+ my ($row, $unit) = @_;
+ return join(' ',
+ sprintf('cost %.0f%%', 100 * $row->{cost} / $unit->{energy}),
+ !defined $row->{maint} ? () :
+ sprintf('+%.1f%%/s', 100 * $row->{maint} / $unit->{energy}),
+ );
+ }
+
sub showattack {
my ($row, $area) = @_;
my $attack = $row->{attack}->[$area]
sub showattack {
my ($row, $area) = @_;
my $attack = $row->{attack}->[$area]
@@
-130,6
+139,8
@@
sub showrange {
$maxdamage += ($upattack->{upgrade} // $attack->{upgrade}) * 3;
my $out = '<td class="val hurt">';
$maxdamage += ($upattack->{upgrade} // $attack->{upgrade}) * 3;
my $out = '<td class="val hurt">';
+ $out .= sprintf '<span title="%s">¤</span> ', showcost($attack, $row)
+ if $attack->{cost};
$out .= sprintf('<small>%s× </small>',
showrange($attack->{count}, $upattack->{count}),
) if $attack->{count} > 1;
$out .= sprintf('<small>%s× </small>',
showrange($attack->{count}, $upattack->{count}),
) if $attack->{count} > 1;
@@
-217,12
+228,7
@@
sub showrange {
(map { $_ && " ($_)" } join ', ',
#TODO: apply upgrades
$_->{range} ? "range $_->{range}" : (),
(map { $_ && " ($_)" } join ', ',
#TODO: apply upgrades
$_->{range} ? "range $_->{range}" : (),
- $_->{cost} ? sprintf('cost %.0f%%%s',
- 100 * $_->{cost} / $row->{energy},
- defined $_->{maint} && sprintf('+%.1f%%/s',
- 100 * $_->{maint} / $row->{energy},
- ),
- ) :
+ $_->{cost} ? showcost($_, $row) :
$_->{cooldown} ? "cooldown $_->{cooldown}s" : (),
),
),
$_->{cooldown} ? "cooldown $_->{cooldown}s" : (),
),
),