Happiness and Fullness
This commit is contained in:
25
data/cat.py
25
data/cat.py
@@ -1,10 +1,31 @@
|
||||
import time # first import here!
|
||||
|
||||
|
||||
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.traits = traits
|
||||
self.last_login = last_login or time.time()
|
||||
self.money = money
|
||||
self.inventory = inventory
|
||||
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):
|
||||
return vars(self)
|
||||
|
||||
Reference in New Issue
Block a user