<(common.inc.plp)><:
+use List::Util qw(max sum);
my %scver = (
id => 'bw',
my $patch = shift @{$units}
or die "Cannot open unit data: metadata not found\n";
-print "<p>Unit properties as seen or measured in $scver{name}\n$patch.\n</p>\n\n";
+print "<p>Unit properties as seen or measured in $scver{name}\n$patch.\n";
+print "Also see the $_ table.\n" for join(', ',
+ ('<a href="/sc/2">StarCraft 2: HotS</a>') x ($scver{major} < 2),
+ ('<a href="/sc">original SC: Brood War</a>') x ($scver{major} > 1),
+);
+print "</p>\n\n";
sub addupgrade {
my ($ref, $increase) = @_;
}
sub coltoggle {
- my ($name, $id) = @_;
+ my ($name, $id, $nolink) = @_;
return sprintf(
(defined $get{order} ? $get{order} eq $id : !$id) ? '%2$s ▼'
- : '<a href="?%s">%s</a>',
+ : $nolink ? '%2$s' : '<a href="?%s">%s</a>',
$id && "order=$id", $name
);
}
<th class="val unit-shield">shield</th>
<th class="val unit-armor" title="armor">⛨</th>
<th class="val hurt" colspan=3>attack</th>
- <th class="hurt hurtrel">dps</th>
+ <th class="hurt hurtrel"><:= coltoggle(qw'dps attack 1') :></th>
<th class="val unit-range">range</th>
<th class="val unit-sight">sight</th>
<th class="val unit-speed">speed</th>
$_ eq 'armored' ? 'unit-l' :
$_ eq 'organic' ? 'unit-o' :
$_ =~ /^massive/ ? 'unit-h' :
+ $_ eq 'shields' ? 'unit-shield' :
'',
} join '_', keys %{ $attack->{bonus} }),
join(', ', map {(
}
}
$damage *= ($attack->{count} // 1) / $attack->{cooldown};
+ if (my $bonus = $upattack->{bonus} // $attack->{bonus}) {
+ $maxdamage += $_ for max(
+ map { ref $_ ? $_->[-1] : $_ } values %{$bonus}
+ );
+ }
$maxdamage *= ($upattack->{count} // $attack->{count} // 1)
/ ($upattack->{cooldown} // $attack->{cooldown});
$out .= showrange($damage, $maxdamage);
$grouped = 0;
$get{order} ||= '';
if ($get{order} eq 'size') {
- $_->{order} = $_->{unit}*8 + $_->{suit} + $_->{hp}/512 + $_->{min}/8192 for @$units;
+ $_->{order} = (
+ $_->{unit}*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 for @$units;
+ $_->{order} = (
+ $_->{gas}*1.5 + $_->{min} + $_->{unit}/8 + $_->{build}/256/8
+ ) for @$units;
+ }
+ elsif ($get{order} eq 'attack') {
+ $_->{order} = $_->{hp} / 1024 + $_->{shield} / 1008 + max(
+ map {
+ ((map { ref $_ ? $_->[-1] : $_ } $_->{damage})[0])
+ * ($_->{count} // 1) / ($_->{cooldown} // 1)
+ * ($_->{splash} ? 1.01 : 1)
+ * ($_->{type} eq 'implosive' ? .96 : 1)
+ * ($_->{type} eq 'explosive' ? .98 : 1)
+ } @{ $_->{attack} }
+ ) for @$units;
}
else {
$units->[$_]->{order} = $_ for 0 .. $#$units;