Sha256: 31797785237cbd2be2c72ba1f08b20a979a3f3ba1077f4e4e9a32ac59b4f783a
Contents?: true
Size: 792 Bytes
Versions: 1
Compression:
Stored size: 792 Bytes
Contents
require 'just_xiangqi/pieces/piece' module JustXiangqi # = Shi # # The piece that can move 1 space diagonally within the palace. class Shi < Piece PALACE_X_COORDINATES = [3, 4, 5] PALACE_Y_COORDINATES = [0, 1, 2, 7, 8, 9] # All the squares that the piece can move to and/or capture. # # @param [Square] square # the origin square. # # @param [GameState] game_state # the current game state. # # @return [SquareSet] def destinations(square, game_state) palace_squares(game_state).diagonal(square).at_range(square, 1).unoccupied_or_occupied_by_opponent(player_number) end private def palace_squares(game_state) game_state.squares.where(x: PALACE_X_COORDINATES, y: PALACE_Y_COORDINATES) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
just_xiangqi-0.1.0 | lib/just_xiangqi/pieces/shi.rb |