Class: Hand

Inherits:
Object
  • Object
show all
Defined in:
lib/hand.rb

Overview

Acts as the player

Constant Summary collapse

DECK =

The deck used in the game

Deck.new
MDSV =

Minimum value the dealer can stay at. Uses the same ratio as blackjack1.

7.5 * (17.0/21.0)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHand

Returns a new instance of Hand.



6
# File 'lib/hand.rb', line 6

def initialize; @cards = [DECK.draw]; end

Instance Attribute Details

#cardsObject

The cards in your hand



3
4
5
# File 'lib/hand.rb', line 3

def cards
  @cards
end

Instance Method Details

#bust?Boolean

Returns true if #value > 7.5

Returns:

  • (Boolean)


13
14
15
16
17
18
# File 'lib/hand.rb', line 13

def bust? # Returns true if #value > 7.5
  if value > 7.5 then true
  else
    false
  end
end

#hitObject

Adds a card to your hand, increasing your value



7
# File 'lib/hand.rb', line 7

def hit; @cards.push DECK.draw; end

#valueObject

The combined value of all the cards in your hand



8
9
10
11
12
# File 'lib/hand.rb', line 8

def value # The combined value of all the cards in your hand
  sum = 0.0
  for c in @cards; sum += c.value; end
  return sum
end