Class: TwentyOne::Dealer
Instance Attribute Summary collapse
-
#shoe ⇒ Object
readonly
Returns the value of attribute shoe.
Attributes inherited from Player
#bet, #busts, #chips, #choice, #hand, #name, #pushes, #twenty_ones, #wins
Instance Method Summary collapse
- #hit(player) ⇒ Object
-
#initialize(name, shoe) ⇒ Dealer
constructor
A new instance of Dealer.
- #showdown(player) ⇒ Object
Methods inherited from Player
Constructor Details
#initialize(name, shoe) ⇒ Dealer
Returns a new instance of Dealer.
7 8 9 10 11 |
# File 'lib/twenty_one/dealer.rb', line 7 def initialize(name, shoe) super name @shoe = shoe end |
Instance Attribute Details
#shoe ⇒ Object (readonly)
Returns the value of attribute shoe.
5 6 7 |
# File 'lib/twenty_one/dealer.rb', line 5 def shoe @shoe end |
Instance Method Details
#hit(player) ⇒ Object
44 45 46 |
# File 'lib/twenty_one/dealer.rb', line 44 def hit(player) player.hand.cards.push shoe.pop end |
#showdown(player) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/twenty_one/dealer.rb', line 13 def showdown(player) if player.hand.value == @hand.value && player.hand.value <= 21 player.deal_bet :push @pushes += 1 return :push elsif @hand.value <= 21 && player.hand.value < @hand.value || player.hand.value > 21 @chips.push player.bet.chips player.deal_bet :bust @wins += 1 return :bust else win_type = :win if player.hand.value == 21 player.deal_bet :twenty_one win_type = :twenty_one else player.deal_bet :win end @busts += 1 return win_type end end |