Class: Game
- Inherits:
-
Object
- Object
- Game
- Defined in:
- lib/truco.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#player_turn ⇒ Object
Returns the value of attribute player_turn.
Instance Method Summary collapse
- #ask_player_for_card ⇒ Object
- #deal_to_everybody ⇒ Object
- #deal_to_players ⇒ Object
- #dealer ⇒ Object
- #hand ⇒ Object
-
#initialize ⇒ Game
constructor
A new instance of Game.
- #players ⇒ Object
- #to_s ⇒ Object
Constructor Details
Instance Attribute Details
#player_turn ⇒ Object
Returns the value of attribute player_turn.
38 39 40 |
# File 'lib/truco.rb', line 38 def player_turn @player_turn end |
Instance Method Details
#ask_player_for_card ⇒ Object
40 41 42 43 44 45 |
# File 'lib/truco.rb', line 40 def ask_player_for_card puts "Waiting for turn of #{@player_turn.object_id.to_s}" @player_turn.display_cards card = gets.chomp puts card.inspect end |
#deal_to_everybody ⇒ Object
23 24 25 26 27 |
# File 'lib/truco.rb', line 23 def deal_to_everybody @players.each do |player| @dealer.deal_to_player(player) end end |
#deal_to_players ⇒ Object
19 20 21 |
# File 'lib/truco.rb', line 19 def deal_to_players deal_to_everybody end |
#dealer ⇒ Object
7 8 9 |
# File 'lib/truco.rb', line 7 def dealer @dealer end |
#hand ⇒ Object
15 16 17 |
# File 'lib/truco.rb', line 15 def hand @dealer.hand end |
#players ⇒ Object
11 12 13 |
# File 'lib/truco.rb', line 11 def players @players end |
#to_s ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/truco.rb', line 29 def to_s @players.each do |player| puts "#" * 50 puts "Player: " + player.object_id.to_s player.display_cards puts "#" * 50 end end |