X-Git-Url: http://git.shiar.net/sheet.git/blobdiff_plain/24084c2319f2fd4f3b9ce3da6eddca31f935ee51..7914537c1fda7796579fee5f8b9bb8791d93d546:/sc.plp diff --git a/sc.plp b/sc.plp index 3a11f0c..b20e51d 100644 --- a/sc.plp +++ b/sc.plp @@ -9,7 +9,7 @@ my %scver = ( major => 1, ); -if ($ENV{PATH_INFO} and $ENV{PATH_INFO} eq '/2') { +if ($Request and $Request eq '2') { %scver = ( id => 'hots', name => 'Heart of the Swarm', @@ -22,7 +22,7 @@ my $datafile = "sc-units-$scver{id}.inc.pl"; Html({ title => "$scver{title} unit cheat sheet", - version => 'v1.1', + version => '1.1', description => [ "Reference of $scver{game} unit properties," . " comparing various statistics of all the units in $scver{name}" @@ -40,19 +40,19 @@ Html({ data => [$datafile], }); -print "
Unit properties as seen or measured in $scver{name}\n$patch.\n"; -print "Also see the $_ table.\n" for join(', ', - ('StarCraft 2: HotS') x ($scver{major} < 2), - ('original SC: Brood War') x ($scver{major} > 1), +say "
Unit properties as seen or measured in $scver{name}\n$patch."; +say "Also see the $_ table." for join(', ', + (showlink('StarCraft 2: HotS', '/sc/2')) x ($scver{major} < 2), + (showlink('original SC: Brood War', '/sc')) x ($scver{major} > 1), ); -print "
\n\n"; +say "\n"; sub addupgrade { my ($ref, $increase, $org) = @_; @@ -85,39 +85,60 @@ for my $unit (@{$units}) { sub coltoggle { my ($name, $id, $nolink) = @_; - return sprintf( - (defined $get{order} ? $get{order} eq $id : !$id) ? '%2$s â¼' - : $nolink ? '%2$s' : '%s', - $id && "order=$id", $name - ); + return "$name â¼" if defined $get{order} ? $get{order} eq $id : !$id; + return $name if $nolink; + return showlink($name, '?'.($id && "order=$id")); } :>- | <:= coltoggle('name', '') :> | -- | - | <:= coltoggle(qw'build cost') :> | -<:= coltoggle(qw'size size') :> | -HP | +<:= coltoggle(exists $get{order} ? 'race' : 'source' => '') :> | +<:= coltoggle(name => 'name') :> | +<:= coltoggle(cost => 'cost') :> | +gas | +build | +<:= coltoggle(qw'size size') :> | +attr | +<:= coltoggle(HP => 'hp') :> | shield | ⨠| -attack | -<:= coltoggle(qw'dps attack 1') :> | +<:= coltoggle(attack => 'attack') :> | +dps | range | sight | -speed | +<:= coltoggle(speed => 'speed') :> | specials | '; - $out .= "$attack->{count}à " if $attack->{count} > 1; + $out .= sprintf '¤ ', showcost($attack, $row) + if $attack->{cost}; + $out .= sprintf('%sà ', + showrangeint($attack->{count}, $upattack->{count}), + ) if $attack->{count} > 1; $out .= '*' if $attack->{type} eq 'explosive'; $out .= '~' @@ -146,7 +171,7 @@ sub showrange { } join '_', @bonus), join(', ', map {( sprintf('+%s vs %s', - showrange( + showrangeint( $attack->{bonus}->{$_}, $attack->{bonus}->{$_} + $attack->{bonus}->{"-$_"} * 3, ), @@ -159,7 +184,7 @@ sub showrange { if $attack->{type} eq 'projectile'; $out .= sprintf '', $attack->{name} if $attack->{name}; - $out .= showrange($damage, $maxdamage); + $out .= showrangeint($damage, $maxdamage); $out .= '' if $attack->{name}; $out .= sprintf('%s', $attack->{splash} eq 'line' ? ('linear', '+') : ('splash', 'â') @@ -167,7 +192,10 @@ sub showrange { $out .= ' | '; if ($attack->{dps}) { - $out .= showrange($attack->{dps}->[0], $attack->{dps}->[-1]); + # precalculated dps, do not touch + $out .= showrangeint($attack->{dps}->[0], + $upattack->{dps}->[-1] // $attack->{dps}->[-1] + ); } elsif ($attack->{cooldown}) { if (my $type = $attack->{type}) { @@ -187,14 +215,14 @@ sub showrange { } $maxdamage *= ($upattack->{count} // $attack->{count} // 1) / ($upattack->{cooldown} // $attack->{cooldown}); - $out .= showrange($damage, $maxdamage); + $out .= showrangeint($damage, $maxdamage); } $out .= ' | ' . 'â½' x !!($attack->{anti} & 1); $out .= ' | ' . 'â³' x !!($attack->{anti} & 2); $out .= ' | ' . - showrange($attack->{range}, $upattack->{range}); + showrangeint($attack->{range}, $upattack->{range}); return $out; } @@ -211,12 +239,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 +251,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 +259,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,24 +288,45 @@ 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%% | {shield} / $_->{hp} ) : ' | ' . - showrange($_->{armor}, $_->{upgraded}->{armor}), + showrangeint($_->{armor}, $_->{upgraded}->{armor}), showattack($_, 0), ' | ' . sprintf( $_->{detect} ? '%s' : '%s', - showrange($_->{sight}, $_->{upgraded}->{sight}) + showrangeint($_->{sight}, $_->{upgraded}->{sight}) + ), + sprintf(' | %s', + showrange( + map { $_ && sprintf '%.1f', $_ } + $_->{speed}, $_->{upgraded}->{speed} + ), + defined $_->{creep} && sprintf(' title="%s on creep"', + $_->{creep} == 1 ? 'same' : showrange( + map { $_ && sprintf '%.1f', $_ } + $_->{speed} * $_->{creep}, + $_->{upgraded}->{speed} && $_->{upgraded}->{speed} * + ($_->{upgraded}->{creep} // $_->{creep}), + ), + ), ), - ' | ' . - showrange($_->{speed}, $_->{upgraded}->{speed}), $_->{attr}->{jump} && qq'â', - $_->{attr}->{flying} - && qq'â', ' | ' . showmagic($_), !$_->{attack}->[1] ? () : ( ' |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
', showattack($_, 1), ' | ' @@ -305,43 +338,56 @@ sub showrange { ); } + my @rows = @{$units}; my $grouped = 1; # race headers if (exists $get{order}) { $grouped = 0; $get{order} ||= ''; - if ($get{order} eq 'size') { + if ($get{order} eq 'name') { + @rows = sort {$a->{name} cmp $b->{name}} @rows; + } + elsif ($get{order} eq 'hp') { $_->{order} = ( - $_->{unit}*16 + ($_->{size} // $_->{suit}) + $_->{cargo}/8 - + $_->{hp}/512 + $_->{min}/8192 - ) for @$units; + $_->{hp}*1.01 + $_->{armor} + $_->{shield} + $_->{size}/1024, + ) for @rows; } elsif ($get{order} eq 'cost') { $_->{order} = ( - $_->{gas}*1.5 + $_->{min} + $_->{unit}/8 + $_->{build}/256/8 - ) for @$units; + $_->{gas}*1.5 + $_->{min} + $_->{pop}/8 + $_->{build}/256/8 + ) for @rows; + } + elsif ($get{order} eq 'size') { + $_->{order} = ( + $_->{pop}*16 + ($_->{size} // $_->{suit}) + $_->{cargo}/8 + + $_->{hp}/512 + $_->{min}/8192 + ) for @rows; } elsif ($get{order} eq 'attack') { $_->{order} = $_->{hp} / 1024 + $_->{shield} / 1008 + max( map { - ($_->{damage} + $_->{upgrade} * 3) - * ($_->{count} // 1) / ($_->{cooldown} // 1) + ($_->{dps} ? $_->{dps}->[-1] : + ($_->{damage} + $_->{upgrade} * 3) + * ($_->{count} // 1) / ($_->{cooldown} // 1) + ) * ($_->{splash} ? 1.01 : 1) * ($_->{type} eq 'implosive' ? .96 : 1) * ($_->{type} eq 'explosive' ? .98 : 1) } @{ $_->{attack} } - ) for @$units; + ) for @rows; } - else { - $units->[$_]->{order} = $_ for 0 .. $#$units; + elsif ($get{order} eq 'speed') { + $_->{order} = ( + ($_->{upgraded}->{speed} // $_->{speed}*1.01) + + $_->{sight}/1024 + $_->{detect}/2048 + ) for @rows; } + @rows = sort {$a->{order} <=> $b->{order}} @rows if exists $rows[0]->{order}; } - my @rows = @{$units}; - @rows = sort {$a->{order} <=> $b->{order}} @rows unless $grouped; my ($race, $cat) = ('', ''); for (@rows) { if ($grouped) { - printf ' | |||||||||||||||||||||||||||||||
%s'."\n", + say sprintf ' | ||||||||||||||||||||||||||||||||
%s', $race = $_->{race}, ucfirst $race unless $race eq $_->{race}; } @@ -372,27 +418,16 @@ sub showrange {
-When two values are given (1-2), second value indicates attribute after all -possible upgrades. +When two values are given (1-2), the second value indicates the attribute +after all possible upgrades. |