Lots of stuff

This commit is contained in:
Firepup Sixfifty 2024-06-02 15:22:42 -05:00
parent 7ef02bf6f4
commit addfce3144
Signed by: Firepup650
GPG key ID: 7C92E2ABBBFAB9BA

198
game.py
View file

@ -1,4 +1,4 @@
from firepup650 import clear, randint, sql, e from firepup650 import clear, randint, sql, e, menu
import random as r import random as r
from fkeycapture import get, getnum, getchars from fkeycapture import get, getnum, getchars
import os, time, sys, re import os, time, sys, re
@ -23,18 +23,15 @@ print("Starting...")
clear() clear()
print("Welcome to the city!") print("Welcome to the city!")
print("Do you have an existing account?\n1. Yes\n2. No") print("Do you have an existing account?\n1. Yes\n2. No")
log = getchars() log = menu({"Yes": 1, "No": 0}, "Welcome to the city!\nDo you have an existing account?")
un = "" un = ""
if log == "1": if log:
clear()
print("Please enter your 5 character username")
pw = "" pw = ""
while 1: while 1:
un.append(getchars(alphanum))
clear() clear()
print("Please enter your 5 character username") print("Please enter your 5 character username")
print(un, end="") print(un, end="")
match un.length(): match len(un):
case 0: case 0:
print("-----") print("-----")
case 1: case 1:
@ -47,13 +44,13 @@ if log == "1":
print("-") print("-")
case _: case _:
pass pass
if un.length() == 5: if len(un) == 5:
break break
un += getchars(1, alphanum)
while 1: while 1:
pw.append(getchars(alphanum))
clear() clear()
print("Please enter your 5 character username") print("Please enter your 5 character password")
match pw.length(): match len(pw):
case 0: case 0:
print("-----") print("-----")
case 1: case 1:
@ -66,8 +63,9 @@ if log == "1":
print("****-") print("****-")
case _: case _:
print("*****") print("*****")
if pw.length() == 5: if len(pw) == 5:
break break
pw += getchars(1, alphanum)
uData = db.get(un) uData = db.get(un)
if not uData: if not uData:
print("Sorry, that username is not recognized.") print("Sorry, that username is not recognized.")
@ -83,7 +81,7 @@ else:
clear() clear()
print("Please enter a 5 character (alphanumeric) username") print("Please enter a 5 character (alphanumeric) username")
print(un, end="") print(un, end="")
match un.length(): match len(un):
case 0: case 0:
print("-----") print("-----")
case 1: case 1:
@ -96,14 +94,13 @@ else:
print("-") print("-")
case _: case _:
pass pass
if un.length() == 5: if len(un) == 5:
break break
un.append(getchars(alphanum)) un += getchars(1, alphanum)
while 1: while 1:
clear() clear()
print("Please enter a 5 character (alphanumeric) password") print("Please enter a 5 character (alphanumeric) password")
match len(pw):
match pw.length():
case 0: case 0:
print("-----") print("-----")
case 1: case 1:
@ -116,9 +113,9 @@ else:
print("****-") print("****-")
case _: case _:
print("*****") print("*****")
if pw.length() == 5: if len(pw) == 5:
break break
pw.append(getchars(alphanum)) pw += getchars(1, alphanum)
uData = db.get(un) uData = db.get(un)
if uData: if uData:
print("Sorry, that username is already registered, please log in instead.") print("Sorry, that username is already registered, please log in instead.")
@ -150,100 +147,135 @@ if uData["logins"] == 1:
print(f"Welcome {un}, to Loge City!") print(f"Welcome {un}, to Loge City!")
else: else:
print(f"Welcome back to Loge City {un}.") print(f"Welcome back to Loge City {un}.")
sleep(1) sleep(2)
while 1: while 1:
print("""What would you like to do? go = menu({"Stats": 1, "Gamble": 2, "Research": 3, "Vehicle Shop": 4, "Rare Parts Shop": 5, "Energy Tank Shop": 6, "Resturant": 7, "[DEBUG]": "D", "Exit": "E"}, "What would you like to do?") # TODO: Put shops in their own menu
1. Stats clear()
2. Gamble
3. Research
4. Vehicle Shop
5. Rare Parts Shop
6. Energy Tank Shop
7. Resturant
E. Exit""") # TODO: Put shops in their own menu
if uData["debug"]:
print("D. [DEBUG]")
go = getchars("1234567ED")
match go: match go:
case "1": case 1:
print(f"""Stats: print(f"""Stats:
Studs: Studs:
Current: {uData["studs"]} Current: {uData["studs"]}
All-time Highest: {uData["highestStuds"]} All-time Highest: {uData["highestStuds"]}
All-time Losses: {uData["studsLost"]} All-time Losses: {uData["studsLost"]}
All-time Gains: {uData["studsGained"]} All-time Gains: {uData["studsGained"]}
Vehicles: {uData["vechicles"]} Vehicles: {uData["vehicles"]}
House Level: {uData["houseLevel"]} House Level: {uData["houseLevel"]}
Energy Tanks: {uData["energyTanks"]}""") Energy Tanks: {uData["energyTanks"]}""")
if uData["debug"]: if uData["debug"]:
print("""Debug Stats: print(f"""Debug Stats:
Bebug bit: {uData["debug"]} Bebug bit: {uData["debug"]}
Permission Level: {uData["permissionLevel"]} Permission Level: {uData["permissionLevel"]}
Idk what o is: {uData["o"]}""") Idk what o is: {uData["o"]}""")
print("Press any key to exit") print("Press any key to exit")
get() get()
clear() case 2:
case "2": bet = menu({"5": 5, "10": 10, "20": 20, "30": 30, "40": 40, "50": 50, "60": 60, "70": 70, "80": 80, "90": 90, "100": 100, "1000": 1000, "Exit": "E"}, "How many studs would you like to bet?")
print("""How many studs would you like to bet? betHigh = 0
1. 10
2. 20
3. 30
4. 40
5. 50
6. 60
7. 70
8. 80
9. 90
0. 100
E. Exit""")
bet = getchars("0123456789E")
betSt = 0
match bet: match bet:
case "1": case 10:
betSt = 20 betHigh = 20
case "2": case 20:
betSt = 40 betHigh = 40
case "3": case 30:
betSt = 60 betHigh = 60
case "4": case 40:
betSt = 80 betHigh = 80
case "5": case 50:
betSt = 100 betHigh = 100
case "6": case 60:
betSt = 120 betHigh = 120
case "7": case 70:
betSt = 140 betHigh = 140
case "8": case 80:
betSt = 160 betHigh = 160
case "9": case 90:
betSt = 180 betHigh = 180
case "0": case 100:
betSt = 200 betHigh = 200
case 1000:
betHigh = 2000
case _: case _:
betSt = 0 betHigh = 0
winnings = 0 winnings = 0
while 1: betLow = -bet if betHigh else 0
winnings = randint(0 - max, max) while betHigh:
winnings = randint(betLow, betHigh)
if multipleOf(winnings): if multipleOf(winnings):
break break
if betSt: if betHigh:
if uData["studs"] >= int(bet) * 10: if uData["studs"] >= abs(betLow):
uData["studs"] += winnings uData["studs"] += winnings
# And this is the end of the old code docs... (basically, this part is modified however) # And this is the end of the old code docs... (basically, this part is modified however)
if winnings == 0: if winnings == 0:
print("You won nothing. (You kept your bet though)") print("You won nothing. (You kept your bet though)")
elif winnings == (0 - (int(bet) * 10)): elif winnings == betLow:
print("You lost your bet!") print("You lost your bet!")
uData["studsLost"] -= winnings uData["studsLost"] += abs(winnings)
elif winnings >= 0: elif winnings >= 0:
print(f"You won {winnings} studs!") print(f"You won {winnings} studs!")
uData["studsGained"] += winnings uData["studsGained"] += winnings
elif winnings <= 0: elif winnings <= 0:
print(f"You lost {winnings} studs!") print(f"You lost {abs(winnings)} studs!")
uData["studsLost"] -= winnings uData["studsLost"] += abs(winnings)
else: else:
print("wtf") print("This should be impossible. Cue the panic attacks.")
if uData["studs"] > uData["highestStuds"]:
uData["highestStuds"] = uData["studs"]
else: else:
print("You don't have enough studs to bet that much.") print("You don't have enough studs to bet that much.")
sleep(5)
case 3:
print("TODO: Research Menu")
sleep(1)
case 4:
print("TODO: Vehicle Shop")
sleep(1)
case 5:
print("TODO: Rare Parts Shop")
sleep(1)
case 6:
print("TODO: Energy Tank Shop")
sleep(1)
case 7:
print("TODO: Resturant")
sleep(1)
case "E":
exit(0)
case "D":
if uData["debug"]:
deb = menu({"Dump User Data": 1, "Reset Studs": 2, "Full data reset": 3, "Exit": "E"}, "[DEBUG MENU]")
match deb:
case 1:
print(f"User Data dump: {uData}")
case 2:
uData["studs"] = 20
uData["studsLost"] = 0
uData["studsGained"] = 0
uData["highestStuds"] = 20
print("Studs (and related stats) have been reset.")
case 3:
uData["studs"] = 20
uData["studsLost"] = 0
uData["studsGained"] = 0
uData["highestStuds"] = 20
uData["vehicles"] = {}
uData["energyTanks"] = 0
uData["logins"] = 0
uData["houseLevel"] = 0
uData["o"] = 0
print("User data has been reset.")
case "E":
print("SLEEP 5")
case _:
print("Firepup forgot to implement a debug menu option\nSLEEP 10")
sleep(5)
sleep(5)
else:
print("Operation not permitted")
sleep(5)
case _:
print("Invalid option, this should have been impossible.")
sleep(60)
clear()
if uData["studs"] > uData["highestStuds"]:
uData["highestStuds"] = uData["studs"]
db.set(un, uData) # Update user data after each loop so it actually saves changes to the data