Module: Menus

Included in:
Blackjack
Defined in:
lib/blackjack/menus.rb

Instance Method Summary collapse

Instance Method Details

#ask_insuranceObject

[View source]

57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/blackjack/menus.rb', line 57

def ask_insurance
  puts ' Insurance?  (Y) Yes  (N) No'
  loop do
    c = Blackjack.getc($stdin)
    case c
    when 'y'
      insure_hand
    when 'n'
      no_insurance
    else
      clear_draw_hands_ask_insurance
    end
    break if %w[y n].include?(c)
  end
end

#draw_bet_optionsObject

[View source]

73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/blackjack/menus.rb', line 73

def draw_bet_options
  puts ' (D) Deal Hand  (B) Change Bet  (O) Options  (Q) Quit'
  c = Blackjack.getc($stdin)
  case c
  when 'd'
    deal_new_hand
  when 'b'
    new_bet($stdin)
  when 'o'
    clear_draw_hands_game_options
  when 'q'
    clear
    exit
  else
    clear_draw_hands_bet_options
  end
end

#draw_game_optionsObject

[View source]

4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/blackjack/menus.rb', line 4

def draw_game_options
  puts ' (N) Number of Decks  (T) Deck Type  (F) Face Type  (B) Back'
  loop do
    c = Blackjack.getc($stdin)
    case c
    when 'n'
      clear_draw_hands_new_num_decks
    when 't'
      clear_draw_hands_new_deck_type
      clear_draw_hands_bet_options
    when 'f'
      clear_draw_hands_new_face_type
      clear_draw_hands_bet_options
    when 'b'
      clear_draw_hands_bet_options
    else
      clear_draw_hands_game_options
    end
    break if %w[n t b f].include?(c)
  end
end

#new_deck_typeObject

[View source]

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/blackjack/menus.rb', line 26

def new_deck_type
  puts ' (1) Regular  (2) Aces  (3) Jacks  (4) Aces & Jacks  (5) Sevens  (6) Eights'
  loop do
    c = Blackjack.getc($stdin).to_i
    case c
    when (1..6)
      self.deck_type = c
      shoe.send("new_#{SHOES[c]}")
      save_game
    else
      clear_draw_hands_new_deck_type
    end
    break if (1..6).include?(c)
  end
end

#new_face_typeObject

[View source]

42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/blackjack/menus.rb', line 42

def new_face_type
  puts ' (1) 🂡  (2) A♠'
  loop do
    c = Blackjack.getc($stdin).to_i
    case c
    when (1..2)
      self.face_type = c
      save_game
    else
      clear_draw_hands_new_face_type
    end
    break if (1..2).include?(c)
  end
end