ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/kgsueme/kgsueme/game.pl
(Generate patch)

Comparing kgsueme/kgsueme/game.pl (file contents):
Revision 1.33 by pcg, Mon Jun 2 14:36:10 2003 UTC vs.
Revision 1.34 by pcg, Tue Jun 3 04:45:43 2003 UTC

16 $self->{format} = sub { "ERROR" }; 16 $self->{format} = sub { "ERROR" };
17 17
18 $self; 18 $self;
19} 19}
20 20
21sub append_text {
22 my ($self, $text) = @_;
23
24 $self->{buffer}->insert ($self->{buffer}->get_end_iter, $text);
25}
26
27sub format_time { 21sub format_time($) {
28 my ($time) = @_; 22 my ($time) = @_;
29 23
30 $time > 60*60 24 $time > 60*60
31 ? sprintf "%d:%02d:%02d", $time / (60 * 60), $time / 60 % 60, $time % 60 25 ? sprintf "%d:%02d:%02d", $time / (60 * 60), $time / 60 % 60, $time % 60
32 : sprintf "%d:%02d", $time / 60 % 60, $time % 60; 26 : sprintf "%d:%02d", $time / 60 % 60, $time % 60;
46 40
47 $self->{format} = sub { 41 $self->{format} = sub {
48 if ($_[0] > $low) { 42 if ($_[0] > $low) {
49 format_time $_[0] - $low; 43 format_time $_[0] - $low;
50 } else { 44 } else {
51 sprintf "%s (%d)", (format_time int ($_[0] % $interval) || $interval), $_[0] / $interval; 45 sprintf "%s (%d)",
46 format_time int ($_[0] % $interval) || $interval,
47 $_[0] / $interval;
52 } 48 }
53 }; 49 };
54 50
55 } elsif ($timesys == TIMESYS_CANADIAN) { 51 } elsif ($timesys == TIMESYS_CANADIAN) {
56 my $low = $interval;
57
58 $self->{set} = sub { $self->{time} = $_[0]; $self->{moves} = $_[1] }; 52 $self->{set} = sub { $self->{time} = $_[0]; $self->{moves} = $_[1] };
59 53
60 $self->{format} = sub { 54 $self->{format} = sub {
61 if ($_[0] > $low) { 55 if (!$self->{moves}) {
62 format_time $_[0] - $low; 56 format_time $_[0] - $low;
63 } else { 57 } else {
64 sprintf "%s / %d", (format_time int($_[0] % $interval) || $interval), $self->{moves}; 58 my $time = int($_[0] % $interval) || $interval;
59 sprintf "%s/%d (%d)",
60 format_time $time,
61 $self->{moves},
62 int ($time / ($self->{moves} || 1));
63
65 } 64 }
66 }; 65 };
67 66
68 } else { 67 } else {
69 # none, or unknown 68 # none, or unknown
159 $self->{imagebox}->add (gtk::image_from_data undef); 158 $self->{imagebox}->add (gtk::image_from_data undef);
160 $self->{imagebox}->show_all; 159 $self->{imagebox}->show_all;
161 160
162 # the big picture... 161 # the big picture...
163 appwin::userpic ($rules->{player}[$self->{colour}], sub { 162 appwin::userpic ($rules->{player}[$self->{colour}], sub {
163 return unless $self->{imagebox};
164 if ($_[0]) { 164 if ($_[0]) {
165 $self->{imagebox}->remove ($_) for $self->{imagebox}->get_children; 165 $self->{imagebox}->remove ($_) for $self->{imagebox}->get_children;
166 $self->{imagebox}->add (gtk::image_from_data $_[0]); 166 $self->{imagebox}->add (gtk::image_from_data $_[0]);
167 $self->{imagebox}->show_all; 167 $self->{imagebox}->show_all;
168 } 168 }
697 my ($self, $node, $comment, $newnode) = @_; 697 my ($self, $node, $comment, $newnode) = @_;
698 $self->SUPER::event_update_comments($node, $comment, $newnode); 698 $self->SUPER::event_update_comments($node, $comment, $newnode);
699 699
700 my $text; 700 my $text;
701 701
702 $text .= "\n<header>Move <move>$node->{move}</move>, <header>Node <node>$node->{id}</node></header>" 702 $text .= "\n<header>Move <move>$node->{move}</move>, Node <node>$node->{id}</node></header>"
703 if $newnode; 703 if $newnode;
704 704
705 for (split /\n/, $comment) { 705 for (split /\n/, $comment) {
706 $text .= "\n"; 706 $text .= "\n";
707 if ($_ =~ s/^([0-9a-zA-Z]+ \[[0-9dkp\?\-]+\])://) { 707 if ($_ =~ s/^([0-9a-zA-Z]+ \[[0-9dkp\?\-]+\])://) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines