X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/3b6982ba552c02daa4de8489e90f90a274ea14fa..0b17bd18ae642a22d7c9fd5411d85ab08f36b61d:/sc.plp
diff --git a/sc.plp b/sc.plp
index 4706bbf..4fc00ba 100644
--- a/sc.plp
+++ b/sc.plp
@@ -1,36 +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],
});
-:>
-
StarCraft units
+print "
$scver{game} units
\n\n";
-
-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";
+
+print "
Unit properties as seen or measured in $scver{name}\n$patch.\n
\n\n";
-<:
sub coltoggle {
my ($name, $id) = @_;
return sprintf(
@@ -46,12 +63,12 @@ sub coltoggle {
<:= coltoggle(qw'build cost') :>
-
<:= coltoggle(qw'size size') :>
+
<:= coltoggle(qw'size size') :>
HP
shield
-
armor
-
ground
-
air
+
â¨
+
attack
+
dps
range
sight
speed
@@ -69,7 +86,8 @@ sub showval {
my ($min, $max);
my $value = $row;
- $value = ref $value eq 'HASH' && $value->{$_} or last for @elements;
+ $value = ref $value eq 'HASH' ? $value->{$_}
+ : ref $value eq 'ARRAY' && $value->[$_] or last for @elements;
if (ref $value eq 'ARRAY') {
$min = $value->[0];
$max = $value->[-1];
@@ -82,15 +100,15 @@ sub showval {
if ($row->{upgrade}) {
for (@{ $row->{upgrade} }) {
my $increase = $_ or next;
- $increase = ref $increase eq 'HASH' && $increase->{$_} or last for @elements;
+ $increase = ref $increase eq 'HASH' ? $increase->{$_}
+ : ref $increase eq 'ARRAY' && $increase->[$_] or last for @elements;
$increase = $increase->[-1] if ref $increase eq 'ARRAY';
$max += $increase if $increase;
}
}
- if ($elements[0] eq 'attack' and $elements[1] ne 'range' and $elements[2] eq 'dps') {{
- my $attack = $row->{ $elements[0] }->{ $elements[1] };
- ref $attack or $attack = $row->{ $elements[0] }->{$attack}; # follow
+ if ($elements[0] eq 'attack' and $elements[2] eq 'dps') {{
+ my $attack = $row->{ $elements[0] }->[ $elements[1] ];
my $type = $attack->{type} or next;
if ($type eq 'explosive') {
$min /= 2;
@@ -104,16 +122,13 @@ sub showval {
sub showattack {
my ($row, $area) = @_;
- my $attack = $row->{attack}->{$area};
- if (not ref $attack) {
- # reference to another area
- $area = $attack;
- $attack = $row->{attack}->{$area};
- }
+ my $attack = $row->{attack}->[$area]
+ or return '