UUID Tracking, and some other minor things
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -193,3 +193,4 @@ cython_debug/
|
|||||||
saves/
|
saves/
|
||||||
*test*
|
*test*
|
||||||
debug.json
|
debug.json
|
||||||
|
uuids.json
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
Release notes are broken, this is outdated, maybe I'll fix them later
|
||||||
Major update!
|
Major update!
|
||||||
Added saving to the web version!
|
Added saving to the web version!
|
||||||
Added happiness level and fullness level
|
Added happiness level and fullness level
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import time # first import here!
|
import time # first import here!
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
|
||||||
class Cat:
|
class Cat:
|
||||||
@@ -13,6 +14,7 @@ class Cat:
|
|||||||
happiness=100,
|
happiness=100,
|
||||||
sick=False,
|
sick=False,
|
||||||
depressed=False,
|
depressed=False,
|
||||||
|
cat_uuid=None,
|
||||||
):
|
):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.traits = traits
|
self.traits = traits
|
||||||
@@ -23,6 +25,7 @@ class Cat:
|
|||||||
self.happiness = happiness
|
self.happiness = happiness
|
||||||
self.sick = sick
|
self.sick = sick
|
||||||
self.depressed = depressed
|
self.depressed = depressed
|
||||||
|
self.cat_uuid = cat_uuid or str(uuid.uuid4())
|
||||||
|
|
||||||
def apply_decay(self): # first neat function! yayyy!
|
def apply_decay(self): # first neat function! yayyy!
|
||||||
elapsed_hours = (time.time() - self.last_login) / 3600
|
elapsed_hours = (time.time() - self.last_login) / 3600
|
||||||
|
|||||||
22
data/save.py
22
data/save.py
@@ -51,12 +51,32 @@ def prepare_move():
|
|||||||
print("No save data to prepare.")
|
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):
|
def save(cat: Cat, dont_save=False):
|
||||||
if os.path.exists("WEB_VERSION") and not dont_save:
|
if os.path.exists("WEB_VERSION") and not dont_save:
|
||||||
print(
|
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 (WITHOUT THE QUOTES) 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 and CTRL+V."
|
||||||
)
|
)
|
||||||
print('"' + base64.b64encode(json.dumps(cat.to_dict()).encode()).decode() + '"')
|
print('"' + base64.b64encode(json.dumps(cat.to_dict()).encode()).decode() + '"')
|
||||||
|
handle_uuid_stuff(cat)
|
||||||
print(
|
print(
|
||||||
"Your savefile has been printed above this, please save it somewhere safe."
|
"Your savefile has been printed above this, please save it somewhere safe."
|
||||||
)
|
)
|
||||||
|
|||||||
1
game.py
1
game.py
@@ -78,7 +78,6 @@ class Game:
|
|||||||
print("Save complete.")
|
print("Save complete.")
|
||||||
self.game_loop()
|
self.game_loop()
|
||||||
|
|
||||||
# TODO: Add way to make money
|
|
||||||
def game_loop(self):
|
def game_loop(self):
|
||||||
self.cat.apply_decay()
|
self.cat.apply_decay()
|
||||||
self.cat.last_login = time.time()
|
self.cat.last_login = time.time()
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import json
|
|||||||
import data.save
|
import data.save
|
||||||
import systems.ui # should cause circular import but doesn't, so not fixing it
|
import systems.ui # should cause circular import but doesn't, so not fixing it
|
||||||
import data.text
|
import data.text
|
||||||
|
import data.cat
|
||||||
|
|
||||||
|
|
||||||
def fix_hash(current_cat):
|
def fix_hash(current_cat):
|
||||||
@@ -23,15 +24,50 @@ def fix_hash(current_cat):
|
|||||||
json.dump(currentjson, f)
|
json.dump(currentjson, f)
|
||||||
|
|
||||||
|
|
||||||
def debug_menu(current_cat):
|
def debug_menu(current_cat: data.cat.Cat):
|
||||||
print("hi")
|
print("hi")
|
||||||
while True:
|
while True:
|
||||||
match systems.ui.select(
|
match systems.ui.select(
|
||||||
"choose ur way of breaking the game",
|
"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,
|
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":
|
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()
|
breakpoint()
|
||||||
case "Fix hash":
|
case "Fix hash":
|
||||||
fix_hash(current_cat)
|
fix_hash(current_cat)
|
||||||
|
|||||||
Reference in New Issue
Block a user