X-Git-Url: http://git.sourceforge.jp/view?p=shogi-server%2Fshogi-server.git;a=blobdiff_plain;f=shogi_server%2Fboard.rb;h=c006176290ea2afa240c137e0e616be697a07143;hp=be22ef19f03d9ca745beff162dfe29eb6f6fed34;hb=1f41193a39cbcef4b0ae68677efa3498883235e3;hpb=3ab213167ab29caa43f8040592ad172a7da3b000 diff --git a/shogi_server/board.rb b/shogi_server/board.rb index be22ef1..c006176 100644 --- a/shogi_server/board.rb +++ b/shogi_server/board.rb @@ -28,7 +28,7 @@ class Board # Initial board setup. # The string ends with '+', not a line break. # - INITIAL_POSITION = (<<-EOF).chomp + INITIAL_HIRATE_POSITION = (<<-EOF).chomp P1-KY-KE-GI-KI-OU-KI-GI-KE-KY P2 * -HI * * * * * -KA * P3-FU-FU-FU-FU-FU-FU-FU-FU-FU @@ -43,17 +43,42 @@ EOF # Split a moves line into an array of a move string. # If it fails to parse the moves, it raises WrongMoves. - # @param moves a moves line. Ex. "+776FU-3334Fu" - # @return an array of a move string. Ex. ["+7776FU", "-3334FU"] + # @param moves a moves line. Ex. "+776FU-3334FU" or + # moves with times. Ex "+776FU,T2-3334FU,T5" + # @return an array of a move string. Ex. ["+7776FU", "-3334FU"] or + # an array of arrays. Ex. [["+7776FU","T2"], ["-3334FU", "T5"]] # def Board.split_moves(moves) ret = [] - rs = moves.gsub %r{[\+\-]\d{4}\w{2}} do |s| - ret << s - "" - end - raise WrongMoves, rs unless rs.empty? + i=0 + tmp = "" + while i