Compare commits

...

2 commits

185
game.py
View file

@ -20,7 +20,9 @@ def rreplace(s: str, old: str, new: str, occurrence: int) -> str:
cur.hide()
clear()
print("Loading Loge City v 0.0.1...")
print(
"Loading Loge City v 0.0.16..."
) # Finally remebered to bump this... I think v16 is right?
sleep(1)
flushPrint("Checking system compatibility...")
sleep(1)
@ -87,6 +89,7 @@ else:
"racScore": 0,
"richScore": 0,
"rare": {},
"upgrades": {},
},
)
uData = db.get(un)
@ -99,12 +102,14 @@ if uData["logins"] == 1:
else:
print(f"Welcome back to Loge City {un}, we hope you are enjoying your stay.")
sleep(2)
# LTOP - jump point for me
while 1:
studsAtTop = uData["studs"]
go = menu(
{
"Stats": 1,
"Gamble": 2,
"Research": 3,
"Upgrades": 3,
"Vehicle Shop": 4,
"Rare Parts Shop": 5,
"Energy Tank Shop": 6,
@ -176,7 +181,10 @@ while 1:
Energy Tanks: {uData["energyTanks"]}
Misc Scores:
Raccoon: {uData["racScore"]}
Rich: {uData["richScore"]}"""
Rich: {uData["richScore"]}
Upgrades:
Luck: {uData["upgrades"].get("luck", 0)}%
Stud Multipiler: {uData["upgrades"].get("studX", 1)}x"""
)
if uData["debug"] or uData["permissionLevel"] >= 50:
print(
@ -196,6 +204,8 @@ while 1:
betHigh = 0 if type(bet) != int else bet
winnings = 0
betLow = -2 * bet if betHigh else 0
if betLow:
betLow = min(betLow + (uData["upgrades"].get("luck") * 5), 0)
while betHigh:
winnings = randint(betLow, betHigh)
if multipleOf(winnings):
@ -208,21 +218,59 @@ while 1:
print("You won nothing. (You kept your bet though)")
elif winnings == betLow:
print("You lost your bet!")
uData["studsLost"] += abs(winnings)
elif winnings >= 0:
print(f"You won {winnings} studs!")
uData["studsGained"] += winnings
elif winnings <= 0:
print(f"You lost {abs(winnings)} studs!")
uData["studsLost"] += abs(winnings)
else:
print("This should be impossible. Cue the panic attacks.")
else:
print("You don't have enough studs to bet that much.")
sleep(5)
case 3:
print("TODO: Research Menu")
sleep(1)
prices = {
"studX": 2000000
* pow(10, (uData["upgrades"].get("studX", 1) * 10) - 10),
"houseL": 199 + pow(53 * uData["houseLevel"], uData["houseLevel"]),
"luck": 500 * pow(10, uData["upgrades"].get("luck", 0) * 2),
}
sel = menu(
{
f"Stud multiplier {uData['upgrades'].get('studX', 1)}x -> {uData['upgrades'].get('studX', 1) + 0.1}x ({prices['studX']} studs)": "studX",
f"House level {uData['houseLevel']} -> {uData['houseLevel'] + 1} ({prices['houseL']} studs)": "houseL",
f"Luck (Affects betting) {uData['upgrades'].get('luck', 0)}% -> {uData['upgrades'].get('luck', 0) + 1}% ({prices['luck']} studs)": "luck",
"Exit": "E",
},
"What do you want to upgrade?",
)
match sel:
case "studX":
if uData["studs"] >= prices[sel]:
uData["studs"] -= prices[sel]
uData["upgrades"][sel] = uData["upgrades"].get(sel, 1) + 0.1
print(
f"You've upgraded your stud multipler to {uData['upgrades'][sel]}x!"
)
case "houseL":
if uData["studs"] >= prices[sel]:
uData["studs"] -= prices[sel]
uData["houseLevel"] += 1
print(
f"You've upgraded your house to level {uData['houseLevel']}!"
)
case "luck":
if uData["studs"] >= prices[sel]:
uData["studs"] -= prices[sel]
uData["upgrades"][sel] = uData["upgrades"].get(sel, 0) + 1
print(
f"You've upgraded your luck to {uData['upgrades'][sel]}%!"
)
case "E":
pass
case _:
print("Firepup forgot to add a menu option, smh")
sleep(2)
sleep(2)
case 4:
sel = menu(
{
@ -255,7 +303,6 @@ while 1:
if sel <= uData["studs"] and "bike" not in uData["vehicles"]:
uData["vehicles"].append("bike")
uData["studs"] -= sel
uData["studsLost"] += sel
print("You purchased a bike!")
elif "bike" in uData["vehicles"]:
print("Sorry, you already have a bike!")
@ -265,7 +312,6 @@ while 1:
if sel <= uData["studs"] and "4-wheeler" not in uData["vehicles"]:
uData["vehicles"].append("4-wheeler")
uData["studs"] -= sel
uData["studsLost"] += sel
print("You purchased a 4-wheeler!")
elif "4-wheeler" in uData["vehicles"]:
print("Sorry, you already have a 4-wheeler!")
@ -278,7 +324,6 @@ while 1:
):
uData["vehicles"].append("old rusty car")
uData["studs"] -= sel
uData["studsLost"] += sel
print("You purchased an old rusty car!")
elif "old rusty car" in uData["vehicles"]:
print("Sorry, you already have an old rusty car!")
@ -288,7 +333,6 @@ while 1:
if sel <= uData["studs"] and "car" not in uData["vehicles"]:
uData["vehicles"].append("car")
uData["studs"] -= sel
uData["studsLost"] += sel
print("You purchased a car!")
elif "car" in uData["vehicles"]:
print("Sorry, you already have a car!")
@ -298,7 +342,6 @@ while 1:
if sel <= uData["studs"] and "minivan" not in uData["vehicles"]:
uData["vehicles"].append("minivan")
uData["studs"] -= sel
uData["studsLost"] += sel
print("You purchased a minivan!")
elif "minivan" in uData["vehicles"]:
print("Sorry, you already have a minivan!")
@ -308,7 +351,6 @@ while 1:
if sel <= uData["studs"] and "van" not in uData["vehicles"]:
uData["vehicles"].append("van")
uData["studs"] -= sel
uData["studsLost"] += sel
print("You purchased a van!")
elif "van" in uData["vehicles"]:
print("Sorry, you already have a van!")
@ -318,7 +360,6 @@ while 1:
if sel <= uData["studs"] and "truck" not in uData["vehicles"]:
uData["vehicles"].append("truck")
uData["studs"] -= sel
uData["studsLost"] += sel
print("You purchased a truck!")
elif "truck" in uData["vehicles"]:
print("Sorry, you already have a truck!")
@ -328,7 +369,6 @@ while 1:
if sel <= uData["studs"] and "food truck" not in uData["vehicles"]:
uData["vehicles"].append("food truck")
uData["studs"] -= sel
uData["studsLost"] += sel
print("You purchased a food truck!")
elif "food truck" in uData["vehicles"]:
print("Sorry, you already have a food truck!")
@ -338,7 +378,6 @@ while 1:
if sel <= uData["studs"] and "semi-truck" not in uData["vehicles"]:
uData["vehicles"].append("semi-truck")
uData["studs"] -= sel
uData["studsLost"] += sel
print("You purchased a semi-truck!")
elif "semi-truck" in uData["vehicles"]:
print("Sorry, you already have a semi-truck!")
@ -348,7 +387,6 @@ while 1:
if sel <= uData["studs"] and "hover bike" not in uData["vehicles"]:
uData["vehicles"].append("hover bike")
uData["studs"] -= sel
uData["studsLost"] += sel
print("You purchased a hover bike!")
elif "hover bike" in uData["vehicles"]:
print("Sorry, you already have a hover bike!")
@ -358,7 +396,6 @@ while 1:
if sel <= uData["studs"] and "hover car" not in uData["vehicles"]:
uData["vehicles"].append("hover car")
uData["studs"] -= sel
uData["studsLost"] += sel
print("You purchased a hover car!")
elif "hover car" in uData["vehicles"]:
print("Sorry, you already have a hover car!")
@ -368,7 +405,6 @@ while 1:
if sel <= uData["studs"] and "hover truck" not in uData["vehicles"]:
uData["vehicles"].append("hover truck")
uData["studs"] -= sel
uData["studsLost"] += sel
print("You purchased a hover truck!")
elif "hover truck" in uData["vehicles"]:
print("Sorry, you already have a hover truck!")
@ -381,7 +417,6 @@ while 1:
):
uData["vehicles"].append("hover semi-truck")
uData["studs"] -= sel
uData["studsLost"] += sel
print("You purchased a hover semi-truck!")
elif "hover semi-truck" in uData["vehicles"]:
print("Sorry, you already have a hover semi-truck!")
@ -391,7 +426,6 @@ while 1:
if sel <= uData["studs"] and "pod racer" not in uData["vehicles"]:
uData["vehicles"].append("pod racer")
uData["studs"] -= sel
uData["studsLost"] += sel
print("You purchased a pod racer!")
elif "pod racer" in uData["vehicles"]:
print("Sorry, you already have a pod racer!")
@ -401,7 +435,6 @@ while 1:
if sel <= uData["studs"] and "rocketship" not in uData["vehicles"]:
uData["vehicles"].append("rocketship")
uData["studs"] -= sel
uData["studsLost"] += sel
print("You purchased a rocketship!")
elif "rocketship" in uData["vehicles"]:
print("Sorry, you already have a rocketship!")
@ -411,7 +444,6 @@ while 1:
if sel <= uData["studs"] and "spaceship" not in uData["vehicles"]:
uData["vehicles"].append("spaceship")
uData["studs"] -= sel
uData["studsLost"] += sel
print("You purchased a spaceship!")
elif "spaceship" in uData["vehicles"]:
print("Sorry, you already have a spaceship!")
@ -424,7 +456,6 @@ while 1:
):
uData["vehicles"].append("spaceship with a hyperdrive")
uData["studs"] -= sel
uData["studsLost"] += sel
print("You purchased a spaceship with a hyperdrive!")
elif "spaceship with a hyperdrive" in uData["vehicles"]:
print("Sorry, you already have a spaceship with a hyperdrive!")
@ -434,7 +465,6 @@ while 1:
if sel <= uData["studs"] and "yacht" not in uData["vehicles"]:
uData["vehicles"].append("yacht")
uData["studs"] -= sel
uData["studsLost"] += sel
print("You purchased a yacht!")
elif "yacht" in uData["vehicles"]:
print("Sorry, you already have a yacht!")
@ -444,7 +474,6 @@ while 1:
if sel <= uData["studs"] and "space yacht" not in uData["vehicles"]:
uData["vehicles"].append("space yacht")
uData["studs"] -= sel
uData["studsLost"] += sel
print("You purchased a space yacht!")
elif "space yacht" in uData["vehicles"]:
print("Sorry, you already have a space yacht!")
@ -454,7 +483,6 @@ while 1:
if sel <= uData["studs"] and "teleporter" not in uData["vehicles"]:
uData["vehicles"].append("teleporter")
uData["studs"] -= sel
uData["studsLost"] += sel
print("You purchased a teleporter!")
elif "teleporter" in uData["vehicles"]:
print("Sorry, you already have a teleporter!")
@ -489,7 +517,6 @@ while 1:
case 250:
if sel <= uData["studs"]:
uData["studs"] -= sel
uData["studsLost"] += sel
uData["richScore"] += 1
if "gold bar" in uData["rare"]:
uData["rare"]["gold bar"] += 1
@ -501,7 +528,6 @@ while 1:
case 500:
if sel <= uData["studs"]:
uData["studs"] -= sel
uData["studsLost"] += sel
uData["richScore"] += 2
if "golden cup" in uData["rare"]:
uData["rare"]["golden cup"] += 1
@ -513,7 +539,6 @@ while 1:
case 1000:
if sel <= uData["studs"]:
uData["studs"] -= sel
uData["studsLost"] += sel
uData["richScore"] += 5
if "golden plate" in uData["rare"]:
uData["rare"]["golden plate"] += 1
@ -525,7 +550,6 @@ while 1:
case 5000:
if sel <= uData["studs"]:
uData["studs"] -= sel
uData["studsLost"] += sel
uData["richScore"] += 10
if "golden table" in uData["rare"]:
uData["rare"]["golden table"] += 1
@ -537,7 +561,6 @@ while 1:
case 250000:
if sel <= uData["studs"]:
uData["studs"] -= sel
uData["studsLost"] += sel
uData["richScore"] += 20
if "crystal" in uData["rare"]:
uData["rare"]["crystal"] += 1
@ -549,7 +572,6 @@ while 1:
case 500000:
if sel <= uData["studs"]:
uData["studs"] -= sel
uData["studsLost"] += sel
uData["richScore"] += 25
if "crystal cup" in uData["rare"]:
uData["rare"]["crystal cup"] += 1
@ -561,7 +583,6 @@ while 1:
case 1000000:
if sel <= uData["studs"]:
uData["studs"] -= sel
uData["studsLost"] += sel
uData["richScore"] += 50
if "crystal plate" in uData["rare"]:
uData["rare"]["crystal plate"] += 1
@ -573,7 +594,6 @@ while 1:
case 5000000:
if sel <= uData["studs"]:
uData["studs"] -= sel
uData["studsLost"] += sel
uData["richScore"] += 75
if "crystal table" in uData["rare"]:
uData["rare"]["crystal table"] += 1
@ -585,7 +605,6 @@ while 1:
case 10000000:
if sel <= uData["studs"]:
uData["studs"] -= sel
uData["studsLost"] += sel
uData["richScore"] += 100
if "double studded 1x1 plate" in uData["rare"]:
uData["rare"]["double studded 1x1 plate"] += 1
@ -597,7 +616,6 @@ while 1:
case 50000000:
if sel <= uData["studs"]:
uData["studs"] -= sel
uData["studsLost"] += sel
uData["richScore"] += 125
if "double studded 2x2 plate" in uData["rare"]:
uData["rare"]["double studded 2x2 plate"] += 1
@ -609,7 +627,6 @@ while 1:
case 100000000:
if sel <= uData["studs"]:
uData["studs"] -= sel
uData["studsLost"] += sel
uData["richScore"] += 150
if "hinge joint" in uData["rare"]:
uData["rare"]["hinge joint"] += 1
@ -621,7 +638,6 @@ while 1:
case 500000000:
if sel <= uData["studs"]:
uData["studs"] -= sel
uData["studsLost"] += sel
uData["richScore"] += 200
if "vault door" in uData["rare"]:
uData["rare"]["vault door"] += 1
@ -658,7 +674,6 @@ while 1:
case 1:
if price1 <= uData["studs"]:
uData["studs"] -= price1
uData["studsLost"] += price1
uData["energyTanks"] += 1
print("You bought a single energy tank!")
else:
@ -667,7 +682,6 @@ while 1:
case 5:
if price5 <= uData["studs"]:
uData["studs"] -= price5
uData["studsLost"] += price5
uData["energyTanks"] += 5
print("You bought 5 energy tanks!")
else:
@ -676,7 +690,6 @@ while 1:
case 10:
if price10 <= uData["studs"]:
uData["studs"] -= price10
uData["studsLost"] += price10
uData["energyTanks"] += 10
print("You bought 10 energy tanks!")
else:
@ -708,7 +721,15 @@ while 1:
},
"What would you like to order?",
)
thing, price, message, weird = ("Nothing", 0, "You bought nothing", True)
# Bugfix: rich and raccoon would always go up even if you failed to buy the item
thing, price, message, weird, rich, rac = (
"Nothing",
0,
"You bought nothing",
True,
0,
0,
)
match sel:
case 1:
thing, price, message, weird = ("a pizza", 5, "delicious!", False)
@ -734,7 +755,7 @@ while 1:
thing = "a can of blueberry"
case 9:
thing = "a can of rain water"
price, message, weird = (
price, message, Weird = (
10,
"tastes just like you remember it!",
False,
@ -754,7 +775,8 @@ while 1:
False,
)
case 5:
thing, price, message, weird = (
# Bugfix here down: Don't redundantly set `weird` to `True` again
thing, price, message, rac = (
" trash",
200,
(
@ -762,58 +784,51 @@ while 1:
if uData["racScore"] < 10
else "You eagerly consume the trash pile! (+1 raccoon score)"
),
True,
1,
)
uData["racScore"] += 1
case 6:
thing, price, message, weird = (
thing, price, message = (
" money",
500,
"You literally just eat money. Disgusting.",
True,
)
case 7:
thing, price, message, weird = (
thing, price, message, rich = (
'a "tip"',
1000,
'You just give the cashier 1000 studs as a "tip". (+1 rich)',
True,
1,
)
uData["richScore"] += 1
case 8:
thing, price, message, weird = (
thing, price, message, rich = (
"a golden pizza",
5000,
"You add the golden pizza to your home. You can't eat it after all. (+1 rich)",
True,
1,
)
uData["richScore"] += 1
case 9:
thing, price, message, weird = (
thing, price, message, rich = (
"liquid gold",
10000,
"You chug the liquid gold. You are in severe pain for at least 20 minutes. (+2 rich)",
True,
2,
)
uData["richScore"] += 2
case 10:
thing, price, message, weird = (
thing, price, message, rich = (
"golden tacos",
20000,
"You add the golden tacos to your home. The box was too poor for them. (+5 rich)",
True,
5,
)
uData["richScore"] += 5
case 11:
thing, price, message, weird = (
thing, price, message, rich = (
"golden doughnuts",
50000,
"You add the golden doughtnuts to your home. Very sophisticated! (+15 rich)",
True,
15,
)
uData["richScore"] += 15
case 12:
thing, price, message, weird = (
thing, price, message, rich, rac = (
"golden trash",
200000,
(
@ -821,26 +836,23 @@ while 1:
if uData["racScore"] < 20
else "You eagerly consume the golden trash pile! (+20 rich, +5 raccoon)"
),
True,
20,
5,
)
uData["richScore"] += 20
uData["racScore"] += 5
case 13:
thing, price, message, weird = (
thing, price, message, rich = (
"5 cubic meters of gold",
500000,
"You EAT 5 cubic meters of gold. I don't even know how you managed that. (+25 rich)",
True,
25,
)
uData["richScore"] += 25
case 14:
thing, price, message, weird = (
thing, price, message, rich = (
'a hefty "tip"',
1000000,
'You "tip" the cashier a million studs. That\'s just not a tip man. (+30 rich)',
True,
30,
)
uData["richScore"] += 30 # Bugfix: Missing rich score increment
case "E":
pass
case _:
@ -848,7 +860,8 @@ while 1:
sleep(5)
if price > 0 and price <= uData["studs"]:
uData["studs"] -= price
uData["studsLost"] += price
uData["richScore"] += rich
uData["racScore"] += rac
if not weird:
print(
f"You {'eat' if sel!=2 else 'drink'} your {thing[2:]}... {message}"
@ -874,6 +887,7 @@ while 1:
"racScore": 0,
"richScore": 0,
"rare": {},
"upgrades": {},
}
fixed = False
for key in migrations:
@ -945,6 +959,25 @@ while 1:
)
sleep(60)
clear()
# Apply stud multipliers to any earned money after the everything else runs
newStuds = studsAtTop - uData["studs"]
if newStuds > 0:
uData["studs"] += newStuds * uData["upgrades"].get("studX", 1)
# If we're gonna have weird stud multipliers, we've gotta round those back to standard increments, and normal rounding isn't enough, since I want the studs to be locked to increments of 5.
if uData["studs"] % 1:
uData["studs"] = round(uData["studs"])
if uData["studs"] % 5:
if (uData["studs"] + (uData["studs"] % 5)) < (
uData["studs"] + (5 - (uData["studs"] % 5))
):
uData["studs"] -= uData["studs"] % 5
else:
uData["studs"] += 5 - (uData["studs"] % 5)
studsDiff = studsAtTop - uData["studs"]
if studsAtTop > 0:
uData["studsGained"] += studsDiff
else: # Yes, this could be caused if studsDiff is 0. However that's not a concern since it'll just subtract 0.
uData["studsLost"] -= studsDiff
if uData["studs"] > uData["highestStuds"]:
uData["highestStuds"] = uData["studs"]
db.set(