class TwentyOne::Dealer
Attributes
shoe[R]
Public Class Methods
new(name, shoe)
click to toggle source
Calls superclass method
# File lib/twenty_one/dealer.rb, line 7 def initialize(name, shoe) super name @shoe = shoe end
Public Instance Methods
hit(player)
click to toggle source
# File lib/twenty_one/dealer.rb, line 44 def hit(player) player.hand.cards.push shoe.pop end
showdown(player)
click to toggle source
# 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