shogi-server source
Révision | 5ab1c0e8f9708d64d932876f2dd1cd8706e98091 (tree) |
---|---|
l'heure | 2017-09-02 20:14:43 |
Auteur | Daigo Moriwaki <daigo@debi...> |
Commiter | Daigo Moriwaki |
[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)
@@ -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 | + | |
1 | 9 | 2017-02-26 Daigo Moriwaki <daigo at debian dot org> |
2 | 10 | |
3 | 11 | * utils/csa-filter.rb: Allow csa-filter.rb to filter games by a winner or loser |
@@ -194,7 +194,7 @@ class GameResultTimeoutWin < GameResultWin | ||
194 | 194 | def process |
195 | 195 | @winner.write_safe("#TIME_UP\n#WIN\n") |
196 | 196 | @loser.write_safe( "#TIME_UP\n#LOSE\n") |
197 | - # no log | |
197 | + log("%TIME_UP") # a player in turn lost | |
198 | 198 | log_summary |
199 | 199 | notify |
200 | 200 | end |
@@ -337,7 +337,7 @@ class GameResultSennichiteDraw < GameResultDraw | ||
337 | 337 | @players.each do |player| |
338 | 338 | player.write_safe("#SENNICHITE\n#DRAW\n") |
339 | 339 | end |
340 | - # no log | |
340 | + log("%SENNICHITE") | |
341 | 341 | log_summary |
342 | 342 | notify |
343 | 343 | end |
@@ -10,12 +10,20 @@ $league.event = "TC_game_result" | ||
10 | 10 | module ShogiServer |
11 | 11 | class BasicPlayer |
12 | 12 | attr_accessor :sente, :status |
13 | + | |
14 | + def write_safe(dummy) | |
15 | + end | |
13 | 16 | end |
14 | 17 | end |
15 | 18 | |
16 | 19 | class TestGameResult < Test::Unit::TestCase |
17 | 20 | class DummyGame |
18 | 21 | attr_accessor :game_name |
22 | + attr_reader :board | |
23 | + | |
24 | + def initialize | |
25 | + @board = "" | |
26 | + end | |
19 | 27 | end |
20 | 28 | |
21 | 29 | def setup |
@@ -105,10 +113,28 @@ class TestGameResult < Test::Unit::TestCase | ||
105 | 113 | |
106 | 114 | def test_game_result_sennichite_draw |
107 | 115 | gr = ShogiServer::GameResultSennichiteDraw.new(@game, @p1, @p2) |
116 | + $cache_state = [] | |
117 | + def gr.log(s) | |
118 | + $cache_state << s | |
119 | + end | |
108 | 120 | assert_equal(@p1.last_game_win, false) |
109 | 121 | assert_equal(@p2.last_game_win, false) |
110 | 122 | assert_equal("sennichite", gr.log_summary_type) |
123 | + | |
124 | + gr.delete_observers | |
125 | + gr.process | |
126 | + assert_equal("%SENNICHITE", $cache_state[0]) | |
111 | 127 | end |
112 | 128 | |
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 | |
113 | 139 | end |
114 | 140 |