Module: PlayerHandActions
- Included in:
- PlayerHand
- Defined in:
- lib/blackjack/player_hand_actions.rb
Instance Method Summary collapse
- #can_dbl? ⇒ Boolean
- #can_hit? ⇒ Boolean
- #can_split? ⇒ Boolean
- #can_stand? ⇒ Boolean
- #dbl ⇒ Object
- #hit ⇒ Object
- #stand ⇒ Object
Instance Method Details
#can_dbl? ⇒ Boolean
12 13 14 15 16 |
# File 'lib/blackjack/player_hand_actions.rb', line 12 def can_dbl? return false if blackjack.money < blackjack.all_bets + bet !(stood || cards.size != 2 || blackjack?) end |
#can_hit? ⇒ Boolean
22 23 24 |
# File 'lib/blackjack/player_hand_actions.rb', line 22 def can_hit? !(played || stood || value(:hard) == 21 || blackjack? || busted?) end |
#can_split? ⇒ Boolean
4 5 6 7 8 9 10 |
# File 'lib/blackjack/player_hand_actions.rb', line 4 def can_split? return false if stood || blackjack.player_hands.size >= PlayerHand::MAX_PLAYER_HANDS return false if blackjack.money < blackjack.all_bets + bet cards.size == 2 && cards.first.value == cards.last.value end |
#can_stand? ⇒ Boolean
18 19 20 |
# File 'lib/blackjack/player_hand_actions.rb', line 18 def can_stand? !(stood || busted? || blackjack?) end |
#dbl ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/blackjack/player_hand_actions.rb', line 37 def dbl deal_card self.played = true self.bet *= 2 process if done? end |
#hit ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/blackjack/player_hand_actions.rb', line 26 def hit deal_card if done? process else blackjack.draw_hands blackjack.current_player_hand.action? end end |
#stand ⇒ Object
45 46 47 48 49 |
# File 'lib/blackjack/player_hand_actions.rb', line 45 def stand self.stood = true self.played = true process end |