]> git.sesse.net Git - wloh/blobdiff - www/index.pl
Add a friendly header to the scenario analysis.
[wloh] / www / index.pl
index fd3228b7a3894676b1247e19024c9fe2350af079..d524ea7381129d43139a3fc93544a73043a51c6f 100755 (executable)
@@ -177,6 +177,10 @@ sub get_covariance_matrix {
 sub write_parms_to_file {
        my ($aux_parms, $match_stddev, $used_ratings, $used_cov) = @_;
 
+       POSIX::setlocale(&POSIX::LC_ALL, 'nb_NO.UTF-8');
+
+       my @sorted_players = sort { $players{$a} cmp $players{$b} } keys %players;
+
        POSIX::setlocale(&POSIX::LC_ALL, 'C');
 
        my $tmpnam = POSIX::tmpnam();
@@ -186,7 +190,7 @@ sub write_parms_to_file {
        printf MCCALC "%f\n", $match_stddev;
        printf MCCALC "%d\n", scalar keys %players;
 
-       for my $id (keys %players) {
+       for my $id (@sorted_players) {
                my $rating = $used_ratings->{$id} // 500.0;
                printf MCCALC "%s %f\n", $id, $rating;
        }
@@ -370,10 +374,16 @@ if (defined($match_player) && defined($match_position)) {
        close MCCALC;
        #unlink $tmpnam;
 
+       my @sorted_players = sort { $players{$a} cmp $players{$b} } keys %players;
+       my $player_name = $players{$sorted_players[$match_player]};
+
        if (scalar @scenario == 0) {
                # FIXME: distinguish between "all played" and "none found"
-               print "    <p>Fant ingen m&aring;te dette kunne skje p&aring.</p>\n";
+               printf "    <p>Fant ingen m&aring;te <strong>%s</strong> kan ende p&aring; <strong>%d.</strong> plass p&aring;.</p>\n",
+                       $player_name, ($match_position + 1);
        } else {
+               printf "    <p>Scenario der <strong>%s</strong> ender p&aring; <strong>%d.</strong> plass:</p>\n",
+                       $player_name, ($match_position + 1);
                print "    <ul>\n";
                for my $m (@scenario) {
                        printf "    <li>%s &ndash; %s: %+d</li>\n", $players{$m->[0]}, $players{$m->[1]}, $m->[2];