Class: JustXiangqi::Pao

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

Overview

Ju

The piece that can move orthogonally and captures by jumping over

Constant Summary collapse

MOVEMENT_VECTORS =
[
  BoardGameGrid::Point.new(0, -1),
  BoardGameGrid::Point.new(1, 0),
  BoardGameGrid::Point.new(0, 1),
  BoardGameGrid::Point.new(-1, 0)
]

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.



24
25
26
# File 'lib/just_xiangqi/pieces/pao.rb', line 24

def destinations(square, game_state)
  move_squares(square, game_state) + capture_squares(square, game_state)
end