shogi-server source
Révision | e549c6dfdb66adbe66909389f005a45526d6b144 (tree) |
---|---|
l'heure | 2020-12-14 20:42:55 |
Auteur | Mizar <mizar.jp@gmai...> |
Commiter | Mizar |
Handle timeout checks when executing KeepAlive and Space commands
@@ -157,6 +157,10 @@ module ShogiServer | ||
157 | 157 | |
158 | 158 | def call |
159 | 159 | @player.write_safe("\n") |
160 | + if (@player.status == "game") | |
161 | + s = @player.game.handle_one_move(:keepalive, @player, @time) | |
162 | + return :return if (s && @player.protocol == LoginCSA::PROTOCOL) | |
163 | + end | |
160 | 164 | return :continue |
161 | 165 | end |
162 | 166 | end |
@@ -685,6 +689,10 @@ module ShogiServer | ||
685 | 689 | |
686 | 690 | def call |
687 | 691 | ## ignore null string |
692 | + if (@player.status == "game") | |
693 | + s = @player.game.handle_one_move(:space, @player, @time) | |
694 | + return :return if (s && @player.protocol == LoginCSA::PROTOCOL) | |
695 | + end | |
688 | 696 | return :continue |
689 | 697 | end |
690 | 698 | end |
@@ -248,7 +248,7 @@ class Game | ||
248 | 248 | # class Game |
249 | 249 | def handle_one_move(str, player, end_time) |
250 | 250 | unless turn?(player) |
251 | - return false if str == :timeout | |
251 | + return false if (str == :timeout || str == :keepalive || str == :space) | |
252 | 252 | |
253 | 253 | @fh.puts("'Deferred %s" % [str]) |
254 | 254 | log_warning("Deferred a move [%s] scince it is not %s 's turn." % |
@@ -263,7 +263,7 @@ class Game | ||
263 | 263 | |
264 | 264 | if (@time_clock.timeout?(@current_player, @start_time, @end_time)) |
265 | 265 | status = :timeout |
266 | - elsif (str == :timeout) | |
266 | + elsif (str == :timeout || str == :keepalive || str == :space) | |
267 | 267 | return false # time isn't expired. players aren't swapped. continue game |
268 | 268 | else |
269 | 269 | t = @time_clock.process_time(@current_player, @start_time, @end_time) |