Class: Hand
- Inherits:
-
Object
- Object
- Hand
- 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
-
#cards ⇒ Object
The cards in your hand.
Instance Method Summary collapse
-
#bust? ⇒ Boolean
Returns true if #value > 7.5.
-
#hit ⇒ Object
Adds a card to your hand, increasing your value.
-
#initialize ⇒ Hand
constructor
A new instance of Hand.
-
#value ⇒ Object
The combined value of all the cards in your hand.
Constructor Details
Instance Attribute Details
#cards ⇒ Object
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
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 |
#hit ⇒ Object
Adds a card to your hand, increasing your value
7 |
# File 'lib/hand.rb', line 7 def hit; @cards.push DECK.draw; end |
#value ⇒ Object
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 |