Module: Utils
- Included in:
- Blackjack
- Defined in:
- lib/blackjack/utils.rb
Instance Method Summary collapse
- #clear_draw_hands ⇒ Object
- #clear_draw_hands_ask_insurance ⇒ Object
- #clear_draw_hands_bet_options ⇒ Object
- #clear_draw_hands_game_options ⇒ Object
- #clear_draw_hands_new_deck_type ⇒ Object
- #clear_draw_hands_new_face_type ⇒ Object
- #clear_draw_hands_new_num_decks ⇒ Object
- #draw_hands_current_hand_action ⇒ Object
- #load_game ⇒ Object
- #play_dealer_hand ⇒ Object
- #save_game ⇒ Object
Instance Method Details
#clear_draw_hands ⇒ Object
21 22 23 24 |
# File 'lib/blackjack/utils.rb', line 21 def clear_draw_hands clear draw_hands end |
#clear_draw_hands_ask_insurance ⇒ Object
41 42 43 44 |
# File 'lib/blackjack/utils.rb', line 41 def clear_draw_hands_ask_insurance clear_draw_hands ask_insurance end |
#clear_draw_hands_bet_options ⇒ Object
46 47 48 49 |
# File 'lib/blackjack/utils.rb', line 46 def clear_draw_hands end |
#clear_draw_hands_game_options ⇒ Object
51 52 53 54 |
# File 'lib/blackjack/utils.rb', line 51 def clear_draw_hands end |
#clear_draw_hands_new_deck_type ⇒ Object
31 32 33 34 |
# File 'lib/blackjack/utils.rb', line 31 def clear_draw_hands_new_deck_type clear_draw_hands new_deck_type end |
#clear_draw_hands_new_face_type ⇒ Object
36 37 38 39 |
# File 'lib/blackjack/utils.rb', line 36 def clear_draw_hands_new_face_type clear_draw_hands new_face_type end |
#clear_draw_hands_new_num_decks ⇒ Object
26 27 28 29 |
# File 'lib/blackjack/utils.rb', line 26 def clear_draw_hands_new_num_decks clear_draw_hands new_num_decks($stdin) end |
#draw_hands_current_hand_action ⇒ Object
56 57 58 59 |
# File 'lib/blackjack/utils.rb', line 56 def draw_hands_current_hand_action draw_hands current_player_hand.action? end |
#load_game ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/blackjack/utils.rb', line 10 def load_game return unless File.readable?(SAVE_FILE) a = File.read(SAVE_FILE).split('|') self.num_decks = a[0].to_i self.deck_type = a[1].to_i self.face_type = a[2].to_i self.money = a[3].to_i self.current_bet = a[4].to_i end |
#play_dealer_hand ⇒ Object
61 62 63 64 65 |
# File 'lib/blackjack/utils.rb', line 61 def play_dealer_hand dealer_hand.play draw_hands end |
#save_game ⇒ Object
4 5 6 7 8 |
# File 'lib/blackjack/utils.rb', line 4 def save_game File.open(SAVE_FILE, 'w') do |file| file.puts "#{num_decks}|#{deck_type}|#{face_type}|#{money}|#{current_bet}" end end |