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

Comparing kgsueme/kgsueme/room.pl (file contents):
Revision 1.19 by pcg, Sat May 29 02:01:43 2004 UTC vs.
Revision 1.20 by pcg, Sat May 29 06:38:27 2004 UTC

62 62
63sub inject_msg_room { 63sub inject_msg_room {
64 my ($self, $msg) = @_; 64 my ($self, $msg) = @_;
65 65
66 # secret typoe ;-) 66 # secret typoe ;-)
67 $self->{chat}->append_text("\n<header><user>" . (util::toxml $msg->{name}) 67 $self->{chat}->append_text ("\n<header><user>" . (util::toxml $msg->{name})
68 . "</user>: </header>" . (util::toxml $msg->{message})); 68 . "</user>: </header>" . (util::toxml $msg->{message}));
69} 69}
70 70
71sub event_update_users { 71sub event_update_users {
72 my ($self, $add, $update, $remove) = @_; 72 my ($self, $add, $update, $remove) = @_;
73 73
76 76
77sub event_update_games { 77sub event_update_games {
78 my ($self, $add, $update, $remove) = @_; 78 my ($self, $add, $update, $remove) = @_;
79 79
80 $self->{app}{gamelist}->update ($self, $add, $update, $remove); 80 $self->{app}{gamelist}->update ($self, $add, $update, $remove);
81
82 # try to identify any new games assigned to us. stupid protocol
83 # first updates the game, joins you and THEN tells you that
84 # which of the games you asked for this is.
85
86 for (@$add) {
87 if ($_->is_playing ($self->{conn}{name})
88 and my $game = shift @{$self->{new_game}}) {
89 $game->inject_upd_game ({ game => $_ });
90 $game->set_channel ($game->{channel});
91 }
92 }
81} 93}
82 94
83sub event_join { 95sub event_join {
84 my ($self) = @_; 96 my ($self) = @_;
85 $self->SUPER::event_join; 97 $self->SUPER::event_join;
110} 122}
111 123
112sub new_game { 124sub new_game {
113 my ($self) = @_; 125 my ($self) = @_;
114 126
115 $self->{new_game} ||= new game conn => $self->{conn}, app => $self; 127 my $d = $self->{app}{defaults};
128
129 my $game = new game conn => $self->{conn}, app => $self->{app}, roomid => $self->{channel};
130 $game->{challenge}{""} = {
131 type => $d->{type},
132 flags => 0,
133 notes => $d->{stones},
134 rules => {
135 ruleset => $d->{ruleset},
136 size => $d->{size},
137 timesys => $d->{timesys},
138 time => $d->{time},
139 interval => $d->{timesys} == TIMESYS_BYO_YOMI ? $d->{byo_time} : $d->{can_time},
140 count => $d->{timesys} == TIMESYS_BYO_YOMI ? $d->{byo_periods} : $d->{can_stones},
141 },
142
143 inlay => $game->{chat}->new_inlay,
144 };
145 $game->draw_challenge ("");
116 $self->{new_game}->show_all; 146 $game->show_all;
147
148 push @{$self->{new_game}}, $game;
117} 149}
118 150
1191; 1511;
120 152

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines