Class: Tundengine::Stages::Turn

Inherits:
Base
  • Object
show all
Defined in:
lib/tundengine/stages/turn.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#child_in_play, #children, #parent

Instance Method Summary collapse

Methods inherited from Base

#declare!, #fast_forward!, #lock!, #on_complete_child!, #rewind!

Constructor Details

#initialize(trick) ⇒ Turn

Returns a new instance of Turn.



7
8
9
10
# File 'lib/tundengine/stages/turn.rb', line 7

def initialize(trick)
  @card = Cards::Null.instance
  super
end

Instance Attribute Details

#cardObject (readonly)

Returns the value of attribute card.



5
6
7
# File 'lib/tundengine/stages/turn.rb', line 5

def card
  @card
end

Instance Method Details

#as_hashObject



28
29
30
# File 'lib/tundengine/stages/turn.rb', line 28

def as_hash
  { player: player.name, card: card.to_s }
end

#on_completed!(card, beats) ⇒ Object



23
24
25
26
# File 'lib/tundengine/stages/turn.rb', line 23

def on_completed!(card, beats)
  @card = card
  trick.on_complete_child!(beats)
end

#play!(card = Cards::Null.instance) ⇒ Object



19
20
21
# File 'lib/tundengine/stages/turn.rb', line 19

def play!(card = Cards::Null.instance)
  player.play!(card)
end

#player_in_roundObject



15
16
17
# File 'lib/tundengine/stages/turn.rb', line 15

def player_in_round
  player.in_round
end