sc: version-specific page metadata
[sheet.git] / sc.plp
diff --git a/sc.plp b/sc.plp
index 5607a9a236f076e4ea4adefccb6e0aeb4df1b325..3252cf3e3cb1f3965765417ad728e03df3dd0524 100644 (file)
--- a/sc.plp
+++ b/sc.plp
 <(common.inc.plp)><:
 
-my $datafile = 'sc-units.inc.pl';
+my %scver = (
+       id => 'bw',
+       name => 'Brood War',
+       patch => '<span title="no known changes as of v1.16.1">version≥1.08</span>',
+       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',
+               patch => 'patch 2.1.3 BU',
+               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 => '<link rel="stylesheet" type="text/css" media="all" href="/sc.css?1.1" title="light">',
        data => [$datafile],
 });
 
-:>
-<h1>StarCraft units</h1>
-
-<p>
-Unit properties as seen or measured in Brood War
-<span title="no known changes as of v1.16.1">version≥1.08</span>.
-</p>
+print "<h1>$scver{game} units</h1>\n\n";
+print "<p>Unit properties as seen or measured in $scver{name}\n$scver{patch}.\n</p>\n\n";
 
-<style type="text/css">
-       .units {
-               border-collapse: separate;
-               border-spacing: 0;
-               margin: 0 auto;
-               white-space: nowrap;
-       }
-       .units th, .units td {
-               border: 0;
-               padding: 0 0.2em;
-               background: transparent;
-               text-align: left;
-       }
-       tr.alt td {
-               font-size: 70%;
-               padding-left: 0.5em;
-       }
-       .units tr th:first-child {
-               padding-left: 0;
-       }
-       .units tbody tr:hover:not(.race) {
-               background: #EEE;
-       }
-
-       table h2 {
-               padding: 1ex 0;
-               margin: 0;
-               text-align: center;
-       }
-       .units thead th, .units tfoot th {
-               font-size: 70%;
-               font-weight: normal;
-       }
-
-       .unit-o {color: #C08} /* organic */
-       .unit-u {color: #44C} /* mechanic */
-       .unit-composed {
-               color: #C88;
-               font-size: 70%;
-       }
-       .unit.unit-s {color: #770}
-       .unit.unit-m {color: #C70}
-       .unit.unit-l {color: #D22}
-       .hurt.unit-s::before {
-               content: '~';
-               color: #773;
-       }
-       .hurt.unit-l::before {
-               content: '*';
-               color: #C66;
-       }
-       .hurt .unit-splash {
-               position: absolute;
-       }
-       .hurtrel, .units .hurtrel {
-               padding-left: 1em;
-               font-size: 70%;
-               color: #778;
-       }
-       .unit-splash {
-               color: #4A0;
-       }
-       .unit-detect::before {
-               content: '!';
-               color: #0A8;
-               font-size: 70%;
-               vertical-align: super;
-       }
-       .unit-magic {
-               padding-left: 0.5em;
-       }
-       .magic-perma {
-               text-decoration: underline;
-       }
-
-       .units .val {
-               white-space: nowrap;
-               text-align: right;
-       }
-
-       .legend dt {
-               float: none;
-               text-align: left;
-               margin-top: 1ex;
-               font-weight: bold;
-       }
-       .legend dd:before {
-               content: '• ';
-       }
-       .legend dd {
-               text-indent: -1em;
-               margin-left: 1em;
-       }
-
-       .legend {
-               display: table-cell;
-               min-width: 20em;
-               text-align: left;
-       }
-       .units {
-               float: left;
-               padding-bottom: 1em;
-               margin-right: 2em;
-       }
-</style>
-
-<:
 sub coltoggle {
        my ($name, $id) = @_;
        return sprintf(
@@ -337,17 +245,15 @@ sub showval {
 
                print(
                        '<tr>',
-                       sprintf('<t%s class="cat">%s',
-                               $cat ne $_->{cat} ? ('h', $cat = $_->{cat}) : ('d', '&nbsp;')
-                       ),
-                       '<td>' . $_->{name},
+                       '<th class="cat">', $cat ne $_->{cat} && ($cat = $_->{cat}),
+                       '<td>', $_->{name},
                        showunitcols($_),
                );
 
                for my $subrow (@{ $_->{special} }) {
                        $subrow->{alt} or next;
                        print(
-                               '<tr class="alt"><td class="cat"><td>' . $subrow->{alt},
+                               '<tr class="alt"><td class="cat"><td>', $subrow->{alt},
                                showunitcols($subrow),
                        );
                }