Class: JustBackgammon::CombinedMove
- Inherits:
-
Object
- Object
- JustBackgammon::CombinedMove
- Extended by:
- Forwardable
- Defined in:
- lib/just_backgammon/combined_move.rb
Overview
CombinedMove
A combined move is a move where one piece moves multiple times.
Instance Attribute Summary collapse
-
#legs ⇒ Array<Move>
readonly
The legs of the combined move.
Instance Method Summary collapse
-
#empty? ⇒ Boolean
Does the combined move start with an empty point?.
-
#from_point? ⇒ Boolean
Does the combined move start from a point?.
-
#initialize(legs:) ⇒ CombinedMove
constructor
A new instance of CombinedMove.
-
#owned_by_opponent?(player_number) ⇒ Boolean
Does the combined move have pieces owned by the opponent?.
Constructor Details
#initialize(legs:) ⇒ CombinedMove
A new instance of CombinedMove.
Example:
# Instantiates a new CombinedMove
JustBackgammon::CombinedMove.new({
legs: [move_a, move_b]
})
21 22 23 |
# File 'lib/just_backgammon/combined_move.rb', line 21 def initialize(legs:) @legs = legs end |
Instance Attribute Details
#legs ⇒ Array<Move> (readonly)
Returns the legs of the combined move.
26 27 28 |
# File 'lib/just_backgammon/combined_move.rb', line 26 def legs @legs end |
Instance Method Details
#empty? ⇒ Boolean
Does the combined move start with an empty point?
40 41 42 |
# File 'lib/just_backgammon/combined_move.rb', line 40 def empty? first_leg.empty? if first_leg end |
#from_point? ⇒ Boolean
Does the combined move start from a point?
33 34 35 |
# File 'lib/just_backgammon/combined_move.rb', line 33 def from_point? first_leg.instance_of?(JustBackgammon::Point) if first_leg end |
#owned_by_opponent?(player_number) ⇒ Boolean
Does the combined move have pieces owned by the opponent?
47 48 49 |
# File 'lib/just_backgammon/combined_move.rb', line 47 def owned_by_opponent?(player_number) first_leg.owned_by_opponent?(player_number) if first_leg end |