Happiness and Fullness
This commit is contained in:
@@ -1,2 +1,3 @@
|
|||||||
Major update!
|
Major update!
|
||||||
Added saving to the web version!
|
Added saving to the web version!
|
||||||
|
Added happiness level and fullness level
|
||||||
25
data/cat.py
25
data/cat.py
@@ -1,10 +1,31 @@
|
|||||||
|
import time # first import here!
|
||||||
|
|
||||||
|
|
||||||
class Cat:
|
class Cat:
|
||||||
def __init__(self, name, traits, money=25, inventory=None):
|
def __init__(
|
||||||
|
self,
|
||||||
|
name,
|
||||||
|
traits,
|
||||||
|
money=25,
|
||||||
|
inventory=None,
|
||||||
|
last_login=None,
|
||||||
|
fullness=100,
|
||||||
|
happiness=100,
|
||||||
|
):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.traits = traits
|
self.traits = traits
|
||||||
|
self.last_login = last_login or time.time()
|
||||||
self.money = money
|
self.money = money
|
||||||
self.inventory = inventory
|
|
||||||
self.inventory = inventory if inventory is not None else {}
|
self.inventory = inventory if inventory is not None else {}
|
||||||
|
self.fullness = fullness # really hunger, but 100 hunger being defualt sounds like its 100% hungry so its fullness.
|
||||||
|
self.happiness = happiness
|
||||||
|
|
||||||
|
def apply_decay(self): # first neat function! yayyy!
|
||||||
|
elapsed_hours = (time.time() - self.last_login) / 3600
|
||||||
|
if elapsed_hours <= 0:
|
||||||
|
elapsed_hours = 0
|
||||||
|
self.fullness -= 5 * elapsed_hours
|
||||||
|
self.happiness -= 5 * elapsed_hours
|
||||||
|
|
||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
return vars(self)
|
return vars(self)
|
||||||
|
|||||||
@@ -51,13 +51,7 @@ def prepare_move():
|
|||||||
print("No save data to prepare.")
|
print("No save data to prepare.")
|
||||||
|
|
||||||
|
|
||||||
class SaveData:
|
def save(cat: Cat, dont_save=False):
|
||||||
def __init__(self, cat, money=100):
|
|
||||||
self.cat = cat
|
|
||||||
self.money = money
|
|
||||||
|
|
||||||
|
|
||||||
def save(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. DO NOT use control+c to copy, instead, select it, and use the right click menu to copy, ctrl+c will crash this."
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ CAT_SIZES = [
|
|||||||
"big",
|
"big",
|
||||||
"chonky",
|
"chonky",
|
||||||
]
|
]
|
||||||
CAT_PERSONALITIES = [
|
CAT_PERSONALITIES = [ # TODO: start at different happiness levels based on personality
|
||||||
"looks like trouble",
|
"looks like trouble",
|
||||||
"judges you silently",
|
"judges you silently",
|
||||||
"won't stop meowing",
|
"won't stop meowing",
|
||||||
|
|||||||
5
game.py
5
game.py
@@ -8,6 +8,7 @@ import os
|
|||||||
import json
|
import json
|
||||||
import traceback
|
import traceback
|
||||||
import base64
|
import base64
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
class Game:
|
class Game:
|
||||||
@@ -77,8 +78,10 @@ class Game:
|
|||||||
print("Save complete.")
|
print("Save complete.")
|
||||||
self.game_loop()
|
self.game_loop()
|
||||||
|
|
||||||
# TODO: Add money system
|
# TODO: Add way to make money
|
||||||
def game_loop(self):
|
def game_loop(self):
|
||||||
|
self.cat.apply_decay()
|
||||||
|
self.cat.last_login = time.time()
|
||||||
ui.current_cat = self.cat
|
ui.current_cat = self.cat
|
||||||
while True:
|
while True:
|
||||||
match ui.select(
|
match ui.select(
|
||||||
|
|||||||
@@ -185,6 +185,8 @@ def house(cat: Cat):
|
|||||||
print(
|
print(
|
||||||
f"{cat.name} - a {cat.traits["size"]} {cat.traits["color"]} with {cat.traits["eyes"]} eyes."
|
f"{cat.name} - a {cat.traits["size"]} {cat.traits["color"]} with {cat.traits["eyes"]} eyes."
|
||||||
)
|
)
|
||||||
|
print(f"Happiness level: {cat.happiness}")
|
||||||
|
print(f"Fullness: {cat.fullness}/100")
|
||||||
print(f"You have ${cat.money}.")
|
print(f"You have ${cat.money}.")
|
||||||
case "Pet your cat":
|
case "Pet your cat":
|
||||||
pet(cat)
|
pet(cat)
|
||||||
|
|||||||
Reference in New Issue
Block a user