Class: JustXiangqi::Ju

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

Overview

Ju

The piece that can move orthogonally.

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) ⇒ Object

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.



15
16
17
# File 'lib/just_xiangqi/pieces/ju.rb', line 15

def destinations(square, game_state)
  game_state.squares.orthogonal(square).unoccupied_or_occupied_by_opponent(player_number).unblocked(square, game_state.squares)
end