OSDN Git Service

* [shogi-server]
authorbeatles <beatles@b8c68f68-1e22-0410-b08e-880e1f8202b4>
Sat, 28 Jun 2008 07:15:42 +0000 (07:15 +0000)
committerbeatles <beatles@b8c68f68-1e22-0410-b08e-880e1f8202b4>
Sat, 28 Jun 2008 07:15:42 +0000 (07:15 +0000)
  - A rating comment line is now written before the first move in a
    record file instead of after the last move, which allows other
    applications watching a game to recognize players in the middle
    of the game.

changelog
shogi_server/game.rb

index 70b2377..f394f70 100644 (file)
--- a/changelog
+++ b/changelog
@@ -1,6 +1,14 @@
 2008-06-28 Daigo Moriwaki <daigo at debian dot org>
 
        * [shogi-server]
+         - A rating comment line is now written before the first move in a
+           record file instead of after the last move, which allows other
+           applications watching a game to recognize players in the middle 
+           of the game.
+
+2008-06-27 Daigo Moriwaki <daigo at debian dot org>
+
+       * [shogi-server]
          -  Pairing players might not have shuffled players because of
             poor shuffling algorithm. This issue has been fixed.
             (Closes: #12661)
index d649e8d..154db72 100644 (file)
@@ -50,16 +50,6 @@ class GameResult
     log(@game.board.to_s.gsub(/^/, "\'"))
   end
 
-  def log_rating
-    log("'rating:%s\n" % [self.to_s]) if @game.rated?
-  end
-
-  def to_s
-    black_name = @black.rated? ? @black.player_id : @black.name
-    white_name = @white.rated? ? @white.player_id : @white.name
-    return "%s:%s" % [black_name, white_name]
-  end
-
   def notify_monitor(type)
     @game.each_monitor do |monitor|
       monitor.write_safe(sprintf("##[MONITOR][%s] %s\n", @game.game_id, type))
@@ -92,7 +82,6 @@ class GameResultWin < GameResult
                                        @black.name, black_result,
                                        @white.name, white_result])
 
-    log_rating
   end
 end
 
@@ -204,7 +193,6 @@ class GameResultDraw < GameResult
   def log_summary(type)
     log_board
     log("'summary:%s:%s draw:%s draw\n", type, @black.name, @white.name)
-    log_rating
   end
 end
 
@@ -467,6 +455,11 @@ P8 * +KA *  *  *  *  * +HI *
 P9+KY+KE+GI+KI+OU+KI+GI+KE+KY
 +
 EOM
+    if rated?
+      black_name = @sente.rated? ? @sente.player_id : @sente.name
+      white_name = @gote.rated?  ? @gote.player_id  : @gote.name
+      @fh.puts("'rating:%s:%s" % [black_name, white_name])
+    end
   end
 
   def show()