game => 'StarCraft II LotV',
major => 2,
},
+ index => 'bw',
+ 1 => 'bw',
+ 2 => 'lotv',
);
-$Request ||= 'bw';
-$Request = 'lotv' if $Request eq '2';
-my %scver = %{ $scvers{$Request} // {} }
+my $requestver = $scvers{$Request ||= 'index'}
or Html(), Abort("Requested version <q>$Request</q> not available", '404 request not found');
-my $datafile = "sc-units-$Request.inc.pl";
+if (ref $requestver ne 'HASH') {
+ $header{Location} = "/sc/$requestver";
+ Abort("Canonical URL for $Request is at $requestver", '302 subpage alias');
+}
+
+my %scver = %{$requestver};
+my $datafile = "sc-units-$Request";
Html({
title => "$scver{title} unit cheat sheet",
- version => '1.2',
+ version => '1.3',
description => [
"Reference of $scver{game} unit properties,"
. " comparing various statistics of all the units in $scver{name}"
],
stylesheet => [qw( light dark )],
raw => '<link rel="stylesheet" type="text/css" media="all" href="/sc.css?1.2">',
- data => [$datafile],
+ data => ["$datafile.inc.pl"],
});
say "<h1>$scver{game} units</h1>\n";
-my $units = do $datafile;
-Abort("Cannot open unit data", 501, $_) for $@ || $! || ();
+my $units = Data($datafile);
my $patch = shift @{$units}
or Abort("Cannot open unit data: metadata not found", 501);
sprintf('+%s vs %s',
showrangeint(
$attack->{bonus}->{$_},
- $attack->{bonus}->{$_} + $attack->{bonus}->{"-$_"} * 3,
+ ($upattack->{bonus} // $attack->{bonus})->{$_}
+ + ($upattack->{bonus} // $attack->{bonus})->{"-$_"} * 3,
),
$_,
),