This repository was archived by the owner on Dec 8, 2025. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathcmdline_rev2.py
More file actions
103 lines (94 loc) · 2.54 KB
/
Copy pathcmdline_rev2.py
File metadata and controls
103 lines (94 loc) · 2.54 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
import requests
userID = -1
head = "http://localhost:8080/"
def query(func,payload):
data = requests.get(head + func, payload)
return parse(data)
def parse(query_load):
str_ = query_load.text
words = str_.split(',')
return [word.strip(' ') for word in words]
def createAcc():
username = input("Username: ")
payload = {"username": username}
data = query("CreateUser", payload)
if data[0] in ["400", "500"]:
print ("ERROR CREATING USER: " + str(data[1:]))
return
print("ACCOUNT CREATION SUCCESSFUL")
return
def logIn():
username = input("Username: ")
payload = {"username": username}
data = query("UserInfo", payload)
if data[0] in ["400", "500"]:
print ("ERROR LOGGING IN: " + str(data[1:]))
return -1
print("Balance:"+data[2])
return int(data[1])
def transaction():
transaction_type = input("Withdraw (w) or Deposit (d): ")
while(transaction_type not in ['w', 'd']):
print("INVALID INPUT")
transaction_type = input("Withdraw (w) or Deposit (d): ")
amount = input("Amount: ")
payload = {"userID": userID, "amount":amount}
if transaction_type == 'd':
data = query("Deposit", payload)
elif transaction_type == 'w':
data = query("Withdraw", payload)
if data[0] in ["400", "500"]:
print ("ERROR:" + str(data[1:]))
return -1
print("TRANSACTION SUCCESSFUL")
return
symbols = """1X BAR
2X BAR
3X BAR
SEVEN
BELL
CHERRY
CLOVER
GEM
JACKPOT
LEMON""".split("\n")
def slots():
bet = input("Bet: ")
payload = {"userID": userID, "bet":bet}
data = query("PlaySlots", payload)
if data[0] in ["400", "500"]:
print ("ERROR PLAYING SLOTS: " + str(data[1:]))
return -1
data[3] = data[3][:-1]
while len(data[3]) < 3:
data[3] = "0"+data[3]
rolls = [symbols[int(i)-1] for i in list(data[3])]
print("YOU ROLLED:", rolls)
print("YOUR BET PAID OUT $"+data[1])
return
cowsay = """
______________
< CooperCasino >
--------------
\\ ^__^
\\ (oo)\\_______
(__)\\ )\\/\\
||----w |
|| ||
"""
print(cowsay)
while(True):
print("Options:\n1. Create Account\n2. Log In\n3. Deposit/Withdraw\n4. Play Slots\n5. Quit")
match(input("Choice: ")):
case '1':
createAcc()
case '2':
userID = logIn()
case '3':
transaction()
case '4':
slots()
case '5':
break
case _:
print("INVALID INPUT")