Class: Tundengine::Player::InTurn
- Inherits:
-
Object
- Object
- Tundengine::Player::InTurn
- Extended by:
- Forwardable
- Defined in:
- lib/tundengine/player/in_turn.rb
Instance Attribute Summary collapse
-
#in_round ⇒ Object
readonly
Returns the value of attribute in_round.
-
#turn ⇒ Object
readonly
Returns the value of attribute turn.
Instance Method Summary collapse
- #after_playing!(card) ⇒ Object
-
#initialize(turn, player_in_round) ⇒ InTurn
constructor
A new instance of InTurn.
- #play!(card = Cards::Null.instance) ⇒ Object
Constructor Details
#initialize(turn, player_in_round) ⇒ InTurn
Returns a new instance of InTurn.
10 11 12 13 |
# File 'lib/tundengine/player/in_turn.rb', line 10 def initialize(turn, player_in_round) @turn = turn @in_round = player_in_round end |
Instance Attribute Details
#in_round ⇒ Object (readonly)
Returns the value of attribute in_round.
8 9 10 |
# File 'lib/tundengine/player/in_turn.rb', line 8 def in_round @in_round end |
#turn ⇒ Object (readonly)
Returns the value of attribute turn.
8 9 10 |
# File 'lib/tundengine/player/in_turn.rb', line 8 def turn @turn end |
Instance Method Details
#after_playing!(card) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/tundengine/player/in_turn.rb', line 19 def (card) playable_cards, beats = hand.playable_cards(turn.trick) if playable_cards.include? card hand.delete card turn.on_completed!(card, beats) else raise "cannot play card #{card} in trick with cards #{turn.trick.cards.map(&:to_s)} when your hand is #{@hand.map(&:to_s)}" end end |