Class: JustXiangqi::Jiang

Inherits:
Piece
  • Object
show all
Defined in:
lib/just_xiangqi/pieces/jiang.rb

Overview

Jiang

The piece that can move 1 space orthogonally within the palace.

Constant Summary collapse

PALACE_X_COORDINATES =
[3, 4, 5]
PALACE_Y_COORDINATES =
[0, 1, 2, 7, 8, 9]

Instance Method Summary collapse

Methods inherited from Piece

#initialize

Constructor Details

This class inherits a constructor from JustXiangqi::Piece

Instance Method Details

#destinations(square, game_state) ⇒ SquareSet

All the squares that the piece can move to and/or capture.

Parameters:

  • square (Square)

    the origin square.

  • game_state (GameState)

    the current game state.

Returns:



21
22
23
# File 'lib/just_xiangqi/pieces/jiang.rb', line 21

def destinations(square, game_state)
  palace_squares(game_state).orthogonal(square).at_range(square, 1).unoccupied_or_occupied_by_opponent(player_number)
end