Class: JustXiangqi::Square

Inherits:
BoardGameGrid::Square
  • Object
show all
Defined in:
lib/just_xiangqi/square.rb

Overview

Square

A Square on a shogi board.

Instance Method Summary collapse

Constructor Details

#initialize(id:, x:, y:, piece: nil) ⇒ Square

New object can be instantiated by passing in a hash with

Example:

# Instantiates a new Square
JustXiangqi::Square.new({
  id: '91',
  x: 0,
  y: 0,
  piece: { id: 1, player_number: 1, type: 'zu' }
})


33
34
35
36
37
38
# File 'lib/just_xiangqi/square.rb', line 33

def initialize(id: , x: , y: , piece: nil)
  @id = id
  @x = x
  @y = y
  @piece = PieceFactory.new(piece).build
end