+2009-02-01 Daigo Moriwaki <daigo at debian dot org>
+
+ * [shogi-server]
+ - The shogi-server records csa files of games in an illegal
+ format. This issue has been fixed. (Closes: #14635)
+ - A ##[MONITOR] command for showing a game result such as %TORYO
+ was not correct. This issue has been fixed.
+
2009-01-13 Daigo Moriwaki <daigo at debian dot org>
- * [shogi_server]
+ * [shogi-server]
- It failed to proccess a game result, OuteKaihiMoreWin where a
checked king does not escape. This issue has been fixed.
class MonitorObserver
def update(game_result)
game_result.game.each_monitor do |monitor|
- monitor.write_safe("##[MONITOR][%s] %s\n" % [game_result.game.game_id, game_result.type])
+ monitor.write_safe("##[MONITOR][%s] %s\n" % [game_result.game.game_id, game_result.result_type])
end
end
end
attr_reader :black
# White plyer object
attr_reader :white
- # Command to send monitors such as '%%TORYO' etc...
+ # Command to send monitors such as '%TORYO' etc...
attr_reader :result_type
def initialize(game, p1, p2)
end
def log_board
- log(@game.board.to_s.gsub(/^/, "\'"))
+ log(@game.board.to_s.gsub(/^/, "\'").chomp)
end
end
black_result = "lose"
white_result = "win"
end
- log("'summary:%s:%s %s:%s %s\n" % [type,
- @black.name, black_result,
- @white.name, white_result])
+ log("'summary:%s:%s %s:%s %s" % [type,
+ @black.name, black_result,
+ @white.name, white_result])
end
end
def process
@winner.write_safe("%TORYO\n#RESIGN\n#WIN\n")
@loser.write_safe( "%TORYO\n#RESIGN\n#LOSE\n")
- log("%%TORYO\n")
+ log("%TORYO")
log_summary("abnormal")
- @result_type = "%%TORYO"
+ @result_type = "%TORYO"
notify
end
end
def process
@winner.write_safe("%KACHI\n#JISHOGI\n#WIN\n")
@loser.write_safe( "%KACHI\n#JISHOGI\n#LOSE\n")
- log("%%KACHI\n")
+ log("%KACHI")
log_summary("kachi")
- @result_type = "%%KACHI"
+ @result_type = "%KACHI"
notify
end
end
def process
@winner.write_safe("%KACHI\n#ILLEGAL_MOVE\n#WIN\n")
@loser.write_safe( "%KACHI\n#ILLEGAL_MOVE\n#LOSE\n")
- log("%%KACHI\n")
+ log("%KACHI")
log_summary("illegal kachi")
- @result_type = "%%KACHI"
+ @result_type = "%KACHI"
notify
end
end
def process
@winner.write_safe("%TORYO\n#RESIGN\n#WIN\n")
@loser.write_safe( "%TORYO\n#RESIGN\n#LOSE\n")
- log("%%TORYO\n")
+ log("%TORYO")
log_summary("toryo")
- @result_type = "%%TORYO"
+ @result_type = "%TORYO"
notify
end
end
def log_summary(type)
log_board
- log("'summary:%s:%s draw:%s draw\n" % [type, @black.name, @white.name])
+ log("'summary:%s:%s draw:%s draw" % [type, @black.name, @white.name])
end
end
# login with trip
def login
cmd "LOGIN testsente@p1 dummy x1"
- cmd "%%GAME testcase-1500-0 +"
+ cmd "%%GAME testClientAtmark-1500-0 +"
cmd2 "LOGIN testgote@p2 dummy2 x1"
- cmd2 "%%CHALLENGE testcase-1500-0 -"
+ cmd2 "%%CHALLENGE testClientAtmark-1500-0 -"
end
def test_toryo
end
assert(/#LOSE/ =~ result)
assert(/#WIN/ =~ result2)
+
+ now = Time.now
+ year = now.strftime("%Y")
+ month = now.strftime("%m")
+ day = now.strftime("%d")
+ path = File.join( File.dirname(__FILE__), "..", year, month, day, "*testClientAtmark-1500-0*")
+ log_files = Dir.glob(path)
+ assert(!log_files.empty?)
+ log_content = File.open(log_files.sort.last).read
+
+ # "$EVENT", "$START_TIME" and "'$END_TIME" are removed since they vary dinamically.
+ should_be = <<-EOF
+V2
+N+testsente@p1
+N-testgote@p2
+P1-KY-KE-GI-KI-OU-KI-GI-KE-KY
+P2 * -HI * * * * * -KA *
+P3-FU-FU-FU-FU-FU-FU-FU-FU-FU
+P4 * * * * * * * * *
+P5 * * * * * * * * *
+P6 * * * * * * * * *
+P7+FU+FU+FU+FU+FU+FU+FU+FU+FU
+P8 * +KA * * * * * +HI *
+P9+KY+KE+GI+KI+OU+KI+GI+KE+KY
++
+'rating:testsente@p1+275876e34cf609db118f3d84b799a790:testgote@p2+c0c40e7a94eea7e2c238b75273087710
++2726FU
+T1
+-3334FU
+T1
+%TORYO
+'P1-KY-KE-GI-KI-OU-KI-GI-KE-KY
+'P2 * -HI * * * * * -KA *
+'P3-FU-FU-FU-FU-FU-FU * -FU-FU
+'P4 * * * * * * -FU * *
+'P5 * * * * * * * * *
+'P6 * * * * * * * +FU *
+'P7+FU+FU+FU+FU+FU+FU+FU * +FU
+'P8 * +KA * * * * * +HI *
+'P9+KY+KE+GI+KI+OU+KI+GI+KE+KY
+'+
+'summary:toryo:testsente@p1 lose:testgote@p2 win
+EOF
+
+ log_content.gsub!(/^\$.*?\n/m, "")
+ log_content.gsub!(/^'\$.*?\n/m, "")
+ assert_equal(should_be, log_content)
end
end