1 $:.unshift File.dirname(__FILE__)
2 $:.unshift File.join(File.dirname(__FILE__), "..")
3 $topdir = File.expand_path File.dirname(__FILE__)
5 require "shogi_server/buoy.rb"
7 class TestFork < BaseClient
8 def parse_game_name(player)
11 if /##\[LIST\] (.*)/ =~ player.message
17 @admin = SocketPlayer.new "dummy", "admin", false
25 result, result2 = handshake do
26 @admin.puts "%%FORK wronggame-900-0 buoy_WrongGame-900-0"
30 assert /##\[ERROR\] wrong source game name/ =~ @admin.message
34 def test_too_short_fork
35 @admin = SocketPlayer.new "dummy", "admin", false
43 result, result2 = handshake do
44 source_game = parse_game_name(@admin)
45 @admin.puts "%%FORK #{source_game} buoy_TooShortFork-900-0 0"
49 assert /##\[ERROR\] number of moves to fork is out of range/ =~ @admin.message
54 buoy = ShogiServer::Buoy.new
56 @admin = SocketPlayer.new "dummy", "admin", "*"
64 assert buoy.is_new_game?("buoy_Fork-1500-0")
66 result, result2 = handshake do
67 source_game = parse_game_name(@admin)
68 @admin.puts "%%FORK #{source_game} buoy_Fork-1500-0"
72 assert buoy.is_new_game?("buoy_Fork-1500-0")
73 @p1 = SocketPlayer.new "buoy_Fork", "p1", true
74 @p2 = SocketPlayer.new "buoy_Fork", "p2", false
94 assert /^Total_Time:1500/ =~ @p1.message
95 assert /^Total_Time:1500/ =~ @p2.message
109 buoy = ShogiServer::Buoy.new
111 @admin = SocketPlayer.new "dummy", "admin", "*"
119 result, result2 = handshake do
120 source_game = parse_game_name(@admin)
121 @admin.puts "%%FORK #{source_game}" # nil for new_buoy_game name
123 assert /##\[FORK\]: new buoy game name: buoy_TestFork_1-1500-0/ =~ @admin.message
126 assert buoy.is_new_game?("buoy_TestFork_1-1500-0")
127 @p1 = SocketPlayer.new "buoy_TestFork_1", "p1", true
128 @p2 = SocketPlayer.new "buoy_TestFork_1", "p2", false
149 assert /^Total_Time:1500/ =~ @p1.message
150 assert /^Total_Time:1500/ =~ @p2.message