X-Git-Url: http://git.shiar.net/sheet.git/blobdiff_plain/3b6982ba552c02daa4de8489e90f90a274ea14fa..7daf512d5b78e196e4b3ada31ae8c5c9705456d7:/sc.plp
diff --git a/sc.plp b/sc.plp
index 4706bbf..2b8112d 100644
--- a/sc.plp
+++ b/sc.plp
@@ -1,41 +1,84 @@
<(common.inc.plp)><:
+use List::Util qw(max sum);
+
+my %scver = (
+ id => 'bw',
+ name => 'Brood War',
+ title => 'starcraft',
+ game => 'StarCraft',
+ major => 1,
+);
-my $datafile = 'sc-units.inc.pl';
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";
+print "Also see the $_ table.\n" for join(', ',
+ ('StarCraft 2: HotS') x ($scver{major} < 2),
+ ('original SC: Brood War') x ($scver{major} > 1),
+);
+print "
\n\n";
+
+sub addupgrade {
+ my ($ref, $increase) = @_;
+ if (ref $increase eq 'HASH') {
+ addupgrade(\${$ref}->{$_}, $increase->{$_}) for keys %{$increase};
+ }
+ elsif (ref $increase eq 'ARRAY') {
+ addupgrade(\${$ref}->[$_], $increase->[$_]) for 0 .. $#{$increase};
+ }
+ ${$ref} += $increase if $increase =~ /^-?[0-9.]+/;
+}
+
+for my $unit (@{$units}) {
+ for my $upgrade (@{ $unit->{upgrade} }) {
+ while (my ($col, $increase) = each %{$upgrade}) {
+ defined $unit->{$col} or next;
+ addupgrade(\( $unit->{upgraded}->{$col} //= $unit->{$col} ), $increase);
+ }
+ }
+}
-<:
sub coltoggle {
- my ($name, $id) = @_;
+ my ($name, $id, $nolink) = @_;
return sprintf(
(defined $get{order} ? $get{order} eq $id : !$id) ? '%2$s â¼'
- : '%s',
+ : $nolink ? '%2$s' : '%s',
$id && "order=$id", $name
);
}
@@ -46,12 +89,12 @@ sub coltoggle {
<:= coltoggle(qw'build cost') :>
-
<:= coltoggle(qw'size size') :>
+
<:= coltoggle(qw'size size') :>
HP
shield
-
armor
-
ground
-
air
+
â¨
+
attack
+
<:= coltoggle(qw'dps attack 1') :>
range
sight
speed
@@ -60,80 +103,78 @@ 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);
-
- my $value = $row;
- $value = ref $value eq 'HASH' && $value->{$_} or last for @elements;
- if (ref $value eq 'ARRAY') {
- $min = $value->[0];
- $max = $value->[-1];
- }
- else {
- $min = $max = $value;
- }
- defined $min or return '';
-
- if ($row->{upgrade}) {
- for (@{ $row->{upgrade} }) {
- my $increase = $_ or next;
- $increase = ref $increase eq 'HASH' && $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
- my $type = $attack->{type} or next;
- if ($type eq 'explosive') {
- $min /= 2;
- }
- elsif ($type eq 'implosive') {
- $min /= 4;
- }
- }}
- return showrange($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-$max";
}
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 '
each point decreases damage per hit by one, upto a minimum of ½
-
reduction applies to initial damage, before size penalties (so a plasma hit of 12 to 4 armor large deals 2 damage, not ½)
-
ground/air
-
damage done per single attack against ground/air units
-
2nd column indicates relative amount of damage done in
- 1 second of fastest game time
-
splash damage+ hits nearby objects as well
-
explosive damage does only
+
reduction applies to initial damage, before size penalties
+ (so a plasma hit of 12 to 4 armor large deals 2 damage, not ½)
+
attack
+
targets â½ ground
+ and/or â³ air
+
damage given per single hit
+
dps indicates relative amount of damage
+ done in 1 second of in-game time
+
splash damage hits all objects nearby +
+ or in a straight line Ã.
+
<:
+if ($scver{major} > 1) {
+ :>does not include ≥bonus damage
+ dealt to susceptible unit types<:
+} else {
+ :>*explosive damage does only
50% damage to small units, 75% to medium, 100% to large
-
concussive/plasma damage does
- 25% to large, 50% medium, 100% to small units
+
~concussive/plasma damage does
+ 25% to large, 50% medium, 100% to small units<:
+} :>
sight
range in which the unit detects other units
emphasis indicates ability to detect cloaked units