OSDN Git Service

The Buoy behaivor is changed.
[shogi-server/shogi-server.git] / test / TC_game.rb
index be3ccab..a2b8366 100644 (file)
@@ -149,7 +149,7 @@ Name+:p1
 Name-:p2
 Your_Turn:+
 Rematch_On_Draw:NO
-To_Move:+
+To_Move:-
 BEGIN Time
 Time_Unit:1sec
 Total_Time:1500
@@ -162,11 +162,12 @@ P2 * -HI *  *  *  *  * -KA *
 P3-FU-FU-FU-FU-FU-FU-FU-FU-FU
 P4 *  *  *  *  *  *  *  *  * 
 P5 *  *  *  *  *  *  *  *  * 
-P6 *  * +FU *  *  *  *  *  * 
-P7+FU+FU * +FU+FU+FU+FU+FU+FU
+P6 *  *  *  *  *  *  *  *  * 
+P7+FU+FU+FU+FU+FU+FU+FU+FU+FU
 P8 * +KA *  *  *  *  * +HI * 
 P9+KY+KE+GI+KI+OU+KI+GI+KE+KY
--
++
++7776FU,T1
 END Position
 END Game_Summary
 EOF
@@ -183,7 +184,7 @@ Name+:p1
 Name-:p2
 Your_Turn:-
 Rematch_On_Draw:NO
-To_Move:+
+To_Move:-
 BEGIN Time
 Time_Unit:1sec
 Total_Time:1500
@@ -196,11 +197,12 @@ P2 * -HI *  *  *  *  * -KA *
 P3-FU-FU-FU-FU-FU-FU-FU-FU-FU
 P4 *  *  *  *  *  *  *  *  * 
 P5 *  *  *  *  *  *  *  *  * 
-P6 *  * +FU *  *  *  *  *  * 
-P7+FU+FU * +FU+FU+FU+FU+FU+FU
+P6 *  *  *  *  *  *  *  *  * 
+P7+FU+FU+FU+FU+FU+FU+FU+FU+FU
 P8 * +KA *  *  *  *  * +HI * 
 P9+KY+KE+GI+KI+OU+KI+GI+KE+KY
--
++
++7776FU,T1
 END Position
 END Game_Summary
 EOF
@@ -264,14 +266,16 @@ END Time
 BEGIN Position
 P1-KY-KE-GI-KI-OU-KI-GI-KE-KY
 P2 * -HI *  *  *  *  * -KA * 
-P3-FU-FU-FU-FU-FU-FU * -FU-FU
-P4 *  *  *  *  *  * -FU *  * 
+P3-FU-FU-FU-FU-FU-FU-FU-FU-FU
+P4 *  *  *  *  *  *  *  *  * 
 P5 *  *  *  *  *  *  *  *  * 
-P6 *  * +FU *  *  *  *  *  * 
-P7+FU+FU * +FU+FU+FU+FU+FU+FU
+P6 *  *  *  *  *  *  *  *  * 
+P7+FU+FU+FU+FU+FU+FU+FU+FU+FU
 P8 * +KA *  *  *  *  * +HI * 
 P9+KY+KE+GI+KI+OU+KI+GI+KE+KY
 +
++7776FU,T1
+-3334FU,T1
 END Position
 END Game_Summary
 EOF
@@ -298,14 +302,16 @@ END Time
 BEGIN Position
 P1-KY-KE-GI-KI-OU-KI-GI-KE-KY
 P2 * -HI *  *  *  *  * -KA * 
-P3-FU-FU-FU-FU-FU-FU * -FU-FU
-P4 *  *  *  *  *  * -FU *  * 
+P3-FU-FU-FU-FU-FU-FU-FU-FU-FU
+P4 *  *  *  *  *  *  *  *  * 
 P5 *  *  *  *  *  *  *  *  * 
-P6 *  * +FU *  *  *  *  *  * 
-P7+FU+FU * +FU+FU+FU+FU+FU+FU
+P6 *  *  *  *  *  *  *  *  * 
+P7+FU+FU+FU+FU+FU+FU+FU+FU+FU
 P8 * +KA *  *  *  *  * +HI * 
 P9+KY+KE+GI+KI+OU+KI+GI+KE+KY
 +
++7776FU,T1
+-3334FU,T1
 END Position
 END Game_Summary
 EOF
@@ -335,5 +341,32 @@ T1
 T1
 EOF
   end
+  
+  def test_monitor_add
+    game_name = "hoge-1500-0"
+    board = ShogiServer::Board.new
+    board.initial
+    p1 = MockPlayer.new
+    p1.sente = true
+    p1.name  = "p1"
+    p2 = MockPlayer.new
+    p2.sente = false
+    p2.name  = "p2"
+    
+    game = ShogiServer::Game.new game_name, p1, p2, board 
+    handler1 = ShogiServer::MonitorHandler1.new p1
+    handler2 = ShogiServer::MonitorHandler2.new p2
+
+    assert_equal(0, game.monitors.size)
+    game.monitoron(handler1)
+    assert_equal(1, game.monitors.size)
+    game.monitoron(handler2)
+    assert_equal(2, game.monitors.size)
+    game.monitoroff(handler1)
+    assert_equal(1, game.monitors.size)
+    assert_equal(handler2, game.monitors.last)
+    game.monitoroff(handler2)
+    assert_equal(0, game.monitors.size)
+  end
 end