diff --git a/untitled/content.py b/untitled/content.py index 5a408b2..76a1186 100644 --- a/untitled/content.py +++ b/untitled/content.py @@ -4,6 +4,7 @@ GAME_NAME = "Untitled Cat Game" # Titled Cat Game SAVE_VERSION = 2 HUNGER_DECAY_PER_HOUR = 5 +BASE_HAPPINESS_DECAY_PER_HOUR = 5 CAT_COLORS = [ "orange tabby", diff --git a/untitled/model.py b/untitled/model.py index 6180029..d349376 100644 --- a/untitled/model.py +++ b/untitled/model.py @@ -2,10 +2,11 @@ import time class Cat: - def __init__(self, name, traits, fullness=100, last_updated=None): + def __init__(self, name, traits, fullness=100, happiness=100, last_updated=None): self.name = name self.traits = traits self.fullness = fullness + self.happiness = happiness self.last_updated = last_updated if last_updated is not None else time.time() def to_dict(self): @@ -13,12 +14,19 @@ class Cat: "name": self.name, "traits": self.traits, "fullness": self.fullness, + "happiness": self.happiness, "last_updated": self.last_updated, } @staticmethod def from_dict(data): - return Cat(data["name"], data["traits"], data["fullness"], data["last_updated"]) + return Cat( + data["name"], + data["traits"], + data["fullness"], + data["happiness"], + data["last_updated"], + ) class Save: diff --git a/untitled/rules.py b/untitled/rules.py index fbb97bd..bb8d7dd 100644 --- a/untitled/rules.py +++ b/untitled/rules.py @@ -1,6 +1,6 @@ import string -from untitled import content +from untitled import content, model def validate_cat_name(name, auto_gen=False): @@ -17,13 +17,16 @@ def validate_cat_name(name, auto_gen=False): return "Your cat's name needs at least 1 letter." -def reconcile(cat, now): +def reconcile(cat: model.Cat, now): elapsed_hours = (now - cat.last_updated) / 3600 if elapsed_hours <= 0: return cat.fullness -= content.HUNGER_DECAY_PER_HOUR * elapsed_hours if cat.fullness < 0: cat.fullness = 0 + cat.happiness -= content.BASE_HAPPINESS_DECAY_PER_HOUR * elapsed_hours + if cat.happiness < 0: + cat.happiness = 0 cat.last_updated = now