## $Id$
## Copyright (C) 2004 NABEYA Kenichi (aka nanami@2ch)
-## Copyright (C) 2007-2008 Daigo Moriwaki (daigo at debian dot org)
+## Copyright (C) 2007-2012 Daigo Moriwaki (daigo at debian dot org)
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
#
class LoggingObserver
def initialize
- @logfile = File.join($league.dir, "00LIST")
+ @logfile = File.join($league.dir, "00LIST")
+ @logfile_floodgate = File.join($league.dir, "00LIST.floodgate")
+ @logfile_others = File.join($league.dir, "00LIST.others")
end
def update(game_result)
black_name,
white_name,
game_result.white_result,
- game_result.game.logfile]
+ game_result.game.logfile,
+ game_result.game.board.move_count]
begin
+ files = [@logfile]
+ if League::Floodgate.game_name?(game_result.game.game_name)
+ files << @logfile_floodgate
+ else
+ files << @logfile_others
+ end
# Note that this is proccessed in the gian lock.
- File.open(@logfile, "a") do |f|
- f << msg.join("\t") << "\n"
+ str = msg.join("\t")
+ files.each do |file|
+ File.open(file, "a") do |f|
+ f.puts str
+ end
end
rescue => e
# ignore
elsif !p1.sente && p2.sente
@black, @white = p2, p1
else
- raise "Never reached!"
+ raise "Never reached!: %s p1: %s p2: %s" % [game.game_id, p1.sente, p2.sente]
end
@players.each do |player|
player.status = "connected"
def process
@winner.write_safe("#TIME_UP\n#WIN\n")
@loser.write_safe( "#TIME_UP\n#LOSE\n")
- # no log
+ log("%TIME_UP") # a player in turn lost
log_summary
notify
end
@players.each do |player|
player.write_safe("#SENNICHITE\n#DRAW\n")
end
+ log("%SENNICHITE")
+ log_summary
+ notify
+ end
+end
+
+class GameResultMaxMovesDraw < GameResultDraw
+ def initialize(game, winner, loser)
+ super
+ @log_summary_type = "max_moves"
+ @result_type = "#MAX_MOVES"
+ end
+
+ def process
+ @players.each do |player|
+ player.write_safe("#MAX_MOVES\n#CENSORED\n")
+ end
# no log
log_summary
notify