git.shiar.nl
/
sheet.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
7ad7f80
)
sc: reusable function to display cast cost
author
Mischa POSLAWSKY
<perl@shiar.org>
Tue, 30 Jun 2015 13:44:16 +0000
(15:44 +0200)
committer
Mischa POSLAWSKY
<perl@shiar.org>
Wed, 1 Jul 2015 17:32:34 +0000
(19:32 +0200)
sc.plp
patch
|
blob
|
history
diff --git
a/sc.plp
b/sc.plp
index e4633107554db5d1d72501bb57b006ca84b6f14b..d1c6fc8cddfff288cf41e28c0cc1e2755dd9b019 100644
(file)
--- a/
sc.plp
+++ b/
sc.plp
@@
-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]
@@
-219,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" : (),
),
),