Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3d130ecdd5 | |||
| 1a95ae57b1 | |||
| 1643fb93d0 | |||
| bf4abeb3b0 | |||
| 88a0eb61fd | |||
| 0f1f8071cd | |||
| 6c4c6c35a5 | |||
| 26ffc55d68 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -193,3 +193,4 @@ cython_debug/
|
||||
saves/
|
||||
*test*
|
||||
debug.json
|
||||
uuids.json
|
||||
@@ -1,3 +1,4 @@
|
||||
Release notes are broken, this is outdated, maybe I'll fix them later
|
||||
Major update!
|
||||
Added saving to the web version!
|
||||
Added happiness level and fullness level
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import time # first import here!
|
||||
import uuid
|
||||
|
||||
|
||||
class Cat:
|
||||
@@ -13,6 +14,7 @@ class Cat:
|
||||
happiness=100,
|
||||
sick=False,
|
||||
depressed=False,
|
||||
cat_uuid=None,
|
||||
):
|
||||
self.name = name
|
||||
self.traits = traits
|
||||
@@ -23,6 +25,7 @@ class Cat:
|
||||
self.happiness = happiness
|
||||
self.sick = sick
|
||||
self.depressed = depressed
|
||||
self.cat_uuid = cat_uuid or str(uuid.uuid4())
|
||||
|
||||
def apply_decay(self): # first neat function! yayyy!
|
||||
elapsed_hours = (time.time() - self.last_login) / 3600
|
||||
@@ -49,7 +52,6 @@ class Cat:
|
||||
)
|
||||
else:
|
||||
print("Your cat is still depressed! You can get catnip in the shop.")
|
||||
# TODO: do what claude said in latest summary
|
||||
|
||||
def to_dict(self):
|
||||
return vars(self)
|
||||
|
||||
23
data/save.py
23
data/save.py
@@ -51,12 +51,32 @@ def prepare_move():
|
||||
print("No save data to prepare.")
|
||||
|
||||
|
||||
def handle_uuid_stuff(cat: Cat):
|
||||
if os.path.exists("uuids.json"):
|
||||
try:
|
||||
with open("uuids.json", "r") as f:
|
||||
uuids = json.load(f)
|
||||
except:
|
||||
return
|
||||
if not uuids.get("enable"):
|
||||
return
|
||||
uuids[cat.cat_uuid] = {"name": cat.name, "last_login": cat.last_login}
|
||||
try:
|
||||
with open("uuids.json", "w") as f:
|
||||
json.dump(uuids, f)
|
||||
except:
|
||||
return
|
||||
else:
|
||||
return
|
||||
|
||||
|
||||
def save(cat: Cat, dont_save=False):
|
||||
if os.path.exists("WEB_VERSION") and not dont_save:
|
||||
print(
|
||||
"Under this message, in quotes, will be a long string of text, this is your savefile, please copy this somewhere safe (WITHOUT THE QUOTES) and make sure to copy the whole thing, you will paste it back to load your game. DO NOT use control+c to copy, instead, select it, and use the right click menu to copy, ctrl+c will crash this."
|
||||
"Under this message, in quotes, will be a long string of text, this is your savefile, please copy this somewhere safe and make sure to copy the whole thing, you will paste it back to load your game. You SHOULD be able to use CTRL+C+."
|
||||
)
|
||||
print('"' + base64.b64encode(json.dumps(cat.to_dict()).encode()).decode() + '"')
|
||||
handle_uuid_stuff(cat)
|
||||
print(
|
||||
"Your savefile has been printed above this, please save it somewhere safe."
|
||||
)
|
||||
@@ -91,6 +111,7 @@ def load(
|
||||
if os.path.exists("WEB_VERSION"):
|
||||
if not hide_web_message:
|
||||
print("Loading is disabled.")
|
||||
return None
|
||||
punished = False
|
||||
data_dir = get_data_dir()
|
||||
hash_path = os.path.join(data_dir, "dont hurt cats.json")
|
||||
|
||||
98
game.py
98
game.py
@@ -78,8 +78,13 @@ class Game:
|
||||
print("Save complete.")
|
||||
self.game_loop()
|
||||
|
||||
# TODO: Add way to make money
|
||||
def game_loop(self):
|
||||
if os.path.exists(
|
||||
"admin_handle.py"
|
||||
): # TODO: make this for specific uuids, like a thing to handle stuff for specific uuids, like give money, but make sure to remove the thing after, and maybe a admin_panel.py to configure a json which admin_handle.py also reads for stuff. i gtg.
|
||||
import admin_handle # type: ignore
|
||||
|
||||
admin_handle.handle(self.cat)
|
||||
self.cat.apply_decay()
|
||||
self.cat.last_login = time.time()
|
||||
ui.current_cat = self.cat
|
||||
@@ -103,7 +108,7 @@ class Game:
|
||||
def load_game(self):
|
||||
if os.path.exists("WEB_VERSION"):
|
||||
print(
|
||||
"Please paste your savefile on the next line, DO NOT USE CTRL+V, instead, right click and click paste. Make sure to not paste the quotes surrounding it if you copied those. Press enter to cancel."
|
||||
"Please paste your savefile on the next line, you can PROBABLY use CTRL+V. Press enter to cancel."
|
||||
)
|
||||
savetext = ui.text("Enter here:")
|
||||
if savetext:
|
||||
@@ -140,11 +145,9 @@ class Game:
|
||||
f"This is a web version of {data.text.GAME_NAME}, here is some important info. To anyone outside of Germany, this game is running on a cheap VPS I got, the company didn't have any US locations available, so I had to get a Germany one, sorry for the high ping (I also have to deal with it, I'm in the US)\nPls don't hack this"
|
||||
)
|
||||
print(
|
||||
"Just a recommendation, don't press any keys with CTRL, it will probably break something. If something weird happens, reload."
|
||||
)
|
||||
print(
|
||||
"By weird, I mean, skipped dialog, crashes, skipping stuff, and breaking a ton, don't click CTRL+C (CTRL+A also seems to end the game for some reason. IDK why. Some other keys might also.)"
|
||||
"Update: You can now use CTRL+C and CTRL+V, and most other CTRL keys shouldn't crash the game (CTRL+R) will reload still, so any web browser stuff that could break it still will. To anyone that didn't know about this, CTRL keys used to crash the game."
|
||||
)
|
||||
|
||||
if os.path.exists("debug.json"):
|
||||
bypass_tamper_check = False
|
||||
debug_config = None
|
||||
@@ -176,7 +179,11 @@ class Game:
|
||||
return
|
||||
|
||||
options = ["New Game", "Release Notes", "Credits"]
|
||||
if os.path.exists("saves") or os.path.exists("WEB_VERSION"):
|
||||
if (
|
||||
os.path.exists("saves")
|
||||
and os.listdir("saves")
|
||||
or os.path.exists("WEB_VERSION")
|
||||
):
|
||||
options.insert(0, "Load Game")
|
||||
if not os.path.exists("WEB_VERSION"):
|
||||
options.append("Quit")
|
||||
@@ -213,16 +220,83 @@ if __name__ == "__main__":
|
||||
print("Developer stuff incoming, if you can, tell me what this says:")
|
||||
traceback.print_exc()
|
||||
print(
|
||||
"Welp, seems that the game crashed, idk why. A common cause of this is pressing CTRL+C, which will cancel some UI stuff and just break the game. If you're on the desktop version, reopen it, if you're on the web version, reload, and don't use CTRL+C.\nOtherwise, great job! You found an issue in the game! If you can, please tell me."
|
||||
"Welp, seems that the game crashed, idk why. A common cause of this is, as of now, IDK, because I fixed the CTRL issue (tell me if it crashed from CTRL+something). If you're on the desktop version, reopen it, if you're on the web version, reload.\nOtherwise, great job! You found an issue in the game! If you can, please tell me."
|
||||
)
|
||||
if os.path.exists("WEB_VERSION"):
|
||||
print(
|
||||
"I could try to give you your savefile, though it might not appear, here's what should be your current savefile:"
|
||||
)
|
||||
try:
|
||||
print(
|
||||
'"'
|
||||
+ base64.b64encode(json.dumps(game.cat.to_dict()).encode()).decode()
|
||||
+ '"'
|
||||
)
|
||||
except:
|
||||
print("Welp, the game broke too much :(.")
|
||||
print(
|
||||
"It's above this message, if theres nothing, the game broke too much, sorry."
|
||||
)
|
||||
print(
|
||||
"Take a moment to screenshot the error or write it down or something if you can send it to me, and:"
|
||||
"Copy it if you can, you paste it into the Load Game menu option when you select it BTW."
|
||||
)
|
||||
ui.press_any_key_to_continue(
|
||||
"Press any key to quit/do nothing if you're on the web version."
|
||||
print(
|
||||
"I'm gonna try to do some other stuff to save RN, if there's a bunch of errors under here, it's PROBABLY fine :)"
|
||||
)
|
||||
try:
|
||||
data.save.handle_uuid_stuff(game.cat)
|
||||
except:
|
||||
print("Yep, that did NOT go as planned.")
|
||||
print("If there's no errors above this, yay.")
|
||||
else:
|
||||
if ui.confirm("Would you like me to attmept to run the save feature?"):
|
||||
try:
|
||||
data.save.save(game.cat)
|
||||
except:
|
||||
print("Sorry, the game is too broken to save :(")
|
||||
print(
|
||||
"Bye I guess, sorry about the crash, you can relaunch if you want :)?"
|
||||
)
|
||||
|
||||
else:
|
||||
if not result:
|
||||
print(
|
||||
"I think you did CTRL+C? I said not to I think. Well, here you are! Great job, not following instructions, I said it for a reason."
|
||||
"So, it seems the game managed to exit, without it meaning to exit, you found a bug! Great job! If you can, please tell me what happened. If you know my Gitea server link, create an issue on the Whiskerbound repository. Sorry, you gotta reload."
|
||||
)
|
||||
if os.path.exists("WEB_VERSION"):
|
||||
print(
|
||||
"I could try to give you your savefile, though it might not appear, here's what should be your current savefile:"
|
||||
)
|
||||
try:
|
||||
print(
|
||||
'"'
|
||||
+ base64.b64encode(
|
||||
json.dumps(game.cat.to_dict()).encode()
|
||||
).decode()
|
||||
+ '"'
|
||||
)
|
||||
except:
|
||||
print("Welp, the game broke too much :(.")
|
||||
print(
|
||||
"It's above this message, if theres nothing, the game broke too much, sorry."
|
||||
)
|
||||
print(
|
||||
"Copy it if you can, you paste it into the Load Game menu option when you select it BTW."
|
||||
)
|
||||
print(
|
||||
"I'm gonna try to do some other stuff to save RN, if there's a bunch of errors under here, it's PROBABLY fine :)"
|
||||
)
|
||||
try:
|
||||
data.save.handle_uuid_stuff(game.cat)
|
||||
except:
|
||||
print("Yep, that did NOT go as planned.")
|
||||
print("If there's no errors above this, yay.")
|
||||
else:
|
||||
if ui.confirm("Would you like me to attmept to run the save feature?"):
|
||||
try:
|
||||
data.save.save(game.cat)
|
||||
except:
|
||||
print("Sorry, the game is too broken to save :(")
|
||||
print(
|
||||
"Bye I guess, sorry about the crash, you can relaunch if you want :)?"
|
||||
)
|
||||
|
||||
@@ -3,6 +3,7 @@ import json
|
||||
import data.save
|
||||
import systems.ui # should cause circular import but doesn't, so not fixing it
|
||||
import data.text
|
||||
import data.cat
|
||||
|
||||
|
||||
def fix_hash(current_cat):
|
||||
@@ -23,15 +24,50 @@ def fix_hash(current_cat):
|
||||
json.dump(currentjson, f)
|
||||
|
||||
|
||||
def debug_menu(current_cat):
|
||||
def debug_menu(current_cat: data.cat.Cat):
|
||||
print("hi")
|
||||
while True:
|
||||
match systems.ui.select(
|
||||
"choose ur way of breaking the game",
|
||||
["Breakpoint", "Fix hash", "Debug settings", "Back"],
|
||||
[
|
||||
"Breakpoint",
|
||||
"Fix hash",
|
||||
"Remove depression and sickness and max out both",
|
||||
"FREE MONEY!!!",
|
||||
"Instantly quit the game without saving",
|
||||
"Debug settings",
|
||||
"Back",
|
||||
],
|
||||
hide_debug=True,
|
||||
):
|
||||
case "Remove depression and sickness and max out both":
|
||||
current_cat.depressed = False
|
||||
current_cat.sick = False
|
||||
current_cat.happiness = 100
|
||||
current_cat.fullness = 100
|
||||
print("Done")
|
||||
case "FREE MONEY!!!":
|
||||
print(f"You have ${current_cat.money} right now.")
|
||||
try:
|
||||
current_cat.money = (
|
||||
int(
|
||||
systems.ui.text(
|
||||
"Enter the amount of money to SET the money to, not add, SET:"
|
||||
)
|
||||
)
|
||||
or current_cat.money
|
||||
)
|
||||
except:
|
||||
print("wat")
|
||||
case "Instantly quit the game without saving":
|
||||
exec(
|
||||
"instantly quit the game without saving"
|
||||
) # i mean, i quit it, what more do you want?
|
||||
case "Breakpoint":
|
||||
print(
|
||||
"In this context, the cat is not cat or self.cat, use current_cat instead."
|
||||
)
|
||||
print("DON'T TYPE EXIT! Instead run 'c' as code.")
|
||||
breakpoint()
|
||||
case "Fix hash":
|
||||
fix_hash(current_cat)
|
||||
|
||||
@@ -41,7 +41,7 @@ def item_menu(cat: data.cat.Cat, item):
|
||||
cat.happiness = 25.0
|
||||
cat.inventory["Catnip"] -= 1
|
||||
print(
|
||||
f"{cat.name} plays with the catnip. {cat.name} is less depressed! They still are still sad though."
|
||||
f"{cat.name} plays with the catnip. {cat.name} is less depressed! They are still sad though."
|
||||
)
|
||||
else:
|
||||
print("You don't have any catnip!")
|
||||
|
||||
Reference in New Issue
Block a user