food
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import string
|
||||
|
||||
from untitled import content
|
||||
|
||||
|
||||
def validate_cat_name(name, auto_gen=False):
|
||||
ALLOWED = set(string.ascii_letters + string.digits)
|
||||
@@ -13,3 +15,19 @@ def validate_cat_name(name, auto_gen=False):
|
||||
return "Your cat's name can only have letters and numbers."
|
||||
if not any(c in string.ascii_letters for c in name):
|
||||
return "Your cat's name needs at least 1 letter."
|
||||
|
||||
|
||||
def reconcile(cat, now):
|
||||
elapsed_hours = (now - cat.last_updated) / 3600
|
||||
if elapsed_hours <= 0:
|
||||
return
|
||||
cat.hunger -= content.HUNGER_DECAY_PER_HOUR * elapsed_hours
|
||||
if cat.hunger < 0:
|
||||
cat.hunger = 0
|
||||
cat.last_updated = now
|
||||
|
||||
|
||||
def feed(cat, amount=100):
|
||||
cat.hunger += amount
|
||||
if cat.hunger > 100:
|
||||
cat.hunger = 100
|
||||
|
||||
Reference in New Issue
Block a user