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.106 by root, Mon May 31 01:07:48 2004 UTC vs.
Revision 1.107 by root, Mon May 31 02:04:40 2004 UTC

357 357
358 delete $self->{board_click}; 358 delete $self->{board_click};
359 359
360 if ($self->{teacher} eq $self->{app}{conn}) { 360 if ($self->{teacher} eq $self->{app}{conn}) {
361 #TODO# # teaching mode not implemented 361 #TODO# # teaching mode not implemented
362 $self->{button_pass}->set (label => "Pass", sensitive => 1, visible => 1); 362 $self->{button_pass}->set (label => "Pass", visible => 1, sensitive => 1);
363 $self->{button_undo}->hide; 363 $self->{button_undo}->hide;
364 $self->{button_resign}->hide; 364 $self->{button_resign}->hide;
365 $self->{board}->set (cursor => undef); 365 $self->{board}->set (cursor => undef);
366 366
367 } elsif ($running && $self->{colour} != COLOUR_NONE) { 367 } elsif ($running && $self->{colour} != COLOUR_NONE) {
369 $self->{button_undo}->show; 369 $self->{button_undo}->show;
370 $self->{button_resign}->show; 370 $self->{button_resign}->show;
371 371
372 if ($self->{cur_board}{score}) { 372 if ($self->{cur_board}{score}) {
373 # during scoring 373 # during scoring
374 $self->{button_pass}->set (label => "Done", sensitive => 1, visible => 1); 374 $self->{button_pass}->set (label => "Done", visible => 1, sensitive => 1);
375 $self->{board}->set (cursor => sub { 375 $self->{board}->set (cursor => sub {
376 $_[0] & (MARK_B | MARK_W) 376 $_[0] & (MARK_B | MARK_W)
377 ? $_[0] ^ MARK_GRAYED 377 ? $_[0] ^ MARK_GRAYED
378 : $_[0]; 378 : $_[0];
379 }); 379 });
380 $self->{board_click} = sub { 380 $self->{board_click} = sub {
381 if ($_[0] == 255) { 381 if ($_[0] == 255) {
382 $self->{button_pass}->sensitive (0); 382 $self->{button_pass}->sensitive (0);
383 warn sprintf "SEND DONE @{$self->{done}} %x\n", $self->{doneid};#d#
383 $self->done; 384 $self->done;
384 } else { 385 } else {
385 $self->send (mark_dead => 386 $self->send (mark_dead =>
386 channel => $self->{channel}, 387 channel => $self->{channel},
387 x => $_[0], 388 x => $_[0],
391 } 392 }
392 }; 393 };
393 394
394 } elsif ($self->{colour} == $self->{whosemove}) { 395 } elsif ($self->{colour} == $self->{whosemove}) {
395 # normal move 396 # normal move
396 $self->{button_pass}->set (label => "Pass", sensitive => 1, visible => 1); 397 $self->{button_pass}->set (label => "Pass", visible => 1, sensitive => 1);
397 $self->{board}->set (cursor => sub { 398 $self->{board}->set (cursor => sub {
398 # if is_valid_move oder so#TODO# 399 # if is_valid_move oder so#TODO#
399 $_[0] & (MARK_B | MARK_W) 400 $_[0] & (MARK_B | MARK_W)
400 ? $_[0] 401 ? $_[0]
401 : $_[0] | MARK_GRAYED | ($self->{colour} == COLOUR_WHITE ? MARK_W : MARK_B); 402 : $_[0] | MARK_GRAYED | ($self->{colour} == COLOUR_WHITE ? MARK_W : MARK_B);
571 $self->destroy; 572 $self->destroy;
572} 573}
573 574
574sub event_move { 575sub event_move {
575 my ($self, $pass) = @_; 576 my ($self, $pass) = @_;
577
576 sound::play 1, $pass ? "pass" : "move"; 578 sound::play 1, $pass ? "pass" : "move";
577} 579}
578 580
579sub event_update_game { 581sub event_update_game {
580 my ($self) = @_; 582 my ($self) = @_;
685 $self->{userpanel}[$_]->configure ($self->{app}, $self->{user}[$_], $rules) 687 $self->{userpanel}[$_]->configure ($self->{app}, $self->{user}[$_], $rules)
686 for COLOUR_BLACK, COLOUR_WHITE; 688 for COLOUR_BLACK, COLOUR_WHITE;
687 } 689 }
688 690
689 sound::play 3, "gamestart"; 691 sound::play 3, "gamestart";
690
691 $self->{rules_inlay}->refresh; 692 $self->{rules_inlay}->refresh;
692} 693}
693 694
694sub event_resign_game { 695sub event_resign_game {
695 my ($self, $player) = @_; 696 my ($self, $player) = @_;
712} 713}
713 714
714sub event_done { 715sub event_done {
715 my ($self) = @_; 716 my ($self) = @_;
716 717
718 warn sprintf "EVENT DONE @{$self->{done}} %x\n", $self->{doneid};#d#
719
717 if ($self->{done}[1 - $self->{colour}] && !$self->{done}[$self->{colour}]) { 720 if ($self->{done}[1 - $self->{colour}] && !$self->{done}[$self->{colour}]) {
721 sound::play 2, "ring" unless $inlay->{count};
718 $self->{chat}->append_text ("\n<infoblock><header>Done</header>" 722 $self->{chat}->append_text ("\n<infoblock><header>Press Done</header>"
719 . "\nYour opponent pressed done."); 723 . "\nYour opponent pressed done. Now it's up to you.");
720 } 724 }
725 if ($self->{doneid} & 0x80000000) {
726 sound::play 2, "warning" unless $inlay->{count};
727 $self->{chat}->append_text ("\n<infoblock><header>Press Done Again</header>"
728 . "\nYour opponent changed the board..");
729 }
730
731 $self->{button_pass}->sensitive (!$self->{done}[$self->{colour}]);
732
733 $self->{chat}->set_end;
721} 734}
722 735
723sub inject_final_result { 736sub inject_final_result {
724 my ($self, $msg) = @_; 737 my ($self, $msg) = @_;
725 738
746 my ($self, $msg) = @_; 759 my ($self, $msg) = @_;
747 760
748 my $inlay = $self->{undo_inlay} ||= $self->{chat}->new_inlay; 761 my $inlay = $self->{undo_inlay} ||= $self->{chat}->new_inlay;
749 return if $inlay->{ignore}; 762 return if $inlay->{ignore};
750 763
751 sound::play 3, "warning" unless $inlay->{count}; 764 sound::play 2, "warning" unless $inlay->{count};
752 $inlay->{count}++; 765 $inlay->{count}++;
753 766
754 $inlay->clear; 767 $inlay->clear;
755 $inlay->append_text ("\n<undo>Undo requested ($inlay->{count} times)</undo>\n"); 768 $inlay->append_text ("\n<undo>Undo requested ($inlay->{count} times)</undo>\n");
756 $inlay->append_button ("Grant", sub { 769 $inlay->append_button ("Grant", sub {
767} 780}
768 781
769sub inject_new_game { 782sub inject_new_game {
770 my ($self, $msg) = @_; 783 my ($self, $msg) = @_;
771 784
772 $self->{chat}->append_text ("\n<header>ACK from server ($msg->{cid} == $self->{cid})</header>"); 785 if ($msg->{cid} != $self->{cid}) {
786 $self->part;
787 warn "ERROR: challenge id mismatch, PLEASE REPORT, especially the circumstances (many games open? etc..)\n";#d#
788 }
789
790 $self->{chat}->append_text ("\n<header>Game successfully created on server.</header>");
773 delete $self->{cid}; 791 delete $self->{cid};
774} 792}
775 793
776sub draw_challenge { 794sub draw_challenge {
777 my ($self, $id) = @_; 795 my ($self, $id) = @_;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines