X-Git-Url: http://git.sourceforge.jp/view?p=shogi-server%2Fshogi-server.git;a=blobdiff_plain;f=shogi_server%2Fpiece.rb;h=93d085fb7cfae8bb9296dd74189374ec19118c5f;hp=4275c0bcd8902599be75fd8c1d893df7b39fd44a;hb=8f6cbe23183482e03df482ab7c2b27dcf124f4e7;hpb=c81f26d9288d31bedec7e9cbc97ba0e8d90a32d7 diff --git a/shogi_server/piece.rb b/shogi_server/piece.rb index 4275c0b..93d085f 100644 --- a/shogi_server/piece.rb +++ b/shogi_server/piece.rb @@ -203,6 +203,52 @@ class PieceFU < Piece end end +class PieceKY < Piece + def initialize(*arg) + @point = 1 + @normal_moves = [] + @promoted_moves = [[0, +1], [+1, +1], [-1, +1], [+1, +0], [-1, +0], [0, -1]] + @name = "KY" + @promoted_name = "NY" + super + end + def room_of_head?(x, y, name) + if (name == "KY") + if (@sente) + return false if (y == 1) + else + return false if (y == 9) + end + end + return true + end + def far_movable_grids + grids = Array::new + if (@promoted) + return [] + else + if (@sente) # up + cand_x = @x + cand_y = @y - 1 + while (jump_to?(cand_x, cand_y)) + grids.push([cand_x, cand_y]) + break if (! put_to?(cand_x, cand_y)) + cand_y = cand_y - 1 + end + else # down + cand_x = @x + cand_y = @y + 1 + while (jump_to?(cand_x, cand_y)) + grids.push([cand_x, cand_y]) + break if (! put_to?(cand_x, cand_y)) + cand_y = cand_y + 1 + end + end + return grids + end + end +end + class PieceKE < Piece def initialize(*arg) @point = 1