X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/24084c2319f2fd4f3b9ce3da6eddca31f935ee51..7fdfc28a5f960c452bcc5efc8792a93ffa4bd144:/sc.plp diff --git a/sc.plp b/sc.plp index 3a11f0c..a1c885f 100644 --- a/sc.plp +++ b/sc.plp @@ -95,10 +95,11 @@ sub coltoggle { <:= coltoggle('name', '') :> - min - gas + cost + gas <:= coltoggle(qw'build cost') :> - <:= coltoggle(qw'size size') :> + <:= coltoggle(qw'size size') :> + attr HP shield ⛨ @@ -114,10 +115,28 @@ sub showrange { 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 join(' ', + 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('+%s%%/s', join '-', + map { sprintf '%.1f', 100 * $row->{maint} / $_ } grep $_, + $unit->{capacity}, + $unit->{upgraded}->{capacity}, + ), + ); + } + sub showattack { my ($row, $area) = @_; my $attack = $row->{attack}->[$area] @@ -129,7 +148,11 @@ sub showrange { $maxdamage += ($upattack->{upgrade} // $attack->{upgrade}) * 3; my $out = ''; - $out .= "$attack->{count}× " if $attack->{count} > 1; + $out .= sprintf '¤ ', showcost($attack, $row) + if $attack->{cost}; + $out .= sprintf('%s× ', + showrange($attack->{count}, $upattack->{count}), + ) if $attack->{count} > 1; $out .= '*' if $attack->{type} eq 'explosive'; $out .= '~' @@ -167,7 +190,10 @@ sub showrange { $out .= ''; if ($attack->{dps}) { - $out .= showrange($attack->{dps}->[0], $attack->{dps}->[-1]); + # precalculated dps, do not touch + $out .= showrange($attack->{dps}->[0], + $upattack->{dps}->[-1] // $attack->{dps}->[-1] + ); } elsif ($attack->{cooldown}) { if (my $type = $attack->{type}) { @@ -211,12 +237,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" : (), ), ), @@ -228,25 +249,6 @@ sub showrange { my ($row) = @_; local $_ = $row; $_->{hp} += $_->{shield} if $_->{shield}; - my $suitchar = ''; - if ($_->{attr}->{structure}) { - $suitchar = 'b'; - } - elsif ($_->{suit}) { - $suitchar = [qw/? s m l/]->[$_->{suit}]; - } - elsif ($_->{cargo} > 0) { - $suitchar = [qw/? s m l l h h h h/]->[abs $_->{cargo}]; - } - elsif ($_->{size}) { - $suitchar = [qw/s m l h h h/]->[$_->{size}]; - } - elsif ($_->{attr} and $_->{attr}->{light}) { - $suitchar = 's'; - } - elsif ($_->{attr} and $_->{attr}->{armored}) { - $suitchar = 'l'; - } return ( '' . ($_->{min} // ''), @@ -255,13 +257,21 @@ sub showrange { !!$_->{base} && '+', $_->{build} || '0', ), - !$suitchar ? '' : sprintf('%s%s', - $suitchar, ucfirst $suitchar, - $_->{attr}->{massive} - && '⚓', + sprintf('%s', + $_-> {cargo} < 0 ? ('supply', T => 'transport') : + $_->{upgraded}->{cargo} < 0 ? ('supply magic-opt', T => 'optional transport') : + $_->{attr}->{flying} ? ('air', F => 'flying') : + $_->{attr}->{structure} ? ('x', B => 'building') : + ( + [qw( x s m l l h h h h )]->[ $_->{cargo} ], + $_->{cargo} || '-', + $_->{cargo} ? 'transportable' : 'untransportable', + ), + defined $_->{size} && sprintf('⌀%.1f ', $_->{size}), ), - '' . ( - defined $_->{unit} && $_->{unit} == .5 ? '½' : $_->{unit} + sprintf('%s', + defined $_->{pop} && $_->{pop} < 0 && ' unit-supply', + defined $_->{pop} && $_->{pop} == .5 ? '½' : $_->{pop}, ), '' . join('', grep { $_ } (defined $_->{organic} ? !$_->{organic} : $_->{attr}->{mech}) @@ -276,6 +286,17 @@ sub showrange { && 'A', $_->{attr}->{light} && 'L', + $_->{suit} && sprintf( + '%s', + map { @{$_} } [ + [qw( x ? unknown )], + [qw( s S small )], + [qw( m M medium )], + [qw( l L large )], + ]->[ $_->{suit} ], + ), + $_->{attr}->{massive} + && '⚓', ), '' . $_->{hp} // '', $_->{shield} ? sprintf('%.0f%%{speed}, $_->{upgraded}->{speed}), $_->{attr}->{jump} && qq'↕', - $_->{attr}->{flying} - && qq'↑', '' . showmagic($_), !$_->{attack}->[1] ? () : ( '', showattack($_, 1), '' @@ -311,13 +330,13 @@ sub showrange { $get{order} ||= ''; if ($get{order} eq 'size') { $_->{order} = ( - $_->{unit}*16 + ($_->{size} // $_->{suit}) + $_->{cargo}/8 + $_->{pop}*16 + ($_->{size} // $_->{suit}) + $_->{cargo}/8 + $_->{hp}/512 + $_->{min}/8192 ) for @$units; } elsif ($get{order} eq 'cost') { $_->{order} = ( - $_->{gas}*1.5 + $_->{min} + $_->{unit}/8 + $_->{build}/256/8 + $_->{gas}*1.5 + $_->{min} + $_->{pop}/8 + $_->{build}/256/8 ) for @$units; } elsif ($get{order} eq 'attack') { @@ -379,19 +398,9 @@ sub showrange {
excludes construction of dependencies such as buildings and +parent units
size -
<: -if ($scver{major} > 1) { - :>transports can fit 8 Small, - 4 Medium, - 2 Large, - or a single Huge unit -
massive ⚓ units - cannot be lifted or slowed and can break force fields<: -} else { - :>affected by Small, - Medium, or - Large unit damage<: -} :> +
Transports can fit upto + 8 + non-Flying units
number of command points taken per unit
<: if ($scver{major} > 1) { @@ -401,9 +410,14 @@ if ($scver{major} > 1) { ψ(ps)ionic, Light, and Armored - attributes<: + attributes +
massive ⚓ units + cannot be lifted or slowed and can break force fields<: } else { - :>organic/mechanic unit<: + :>organic/mechanic unit +
affected by Small, + Medium, or + Large unit damage<: } :>
HP
total number of hitpoints (including shields) @@ -449,7 +463,7 @@ if ($scver{major} > 1) {
passive abilities are always enabled
hover for description
range is maximum range required to activate -
cost is percentage of total energy lost +
cost is energy loss percentage on spawn and when fully charged