mirror of
https://github.com/Xameren/Casino.git
synced 2025-02-04 08:29:24 +01:00
UI update and minor changes
-> Changed the UI both in the menu screen and the new player screen -> Made cheat detection a bit more reliable -> Fixed a bug where betting on tails and being correct sometimes didnt award the player
This commit is contained in:
parent
44f3bb8ce1
commit
d31d88ccf9
1 changed files with 67 additions and 44 deletions
111
Casino.py
111
Casino.py
|
@ -6,6 +6,8 @@ import os
|
||||||
import json
|
import json
|
||||||
import datetime
|
import datetime
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
import hashlib
|
||||||
|
|
||||||
os.system("title " + "Let's go gambling! dududu ehh. God damn it!")
|
os.system("title " + "Let's go gambling! dududu ehh. God damn it!")
|
||||||
|
|
||||||
# GAMES
|
# GAMES
|
||||||
|
@ -182,7 +184,6 @@ def Roulette():
|
||||||
for i in range(5):
|
for i in range(5):
|
||||||
|
|
||||||
print("\033[H", end="")
|
print("\033[H", end="")
|
||||||
print()
|
|
||||||
print(decortext, " Roulette wheel ", decortext)
|
print(decortext, " Roulette wheel ", decortext)
|
||||||
print(textdecorup)
|
print(textdecorup)
|
||||||
print(f"|{cleanedtext}|")
|
print(f"|{cleanedtext}|")
|
||||||
|
@ -910,13 +911,16 @@ def Coinflip():
|
||||||
stringeffect2 = ""
|
stringeffect2 = ""
|
||||||
count = 0
|
count = 0
|
||||||
speed = 0
|
speed = 0
|
||||||
|
result = ""
|
||||||
while count < random.randint(9,10):
|
while count < random.randint(9,10):
|
||||||
print("\033[H\033[J", end="")
|
print("\033[H\033[J", end="")
|
||||||
print(stringeffect + "Tossing..." + stringeffect2)
|
print(stringeffect + "Tossing..." + stringeffect2)
|
||||||
if count == 1 or count == 3 or count == 5 or count == 7 or count == 9:
|
if count == 1 or count == 3 or count == 5 or count == 7 or count == 9:
|
||||||
print("-> Heads <-")
|
print("-> Heads <-")
|
||||||
|
result = "heads"
|
||||||
else:
|
else:
|
||||||
print("-> Tails <-")
|
print("-> Tails <-")
|
||||||
|
result = "tails"
|
||||||
print(stringeffect + "Tossing..." + stringeffect2)
|
print(stringeffect + "Tossing..." + stringeffect2)
|
||||||
if count == 3 or count == 6 or count == 9:
|
if count == 3 or count == 6 or count == 9:
|
||||||
stringeffect2 += "]"
|
stringeffect2 += "]"
|
||||||
|
@ -924,7 +928,7 @@ def Coinflip():
|
||||||
count += 1
|
count += 1
|
||||||
speed += 0.075
|
speed += 0.075
|
||||||
time.sleep(speed)
|
time.sleep(speed)
|
||||||
if count == 9:
|
if result == "heads":
|
||||||
if a == 1:
|
if a == 1:
|
||||||
money = money+(b*2)
|
money = money+(b*2)
|
||||||
print("You won ", b, "dollars!")
|
print("You won ", b, "dollars!")
|
||||||
|
@ -1033,7 +1037,7 @@ def dailyreward():
|
||||||
try:
|
try:
|
||||||
loaded_datetime = json.loads(json_datetime)
|
loaded_datetime = json.loads(json_datetime)
|
||||||
lastrewardtime = datetime.fromisoformat(loaded_datetime["current_time"])
|
lastrewardtime = datetime.fromisoformat(loaded_datetime["current_time"])
|
||||||
except (json.JSONDecodeError, KeyError, ValueError):
|
except (json.JSONDecodeError, KeyError, ValueError)as e:
|
||||||
lastrewardtime = datetime(year= 2020, month= 1, day= 1, hour= 1, minute= 1, second= 1, microsecond= 1)
|
lastrewardtime = datetime(year= 2020, month= 1, day= 1, hour= 1, minute= 1, second= 1, microsecond= 1)
|
||||||
timediff = currenttime - lastrewardtime
|
timediff = currenttime - lastrewardtime
|
||||||
if timediff.days >= 1:
|
if timediff.days >= 1:
|
||||||
|
@ -1076,6 +1080,8 @@ def dailyreward():
|
||||||
print(f"> {randxp*level} XP <")
|
print(f"> {randxp*level} XP <")
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
lastrewardtime = datetime.now()
|
lastrewardtime = datetime.now()
|
||||||
|
|
||||||
|
save_game()
|
||||||
else:
|
else:
|
||||||
next_reward_time = lastrewardtime + timedelta(hours=24)
|
next_reward_time = lastrewardtime + timedelta(hours=24)
|
||||||
|
|
||||||
|
@ -1094,47 +1100,58 @@ def CasinoMenu():
|
||||||
xp -= xptoreach
|
xp -= xptoreach
|
||||||
level += 1
|
level += 1
|
||||||
print("\033[H\033[J", end="")
|
print("\033[H\033[J", end="")
|
||||||
|
xptoreach = xptoreachbase*level
|
||||||
|
xp_filled_value = round((xp / xptoreach) * 20)
|
||||||
|
xp_filled = ""
|
||||||
|
for _ in range(xp_filled_value):
|
||||||
|
xp_filled += '#'
|
||||||
|
for _ in range(20 - xp_filled_value):
|
||||||
|
xp_filled += '-'
|
||||||
|
|
||||||
print("\033[H\033[J", end="")
|
print("\033[H\033[J", end="")
|
||||||
save_game()
|
save_game()
|
||||||
print(f"Welcome to the Casino, {username}!")
|
print(f"Welcome to the Casino, \033[1m{username}!\033[0m")
|
||||||
print("Which game would you like to play?\n")
|
print(f"Money: {money}")
|
||||||
print("1. Roulette")
|
print(f"Level: {level}")
|
||||||
print("2. Slots")
|
print(f"XP: {xp} / {xptoreach}")
|
||||||
print("3. Horse Betting")
|
print(f"[{xp_filled}]\n")
|
||||||
print("4. Casino War")
|
print("1) Roulette")
|
||||||
print("5. Coin Flip")
|
print("2) Slots")
|
||||||
print("6. Crash")
|
print("3) Horse Betting")
|
||||||
print("7. Keno")
|
print("4) Casino War")
|
||||||
print("8. Stats")
|
print("5) Coin Flip")
|
||||||
print("9. Daily reward")
|
print("6) Crash")
|
||||||
print("10. Exit")
|
print("7) Keno")
|
||||||
|
print("8) Daily reward\n")
|
||||||
|
|
||||||
|
print("s) Stats")
|
||||||
|
print("q) Exit")
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
choicemenu = int(input("\nSelect a number associated with the game.\n"))
|
choicemenu = input("\nSelect an option: ")
|
||||||
|
|
||||||
if choicemenu == 1:
|
if choicemenu == "1":
|
||||||
Roulette()
|
Roulette()
|
||||||
elif choicemenu == 2:
|
elif choicemenu == "2":
|
||||||
Slots()
|
Slots()
|
||||||
elif choicemenu == 3:
|
elif choicemenu == "3":
|
||||||
HorseBettin()
|
HorseBettin()
|
||||||
elif choicemenu == 4:
|
elif choicemenu == "4":
|
||||||
CasinoWar()
|
CasinoWar()
|
||||||
elif choicemenu == 5:
|
elif choicemenu == "5":
|
||||||
Coinflip()
|
Coinflip()
|
||||||
elif choicemenu == 6:
|
elif choicemenu == "6":
|
||||||
coolstoppingargument = True
|
coolstoppingargument = True
|
||||||
cashout = False
|
cashout = False
|
||||||
dead = False
|
dead = False
|
||||||
Crash()
|
Crash()
|
||||||
elif choicemenu == 7:
|
elif choicemenu == "7":
|
||||||
Keno()
|
Keno()
|
||||||
elif choicemenu == 8:
|
elif choicemenu == "8":
|
||||||
Stats()
|
|
||||||
elif choicemenu == 9:
|
|
||||||
dailyreward()
|
dailyreward()
|
||||||
elif choicemenu == 10:
|
elif choicemenu == "s":
|
||||||
|
Stats()
|
||||||
|
elif choicemenu == "q":
|
||||||
sys.exit()
|
sys.exit()
|
||||||
break
|
break
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
@ -1145,10 +1162,10 @@ def CasinoMenu():
|
||||||
|
|
||||||
|
|
||||||
def save_game():
|
def save_game():
|
||||||
global xptoreach, value1, legit, json_datetime
|
global xptoreach, value1, legit, json_datetime, m
|
||||||
|
m = hashlib.sha256(f"{money+xp+xptoreach+level+wins_roulette+wins_slots+wins_keno+wins_casinowar+wins_coinflip+wins_crash+wins_horsebetting}".encode())
|
||||||
value1 = money+xp+xptoreach+level+wins_roulette+wins_slots+wins_keno+wins_casinowar+wins_coinflip+wins_crash+wins_horsebetting
|
value1 = m.hexdigest()
|
||||||
|
|
||||||
game_state = {
|
game_state = {
|
||||||
"money": money,
|
"money": money,
|
||||||
"merry_christmas": merry_christmas,
|
"merry_christmas": merry_christmas,
|
||||||
|
@ -1167,20 +1184,22 @@ def save_game():
|
||||||
"legit": legit,
|
"legit": legit,
|
||||||
"json_datetime": json_datetime
|
"json_datetime": json_datetime
|
||||||
}
|
}
|
||||||
|
if legit == False:
|
||||||
|
game_state["value1"] = "cheater"
|
||||||
|
game_state["legit"] = False
|
||||||
|
|
||||||
with open(save_file, 'w') as file:
|
with open(save_file, 'w') as file:
|
||||||
json.dump(game_state, file)
|
json.dump(game_state, file)
|
||||||
|
|
||||||
def load_game():
|
def load_game():
|
||||||
global json_datetime, lastrewardtime, legit, value1, load_fail, money, merry_christmas, username, xp, xptoreach, wins_casinowar, wins_coinflip, wins_crash, wins_horsebetting, wins_keno, wins_roulette, wins_slots, level, username
|
global m, json_datetime, lastrewardtime, legit, value1, load_fail, money, merry_christmas, username, xp, xptoreach, wins_casinowar, wins_coinflip, wins_crash, wins_horsebetting, wins_keno, wins_roulette, wins_slots, level, username
|
||||||
if os.path.exists(save_file):
|
if os.path.exists(save_file):
|
||||||
with open(save_file, 'r') as file:
|
try:
|
||||||
try:
|
with open(save_file, 'r') as file:
|
||||||
game_state = json.load(file)
|
game_state = json.load(file)
|
||||||
username = game_state["username"]
|
username = game_state["username"]
|
||||||
money = game_state["money"]
|
money = game_state["money"]
|
||||||
merry_christmas = game_state["merry_christmas"]
|
merry_christmas = game_state["merry_christmas"]
|
||||||
username = game_state["username"]
|
|
||||||
xp = game_state["xp"]
|
xp = game_state["xp"]
|
||||||
xptoreach = game_state["xptoreach"]
|
xptoreach = game_state["xptoreach"]
|
||||||
level = game_state["level"]
|
level = game_state["level"]
|
||||||
|
@ -1194,13 +1213,18 @@ def load_game():
|
||||||
value1 = game_state["value1"]
|
value1 = game_state["value1"]
|
||||||
legit = game_state["legit"]
|
legit = game_state["legit"]
|
||||||
json_datetime = game_state["json_datetime"]
|
json_datetime = game_state["json_datetime"]
|
||||||
except Exception:
|
g = hashlib.sha256(f"{money+xp+xptoreach+level+wins_roulette+wins_slots+wins_keno+wins_casinowar+wins_coinflip+wins_crash+wins_horsebetting}".encode())
|
||||||
print("You have an outdated or a corrupted save file!")
|
new_value1 = g.hexdigest()
|
||||||
if legit == True:
|
if legit == True:
|
||||||
if money+xp+xptoreach+level+wins_roulette+wins_slots+wins_keno+wins_casinowar+wins_coinflip+wins_crash+wins_horsebetting == value1:
|
if new_value1 == value1:
|
||||||
legit = True
|
legit = True
|
||||||
else:
|
else:
|
||||||
legit = False
|
legit = False
|
||||||
|
except Exception as e:
|
||||||
|
print(f"You have an outdated or a corrupted save file! Error {e} \n A value might be missing")
|
||||||
|
time.sleep(3)
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
if legit == False: # ):
|
if legit == False: # ):
|
||||||
print("I should have allowed you to change the odds \nof the games in the save file aswell, eh?")
|
print("I should have allowed you to change the odds \nof the games in the save file aswell, eh?")
|
||||||
|
@ -1208,8 +1232,7 @@ def load_game():
|
||||||
if money > 999999999:
|
if money > 999999999:
|
||||||
print("Youre so greedy aswell...")
|
print("Youre so greedy aswell...")
|
||||||
money = 0
|
money = 0
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
|
|
||||||
load_fail = False
|
load_fail = False
|
||||||
else:
|
else:
|
||||||
load_fail = True
|
load_fail = True
|
||||||
|
|
Loading…
Add table
Reference in a new issue