OSDN Git Service

util/statistics.rb: Updated to investigate floodgate-600-10 games.
[shogi-server/shogi-server.git] / shogi_server / player.rb
index 08425f5..c7dc8a4 100644 (file)
@@ -1,7 +1,7 @@
 ## $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
@@ -27,6 +27,7 @@ class BasicPlayer
     @name = nil
     @password = nil
     @rate = 0
+    @estimated_rate = 0
     @win  = 0
     @loss = 0
     @last_game_win = false
@@ -48,6 +49,10 @@ class BasicPlayer
   # Score in the rating sysem
   attr_accessor :rate
 
+  # Estimated rate for unrated player (rate == 0)
+  # But this value is not persisted and cleared when player logs off.
+  attr_accessor :estimated_rate
+
   # Number of games for win and loss in the rating system
   attr_accessor :win, :loss
   
@@ -143,6 +148,7 @@ class Player < BasicPlayer
     @main_thread = Thread::current
     @write_queue = ShogiServer::TimeoutQueue.new(WRITE_THREAD_WATCH_INTERVAL)
     @player_logger = nil
+    @last_command_at = Time.now
     start_write_thread
   end
 
@@ -150,6 +156,8 @@ class Player < BasicPlayer
   attr_accessor :protocol, :eol, :game, :mytime
   attr_accessor :main_thread
   attr_reader :socket_buffer
+  # It is updated whenever a player sends a new command
+  attr_accessor :last_command_at
   
   def setup_logger(dir)
     log_file = File.join(dir, "%s.log" % [simple_player_id])
@@ -317,6 +325,7 @@ class Player < BasicPlayer
           # do nothing
         else
           # TODO never reach
+          log_error("Detected a wrong return value for %s" % [cmd])
         end
 
       ensure