class JustBackgammon::CombinedMove

CombinedMove

A combined move is a move where one piece moves multiple times.

Attributes

legs[R]

@return [Array<Move>] the legs of the combined move.

Public Class Methods

new(legs:) click to toggle source

A new instance of CombinedMove.

@param [Array<Move>] legs

The legs of the combined move.

Example:

# Instantiates a new CombinedMove
JustBackgammon::CombinedMove.new({
  legs: [move_a, move_b]
})
# File lib/just_backgammon/combined_move.rb, line 21
def initialize(legs:)
  @legs = legs
end

Public Instance Methods

empty?() click to toggle source

Checks if the combined move start with an empty point.

@return [Boolean]

# File lib/just_backgammon/combined_move.rb, line 38
def empty?
  first_leg.empty? if first_leg
end
from_point?() click to toggle source

Checks if the combined move start from a point.

@return [Boolean]

# File lib/just_backgammon/combined_move.rb, line 31
def from_point?
  first_leg.instance_of?(JustBackgammon::Point) if first_leg
end
multi_leg?() click to toggle source

Checks if the combined move have pieces owned by the opponent.

@return [Boolean]

# File lib/just_backgammon/combined_move.rb, line 52
def multi_leg?
  legs.size > 2
end
owned_by_opponent?(player_number) click to toggle source

Checks if the combined move have pieces owned by the opponent.

@return [Boolean]

# File lib/just_backgammon/combined_move.rb, line 45
def owned_by_opponent?(player_number)
  first_leg.owned_by_opponent?(player_number) if first_leg
end