… | |
… | |
35 | $self->{app}->do_command ($chat, $cmd, $arg, userlist => $self->{userlist}, room => $self); |
35 | $self->{app}->do_command ($chat, $cmd, $arg, userlist => $self->{userlist}, room => $self); |
36 | }); |
36 | }); |
37 | |
37 | |
38 | $hbox->pack_start ((my $vbox = new Gtk2::VBox), 0, 1, 0); |
38 | $hbox->pack_start ((my $vbox = new Gtk2::VBox), 0, 1, 0); |
39 | |
39 | |
40 | $vbox->pack_start ((my $button = new_with_label Gtk2::Button "Close"), 0, 1, 0); |
40 | $vbox->pack_start ((my $button = new_with_label Gtk2::Button "Leave"), 0, 1, 0); |
41 | $button->signal_connect (clicked => sub { $self->part }); |
41 | $button->signal_connect (clicked => sub { $self->part }); |
42 | |
42 | |
43 | $vbox->pack_start ((my $button = new_with_label Gtk2::Button "New Game"), 0, 1, 0); |
43 | $vbox->pack_start ((my $button = new_with_label Gtk2::Button "New Game"), 0, 1, 0); |
44 | $button->signal_connect (clicked => sub { $self->new_game }); |
44 | $button->signal_connect (clicked => sub { $self->new_game }); |
45 | |
45 | |
… | |
… | |
82 | # try to identify any new games assigned to us. stupid protocol |
82 | # try to identify any new games assigned to us. stupid protocol |
83 | # first updates the game, joins you and THEN tells you that |
83 | # first updates the game, joins you and THEN tells you that |
84 | # which of the games you asked for this is. |
84 | # which of the games you asked for this is. |
85 | |
85 | |
86 | for (@$add) { |
86 | for (@$add) { |
87 | if ($_->player_colour ($self->{conn}{name}) |
87 | if (($_->{black}{name} eq $self->{conn}{name} |
|
|
88 | || $_->{white}{name} eq $self->{conn}{name} |
|
|
89 | || $_->{owner}{name} eq $self->{conn}{name}) |
88 | and my $game = shift @{$self->{new_game}}) { |
90 | && (my $game = shift @{$self->{new_game}})) { |
89 | $game->inject_upd_game ({ game => $_ }); |
91 | $game->inject_upd_game ({ game => $_ }); |
90 | $game->set_channel ($game->{channel}); |
92 | $game->set_channel ($game->{channel}); |
91 | } |
93 | } |
92 | } |
94 | } |
93 | } |
95 | } |
… | |
… | |
122 | } |
124 | } |
123 | |
125 | |
124 | sub new_game { |
126 | sub new_game { |
125 | my ($self) = @_; |
127 | my ($self) = @_; |
126 | |
128 | |
127 | my $d = $self->{app}{defaults}; |
|
|
128 | |
|
|
129 | my $game = new game conn => $self->{conn}, app => $self->{app}, roomid => $self->{channel}; |
129 | my $game = new game conn => $self->{conn}, app => $self->{app}, roomid => $self->{channel}; |
130 | $game->{challenge}{""} = { |
130 | $game->new_game_challenge; |
131 | gametype => $d->{gametype}, |
|
|
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 (""); |
|
|
146 | $game->show_all; |
131 | $game->show_all; |
147 | |
132 | |
148 | push @{$self->{new_game}}, $game; |
133 | push @{$self->{new_game}}, $game; |
149 | } |
134 | } |
150 | |
135 | |