OSDN Git Service

[shogi-server] - shogi_server/{game,time_clock}.rb:
authorDaigo Moriwaki <beatles@users.sourceforge.jp>
Sun, 8 Sep 2013 02:02:41 +0000 (11:02 +0900)
committerDaigo Moriwaki <beatles@users.sourceforge.jp>
Sun, 8 Sep 2013 02:02:41 +0000 (11:02 +0900)
  When StopWatchClock is used, "Time_Unit:" of starting messages
  in CSA protocol supplies "1min".

changelog
shogi_server/game.rb
shogi_server/time_clock.rb

index 428124a..90ad85a 100644 (file)
--- a/changelog
+++ b/changelog
@@ -1,3 +1,10 @@
+2013-09-08  Daigo Moriwaki <daigo at debian dot org>
+
+       * [shogi-server]
+         - shogi_server/{game,time_clock}.rb:
+           When StopWatchClock is used, "Time_Unit:" of starting messages
+           in CSA protocol supplies "1min".
+
 2013-04-07  Daigo Moriwaki <daigo at debian dot org>
 
        * [shogi-server]
index 1197896..fb7ed18 100644 (file)
@@ -364,7 +364,7 @@ Name-:#{@gote.name}
 Rematch_On_Draw:NO
 To_Move:+
 BEGIN Time
-Time_Unit:1sec
+Time_Unit:#{@time_clock.time_unit}
 Total_Time:#{@total_time}
 Byoyomi:#{@byoyomi}
 Least_Time_Per_Move:#{Least_Time_Per_Move}
@@ -398,7 +398,7 @@ Your_Turn:#{sg_flag}
 Rematch_On_Draw:NO
 To_Move:#{@board.teban ? "+" : "-"}
 BEGIN Time
-Time_Unit:1sec
+Time_Unit:#{@time_clock.time_unit}
 Total_Time:#{@total_time}
 Byoyomi:#{@byoyomi}
 Least_Time_Per_Move:#{Least_Time_Per_Move}
index 08258de..6426fda 100644 (file)
@@ -53,6 +53,12 @@ class TimeClock
     return 9999999
   end
 
+  # Returns what "Time_Unit:" in CSA protocol should provide.
+  #
+  def time_unit
+    return "1sec"
+  end
+
   # If thinking time runs out, returns true; false otherwise.
   #
   def timeout?(player, start_time, end_time)
@@ -106,6 +112,10 @@ class StopWatchClock < TimeClock
     super
   end
 
+  def time_unit
+    return "1min"
+  end
+
   def time_duration(start_time, end_time)
     t = [(end_time - start_time).floor, @least_time_per_move].max
     return (t / @byoyomi) * @byoyomi