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 (parent:
0b00ef9
)
sc: include upgraded cast costs
author
Mischa POSLAWSKY
<perl@shiar.org>
Tue, 30 Jun 2015 14:04:14 +0000
(16:04 +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 d1c6fc8cddfff288cf41e28c0cc1e2755dd9b019..28d22d71c56290b57b38df0ed8c7d43002bb975b 100644
(file)
--- a/
sc.plp
+++ b/
sc.plp
@@
-115,16
+115,24
@@
sub showrange {
my ($min, $max) = @_;
return '' if not defined $min;
$_ &&= int($_ + .5) for $min, $max; # round halves up
my ($min, $max) = @_;
return '' if not defined $min;
$_ &&= int($_ + .5) for $min, $max; # round halves up
- return $min || '-' if
not defined
$max or $min == $max;
+ return $min || '-' if
!
$max or $min == $max;
return "$min-$max";
}
sub showcost {
my ($row, $unit) = @_;
return "$min-$max";
}
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 %.0f%%', 100 * $row->{cost} / $unit->{energy}),
- !defined $row->{maint} ? () :
- sprintf('+%.1f%%/s', 100 * $row->{maint} / $unit->{energy}),
+ sprintf('cost %s%%',
+ showrange($row->{cost} * $minmult, $row->{cost} * $maxmult),
+ ),
+ !defined $row->{maint} ? () : sprintf('+%.1f%s%%/s',
+ $row->{maint} * $minmult,
+ !!$maxmult && sprintf('-%.1f', $row->{maint} * $maxmult),
+ ),
);
}
);
}