• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

shogi-server source


Commit MetaInfo

Révision5ab1c0e8f9708d64d932876f2dd1cd8706e98091 (tree)
l'heure2017-09-02 20:14:43
AuteurDaigo Moriwaki <daigo@debi...>
CommiterDaigo Moriwaki

Message de Log

[shogi-server] Write more game results in record files

As the CSA Record Format standard states, "%TIME_UP" and
"%SENNICHITE" are now recorded in CSA files when a game ends for
timed up or sennichite respectively.
(Closes #37490)

Change Summary

Modification

--- a/changelog
+++ b/changelog
@@ -1,3 +1,11 @@
1+2017-09-02 Daigo Moriwaki <daigo at debian dot org>
2+
3+ * [shogi-server] Write more game results in record files
4+ As the CSA Record Format standard states, "%TIME_UP" and
5+ "%SENNICHITE" are now recorded in CSA files when a game ends for
6+ timed up or sennichite respectively.
7+ (Closes #37490)
8+
19 2017-02-26 Daigo Moriwaki <daigo at debian dot org>
210
311 * utils/csa-filter.rb: Allow csa-filter.rb to filter games by a winner or loser
--- a/shogi_server/game_result.rb
+++ b/shogi_server/game_result.rb
@@ -194,7 +194,7 @@ class GameResultTimeoutWin < GameResultWin
194194 def process
195195 @winner.write_safe("#TIME_UP\n#WIN\n")
196196 @loser.write_safe( "#TIME_UP\n#LOSE\n")
197- # no log
197+ log("%TIME_UP") # a player in turn lost
198198 log_summary
199199 notify
200200 end
@@ -337,7 +337,7 @@ class GameResultSennichiteDraw < GameResultDraw
337337 @players.each do |player|
338338 player.write_safe("#SENNICHITE\n#DRAW\n")
339339 end
340- # no log
340+ log("%SENNICHITE")
341341 log_summary
342342 notify
343343 end
--- a/test/TC_game_result.rb
+++ b/test/TC_game_result.rb
@@ -10,12 +10,20 @@ $league.event = "TC_game_result"
1010 module ShogiServer
1111 class BasicPlayer
1212 attr_accessor :sente, :status
13+
14+ def write_safe(dummy)
15+ end
1316 end
1417 end
1518
1619 class TestGameResult < Test::Unit::TestCase
1720 class DummyGame
1821 attr_accessor :game_name
22+ attr_reader :board
23+
24+ def initialize
25+ @board = ""
26+ end
1927 end
2028
2129 def setup
@@ -105,10 +113,28 @@ class TestGameResult < Test::Unit::TestCase
105113
106114 def test_game_result_sennichite_draw
107115 gr = ShogiServer::GameResultSennichiteDraw.new(@game, @p1, @p2)
116+ $cache_state = []
117+ def gr.log(s)
118+ $cache_state << s
119+ end
108120 assert_equal(@p1.last_game_win, false)
109121 assert_equal(@p2.last_game_win, false)
110122 assert_equal("sennichite", gr.log_summary_type)
123+
124+ gr.delete_observers
125+ gr.process
126+ assert_equal("%SENNICHITE", $cache_state[0])
111127 end
112128
129+ def test_game_result_timeout
130+ gr = ShogiServer::GameResultTimeoutWin.new(@game, @p2, @p1)
131+ $cache_state = []
132+ def gr.log(s)
133+ $cache_state << s
134+ end
135+ gr.delete_observers
136+ gr.process
137+ assert_equal("%TIME_UP", $cache_state[0])
138+ end
113139 end
114140