Class: JustXiangqi::Xiang

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

Overview

Xiang

The piece that can move 2 spaces diagonally on its side of the river

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:



18
19
20
# File 'lib/just_xiangqi/pieces/xiang.rb', line 18

def destinations(square, game_state)
  players_side_squares(game_state).diagonal(square).at_range(square, 2).unoccupied_or_occupied_by_opponent(player_number) 
end