OSDN Git Service

players.yaml is now read only. The server no longer writes last_game_win data to...
[shogi-server/shogi-server.git] / shogi_server / pieceky.rb
1 module ShogiServer
2
3 class PieceKY  < Piece
4   def initialize(*arg)
5     @point = 1
6     @normal_moves = []
7     @promoted_moves = [[0, +1], [+1, +1], [-1, +1], [+1, +0], [-1, +0], [0, -1]]
8     @name = "KY"
9     @promoted_name = "NY"
10     super
11   end
12   def room_of_head?(x, y, name)
13     if (name == "KY")
14       if (@sente)
15         return false if (y == 1)
16       else
17         return false if (y == 9)
18       end
19     end
20     return true
21   end
22   def far_movable_grids
23     grids = Array::new
24     if (@promoted)
25       return []
26     else
27       if (@sente)                 # up
28         cand_x = @x
29         cand_y = @y - 1
30         while (jump_to?(cand_x, cand_y))
31           grids.push([cand_x, cand_y])
32           break if (! put_to?(cand_x, cand_y))
33           cand_y = cand_y - 1
34         end
35       else                        # down
36         cand_x = @x
37         cand_y = @y + 1
38         while (jump_to?(cand_x, cand_y))
39           grids.push([cand_x, cand_y])
40           break if (! put_to?(cand_x, cand_y))
41           cand_y = cand_y + 1
42         end
43       end
44       return grids
45     end
46   end
47 end
48
49 end