Class: JustXiangqi::Zu

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

Overview

Zu

The piece that can move one space forward and can also move one space horizontally when on the opposite 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:



17
18
19
# File 'lib/just_xiangqi/pieces/zu.rb', line 17

def destinations(square, game_state)
  same_file_forwards_and_or_same_rank(square, game_state).in_range(square, 1).unoccupied_or_occupied_by_opponent(player_number)
end