parsegame(): Support for saving away sgf copies for debugging
[asr.git] / player.pl
blob443c15c766d5c4b356aa9e1057b8ab557ee2de1f
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('Player Info');
14 my $prec = $ctx->db_selectrow("SELECT * FROM player_info WHERE id = ?", {}, $ctx->param('pid'));
15 if (not $prec) {
16 print $ctx->p("Player not found.");
17 $ctx->footer;
18 exit;
21 print $ctx->p("Player <strong>$prec->{nick}</strong> ($prec->{score}) with id $prec->{id}. KGS games last refreshed on $prec->{last_update}");
23 print <<EOT;
24 <h2>Ladder Games List</h2>
25 <table id="gamelist">
26 <tr><th>White</th><th>Black</th><th>Date</th><th>Score\&Delta;</th></tr>
27 EOT
28 my $q = $ctx->{dbi}->prepare("SELECT * FROM player_game WHERE bid = ? OR wid = ?");
29 $q->execute($prec->{id}, $prec->{id});
30 while (my $r = $q->fetchrow_hashref) {
31 my $class = ($r->{winid} == $prec->{id} ? 'winner' : 'loser');
32 print "<tr class=\"$class\"><td>".$ctx->plink($r->{'wid'}, $r->{'wnick'})."</td><td>".$ctx->plink($r->{'bid'}, $r->{'bnick'})."</td><td><a href=\"$r->{url}\">$r->{date}</a></td><td>".($class eq 'winner' ? '+'.$r->{scoredelta} : 0)."</td></tr>\n";
34 print "</table>\n";
36 $ctx->footer;