class Blackjack::Player

Attributes

hand[RW]
name[RW]

Public Class Methods

new(args) click to toggle source
# File lib/blackjack/player.rb, line 4
def initialize(args)
  @name = args[:name]
  @hand = args[:hand]
  @human = args[:human] || false
  @stand = false
end

Public Instance Methods

bust?() click to toggle source
# File lib/blackjack/player.rb, line 32
def bust?
  hand.bust?
end
formatted_score() click to toggle source
# File lib/blackjack/player.rb, line 28
def formatted_score
  "#{name}'s score: #{score}\n\n"
end
human?() click to toggle source
# File lib/blackjack/player.rb, line 16
def human?
  @human
end
score() click to toggle source
# File lib/blackjack/player.rb, line 24
def score
  hand.cards_value
end
stand!() click to toggle source
# File lib/blackjack/player.rb, line 11
def stand!
  @stand = true
  "#{name} stands!\n\n"
end
stand?() click to toggle source
# File lib/blackjack/player.rb, line 20
def stand?
  @stand
end
wants_to_hit?() click to toggle source
# File lib/blackjack/player.rb, line 36
def wants_to_hit?
  score < 17
end
wins!() click to toggle source
# File lib/blackjack/player.rb, line 40
def wins!
  "#{name} wins!"
end