UUID Tracking, and some other minor things
This commit is contained in:
@@ -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
|
||||
|
||||
22
data/save.py
22
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 (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() + '"')
|
||||
handle_uuid_stuff(cat)
|
||||
print(
|
||||
"Your savefile has been printed above this, please save it somewhere safe."
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user