-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathruby_casino.rb
More file actions
executable file
·126 lines (124 loc) · 3.7 KB
/
ruby_casino.rb
File metadata and controls
executable file
·126 lines (124 loc) · 3.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
require "pry"
require "colorize"
require "require_all"
#require "sounder"
require_all 'classes'
# require_all 'blackjack'
# require_relative 'classes/roulette.rb'
# require_relative 'classes/player.rb'
#casino
#requires player
#cashier here
#game menu here
#binding.pry
class Casino < Player
def initialize(wallet)
@game_menu = ["Blackjack", "Hangman", "Slot Machine", "Roulette", "Keno"]
@wallet = wallet
#Player.new
main_menu
end
def main_menu
puts
puts
puts "Please choose from one of our game options.(1-#{@game_menu.length})"
puts
@game_menu.each_with_index do |game, i|
puts "#{i + 1}. #{game}"
end
puts "6. Leave Casino"
puts "7. New Player"
puts "8. Cashier"
game_choice = gets.strip.to_i
do_choice(game_choice)
end
def do_choice(game_choice)
case game_choice
when 1
#######################################################################
puts "play blackjack here when added. now back to main menu..."
#######################################################################
when 2
Hangman.new(@wallet)
when 3
#######################################################################
puts "play Slots here when added. now back to main menu..."
main_menu
#######################################################################
when 4
Roulette.new(@wallet)
when 5
#######################################################################
Keno.new(@wallet)
# puts "play Keno here when added. now back to main menu..."
# main_menu
#######################################################################
when 6
quit_casino
when 7
Player.new
when 8
cashier
else
puts
puts
puts "Invalid Option. Please Try Again."
main_menu
end
end
def quit_casino
puts
puts
puts "Thanks for playing. Hope to see you soon!"
puts
exit(0)
end
def cashier
puts
puts "Hello #{@player}, how may I help you today?"
@cashier_menu = ["View Balance", "Add to Balance", "Withdraw balance and Leave Casino", "Return to Game Options"]
@cashier_menu.each_with_index do |game, i|
puts "#{i + 1}. #{game}"
puts
# puts "Please choose option 1-#{i+1}"
end
choice = gets.strip.to_i
case choice
when 1
print `clear`
puts "Your balance is $#{@wallet.round(2)}."
cashier
when 2
print `clear`
puts
puts "#{@player}, your current balance is #{@wallet}"
puts
puts "How much would you like to add to your wallet?"
puts
add_me = gets.to_i
increase_balance(add_me)
main_menu
when 3
print `clear`
puts
puts "Are you sure you'd like to withdraw your wallet and leave? (y/n)"
choice = gets.strip.to_s
if choice.downcase == 'y'
withdraw_total = @wallet.to_i
decrease_balance(withdraw_total)
puts
puts
puts "Ok #{@player}, you've withdrawn $#{@wallet}"
quit_casino
else
print `clear`
cashier
end
when 4
main_menu
end
end
end
Player.new
Casino.new(0)
binding.pry