X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/c8b78d7e45756addbc07cc8591ff68ba95f538c3..e7d0872468d9ff54c39ac8a7e64f283ba093c7aa:/sc.plp diff --git a/sc.plp b/sc.plp index 4105bec..13248fb 100644 --- a/sc.plp +++ b/sc.plp @@ -1,155 +1,53 @@ <(common.inc.plp)><: -my $datafile = 'sc-units.inc.pl'; +my %scver = ( + id => 'bw', + name => 'Brood War', + title => 'starcraft', + game => 'StarCraft', + major => 1, +); + if ($ENV{PATH_INFO} and $ENV{PATH_INFO} eq '/2') { - $datafile = 'sc2-units.inc.pl'; + %scver = ( + id => 'hots', + name => 'Heart of the Swarm', + title => 'starcraft2', + game => 'StarCraft II', + major => 2, + ); } +my $datafile = "sc-units-$scver{id}.inc.pl"; Html({ - title => 'starcraft unit cheat sheet', - version => 'v1.0', + title => "$scver{title} unit cheat sheet", + version => 'v1.1', description => [ - 'Reference of StarCraft unit properties,' - . ' comparing various statistics of all the units in Brood War' + "Reference of $scver{game} unit properties," + . " comparing various statistics of all the units in $scver{name}" . ' including costs, damage, defense, speed, ranges, and abilities.', ], - keywords => [qw' + keywords => [ + qw' starcraft game unit statistics stats comparison table sheet cheat reference software attributes properties - '], + ', + $scver{major} < 2 ? qw' bw broodwar brood war ' : qw' starcraft2 hots ', + ], stylesheet => [qw'light'], + raw => '', data => [$datafile], }); -:> -
-Unit properties as seen or measured in Brood War -versionâ¥1.08. -
+my $units = do $datafile; +die "Cannot open unit data: $_\n" for $@ || $! || (); +my $patch = shift @{$units} + or die "Cannot open unit data: metadata not found\n"; - - -<: sub coltoggle { my ($name, $id) = @_; return sprintf( @@ -178,6 +76,12 @@ sub coltoggle { <: sub showrange { + my ($min, $max) = @_; + $_ = int($_ + .5) for $min, $max; # round halves up + return $min == $max ? $min : "$min-$max"; +} + +sub showval { my ($row, @elements) = @_; my ($min, $max); @@ -212,9 +116,7 @@ sub showrange { $min /= 4; } }} - $_ = int($_ + .5) for $min, $max; # round halves up - - return $min == $max ? $min : "$min-$max"; + return showrange($min, $max); } sub showattack { @@ -239,14 +141,15 @@ sub showrange { } $tagbase .= '">'; - my $out = showrange($row, 'attack', $area, 'damage'); + my $out = showval($row, 'attack', $area, 'damage'); $out .= '+' if $attack->{splash}; $attack->{dps} = $attack->{cooldown} && [ map { 24 * $_ / $attack->{cooldown} * ($attack->{count} // 1) } map { ref $_ ? @{$_} : $_ } $attack->{damage} + #TODO: upgrade (zergling) ]; - $out .= '