Re-spinned initial commit
[asr.git] / index.pl
blob2f606aa3621622ec9f15983ff86a2f1d9a2574fd
1 #!/usr/bin/perl
3 use strict;
4 use warnings;
5 use ASR;
6 use POSIX qw/strftime/;
7 use Carp qw/cluck/;
8 $SIG{__WARN__} = sub { cluck $_[0] };
10 my $ctx = ASR::Ladder->new;
12 $ctx->header();
14 print "<div id=\"ladder\"><h2>Blitz Ladder Listing</h2>\n";
15 print "<p id=\"skiptable\"><a href=\"#instructions\">Go to instructions</a></p>\n";
17 print "<table><tr><th>#</th><th>Player</th><th>Score</th><th>Win</th><th>Loss</th><th>Ratio</th><th>Last Game</th><th>...score&Delta;</th><th>Streak</th></tr>\n";
18 my $q = $ctx->{dbi}->prepare("SELECT * FROM ladder");
19 $q->execute();
20 my $i = 1;
21 while (my $r = $q->fetchrow_arrayref) {
22 my $id = $r->[0];
23 $r->[0] = $i++;
24 $r->[1] = $ctx->plink($id, $r->[1]);
25 print "<tr><!--$id--><td>".join("</td><td>", @$r)."</td></tr>\n";
27 print "</table></div>\n";
29 print <<EOT;
31 <div id="extrastuff">
33 <div id="instructions">
34 <h2>How It Works</h2>
35 <p>New ladder games are automatically checked every hour (at :54); you do not need to report them to anybody. A ladder game must be <strong>19x19, 1:00 + <i>n</i>&times;0:10</strong> (<i>n</i> is 1 to 5), type <i>{free, ranked or simul}</i>, longer than 30 moves, both players must be ladder members and one of the players must say <strong>'ASR ladder'</strong> during the first 30 moves. Handicap, komi, ruleset, adding time later and granting undo is choice of players and does not affect the scoring!</p>
36 <p>To join the ladder, just leave pasky (pasky\@ucw.cz) a message. New ladder players start at 100 points, and for each game they win they get <tt>((score<sub>loser</sub> - score<sub>winner</sub>) / $ctx->{scoring}->{winportion})</tt> points, but at least $ctx->{scoring}->{winfloor} point per win. No points are deducted for losses, but <em>all</em> players lose $ctx->{scoring}->{dailydrop} points per day. Players who do not play any games for a month are dropped from the ladder.</p>
38 <h2>Prize Rules</h2>
39 <p>In case a prize is announced for some month (see ASR room message), on the end of the month, score is normalized: people who played no games in that month are removed from the ladder, score less than 100 is reset to 100, score more than 200 is capped to 200 and for all score over 100, the amount over 100 is halved. Also, one person cannot win the prize twice in a row.</p>
40 </div>
42 <div id="scoremodel">
43 <h2>Score Change Modelling</h2>
44 <form action="modelscore.pl" method="post">
45 <p>Game of <input type="text" name="p1"> vs <input type="text" name="p2"> <input type="submit" name="s" value="Project score change"></p>
46 </form>
47 </div>
49 <p id="adminlink"><a href="admin.pl">Admin interface</a></p>
50 <p id="sourcelink"><a href="http://repo.or.cz/w/asr.git">Source code</a></p>
52 </div>
54 EOT
56 $ctx->footer;