OSDN Git Service

[shogi-server] Write game results in categorical files
[shogi-server/shogi-server.git] / shogi_server / game_result.rb
index 27902b9..5e0bd36 100644 (file)
@@ -37,7 +37,9 @@ end
 #
 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)
@@ -52,11 +54,21 @@ class LoggingObserver
            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