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.94 by pcg, Tue May 25 21:08:31 2004 UTC vs.
Revision 1.95 by pcg, Fri May 28 23:19:59 2004 UTC

256 $hbox->add ($self->{userpanel}[$_] = new game::userpanel colour => $_) 256 $hbox->add ($self->{userpanel}[$_] = new game::userpanel colour => $_)
257 for COLOUR_WHITE, COLOUR_BLACK; 257 for COLOUR_WHITE, COLOUR_BLACK;
258 258
259 $vbox->pack_start (($self->{chat} = new superchat), 1, 1, 0); 259 $vbox->pack_start (($self->{chat} = new superchat), 1, 1, 0);
260 260
261 $self->{rules_inlay} = $self->{chat}->new_switchable_inlay ("Game Setup:", sub { $self->draw_rules (@_) }, 1); 261 $self->{rules_inlay} = $self->{chat}->new_switchable_inlay ("Game Setup:", sub { $self->draw_setup (@_) }, 1);
262 $self->{users_inlay} = $self->{chat}->new_switchable_inlay ("Users:", sub { $self->draw_users (@_) }, 0); 262 $self->{users_inlay} = $self->{chat}->new_switchable_inlay ("Users:", sub { $self->draw_users (@_) }, 1);
263 263
264 $self->{chat}->signal_connect (command => sub { 264 $self->{chat}->signal_connect (command => sub {
265 my ($chat, $cmd, $arg) = @_; 265 my ($chat, $cmd, $arg) = @_;
266 if ($cmd eq "rsave") { 266 if ($cmd eq "rsave") {
267 Storable::nstore { tree => $self->{tree}, curnode => $self->{curnode}, move => $self->{move} }, $arg;#d# 267 Storable::nstore { tree => $self->{tree}, curnode => $self->{curnode}, move => $self->{move} }, $arg;#d#
405 sound::play 1, $pass ? "pass" : "move"; 405 sound::play 1, $pass ? "pass" : "move";
406} 406}
407 407
408sub event_update_game { 408sub event_update_game {
409 my ($self) = @_; 409 my ($self) = @_;
410
410 $self->SUPER::event_update_game; 411 $self->SUPER::event_update_game;
411 412
412 return unless $self->{joined}; 413 return unless $self->{joined};
413 414
414 my $title = defined $self->{channel} 415 my $title = defined $self->{channel}
431 } 432 }
432 } 433 }
433 434
434 $self->{left}->show_all; 435 $self->{left}->show_all;
435 436
436 # view text 437 $self->{rules_inlay}->refresh;
437 438
438 eval { #d#
439 my @ga;
440 $ga[0] = "\nType: " . util::toxml $self->type_char;
441 $ga[1] = "\nFlags:";
442 $ga[1] .= " started" if $self->is_inprogress;
443 $ga[1] .= " adjourned" if $self->is_adjourned;
444 $ga[1] .= " scored" if $self->is_scored;
445 $ga[1] .= " saved" if $self->is_saved;
446
447 $ga[2] = "\nOwner: <user>" . (util::toxml $self->{user3}->as_string) . "</user>"
448 if $self->{user3}->is_inprogress;
449
450 $ga[3] = "\nPlayers: <user>" . (util::toxml $self->{user2}->as_string) . "</user>"
451 . " vs. <user>" . (util::toxml $self->{user1}->as_string) . "</user>"
452 if $self->is_inprogress;
453
454 if ($self->is_inprogress) {
455 $ga[4] = "\nHandicap: " . $self->{handicap};
456 $ga[5] = "\nKomi: " . $self->{komi};
457 $ga[6] = "\nSize: " . $self->size_string;
458 }
459
460 if ($self->is_scored) {
461 $ga[7] = "\nResult: " . $self->score_string;
462 }
463
464 $text = "\n<infoblock><header>Game Update</header>";
465 for (0..7) {
466 if ($self->{gatext}[$_] ne $ga[$_]) {
467 $text .= $ga[$_];
468 }
469 }
470 $text .= "</infoblock>";
471
472 $self->{gatext} = \@ga;
473 };
474
475 $self->{chat}->append_text ($text);
476} 439}
477 440
478sub draw_rules { 441sub draw_setup {
479 my ($self, $inlay) = @_; 442 my ($self, $inlay) = @_;
480 443
481 my $rules = $self->{rules}; 444 my $rules = $self->{rules};
482 445
483 my $text = ""; 446 my $text = "";
447
448 ## Rules
484 449
485 $text .= "\nRuleset: " . $ruleset{$rules->{ruleset}}; 450 $text .= "\nRuleset: " . $ruleset{$rules->{ruleset}};
486 451
487 $text .= "\nTime: "; 452 $text .= "\nTime: ";
488 453
497 } elsif ($rules->{timesys} == TIMESYS_CANADIAN) { 462 } elsif ($rules->{timesys} == TIMESYS_CANADIAN) {
498 $text .= util::format_time $rules->{time}; 463 $text .= util::format_time $rules->{time};
499 $text .= sprintf " + %s/%d CAN", util::format_time $rules->{interval}, $rules->{count}; 464 $text .= sprintf " + %s/%d CAN", util::format_time $rules->{interval}, $rules->{count};
500 } 465 }
501 466
467 ## Other state info
468
469 $text .= "\nType: " . util::toxml $self->type_char;
470 $text .= "\nFlags:";
471 $text .= " started" if $self->is_inprogress;
472 $text .= " adjourned" if $self->is_adjourned;
473 $text .= " scored" if $self->is_scored;
474 $text .= " saved" if $self->is_saved;
475
476 $text .= "\nOwner: <user>" . (util::toxml $self->{user3}->as_string) . "</user>"
477 if $self->{user3}->is_valid;
478
479 if ($self->is_inprogress) {
480 $text .= "\nPlayers: <user>" . (util::toxml $self->{user2}->as_string) . "</user>"
481 . " vs. <user>" . (util::toxml $self->{user1}->as_string) . "</user>";
482 $text .= "\nHandicap: " . $self->{handicap};
483 $text .= "\nKomi: " . $self->{komi};
484 $text .= "\nSize: " . $self->size_string;
485 }
486
487 if ($self->is_scored) {
488 $text .= "\nResult: " . $self->score_string;
489 }
490
502 $inlay->append_text ("<infoblock>$text</infoblock>"); 491 $inlay->append_text ("<infoblock>$text</infoblock>");
492
503} 493}
504 494
505sub event_update_rules { 495sub event_update_rules {
506 my ($self, $rules) = @_; 496 my ($self, $rules) = @_;
507 497

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines