gtg
This commit is contained in:
@@ -4,6 +4,7 @@ GAME_NAME = "Untitled Cat Game" # Titled Cat Game
|
|||||||
SAVE_VERSION = 2
|
SAVE_VERSION = 2
|
||||||
|
|
||||||
HUNGER_DECAY_PER_HOUR = 5
|
HUNGER_DECAY_PER_HOUR = 5
|
||||||
|
BASE_HAPPINESS_DECAY_PER_HOUR = 5
|
||||||
|
|
||||||
CAT_COLORS = [
|
CAT_COLORS = [
|
||||||
"orange tabby",
|
"orange tabby",
|
||||||
|
|||||||
@@ -2,10 +2,11 @@ import time
|
|||||||
|
|
||||||
|
|
||||||
class Cat:
|
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.name = name
|
||||||
self.traits = traits
|
self.traits = traits
|
||||||
self.fullness = fullness
|
self.fullness = fullness
|
||||||
|
self.happiness = happiness
|
||||||
self.last_updated = last_updated if last_updated is not None else time.time()
|
self.last_updated = last_updated if last_updated is not None else time.time()
|
||||||
|
|
||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
@@ -13,12 +14,19 @@ class Cat:
|
|||||||
"name": self.name,
|
"name": self.name,
|
||||||
"traits": self.traits,
|
"traits": self.traits,
|
||||||
"fullness": self.fullness,
|
"fullness": self.fullness,
|
||||||
|
"happiness": self.happiness,
|
||||||
"last_updated": self.last_updated,
|
"last_updated": self.last_updated,
|
||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def from_dict(data):
|
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:
|
class Save:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import string
|
import string
|
||||||
|
|
||||||
from untitled import content
|
from untitled import content, model
|
||||||
|
|
||||||
|
|
||||||
def validate_cat_name(name, auto_gen=False):
|
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."
|
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
|
elapsed_hours = (now - cat.last_updated) / 3600
|
||||||
if elapsed_hours <= 0:
|
if elapsed_hours <= 0:
|
||||||
return
|
return
|
||||||
cat.fullness -= content.HUNGER_DECAY_PER_HOUR * elapsed_hours
|
cat.fullness -= content.HUNGER_DECAY_PER_HOUR * elapsed_hours
|
||||||
if cat.fullness < 0:
|
if cat.fullness < 0:
|
||||||
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
|
cat.last_updated = now
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user