X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/d65dbc45b208c486003f110d3d4072c08df7d58b..ce2e637541f303d2967f7d424c3ea8240e579172:/sc.plp diff --git a/sc.plp b/sc.plp index ec79a7c..d1c6fc8 100644 --- a/sc.plp +++ b/sc.plp @@ -95,8 +95,8 @@ sub coltoggle { <:= coltoggle('name', '') :> - min - gas + cost + gas <:= coltoggle(qw'build cost') :> <:= coltoggle(qw'size size') :> attr @@ -119,6 +119,15 @@ sub showrange { 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] @@ -130,6 +139,8 @@ sub showrange { $maxdamage += ($upattack->{upgrade} // $attack->{upgrade}) * 3; my $out = ''; + $out .= sprintf '¤ ', showcost($attack, $row) + if $attack->{cost}; $out .= sprintf('%s× ', showrange($attack->{count}, $upattack->{count}), ) if $attack->{count} > 1; @@ -217,12 +228,7 @@ sub showrange { (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" : (), ), ),