moss-n-puddles/utils/support.py
Howard Abrams 542e140013 Figured the give and take system
Now the Knocker will only accept the ring, and not berries.
2025-04-03 18:54:20 -07:00

36 lines
1.1 KiB
Python
Executable file

#!/usr/bin/env python
from typeclasses.characters import Character
def character_has(holder, item):
"""
Return true if character, holder, has an item.
Where item is probably a string name to match an item's key.
It can also be a type, for instance:
character_has(character, typeclasses.drinkables.TeaCup)
"""
for i in holder.contents:
if isinstance(item, str) and i.key == item:
return i
elif i.key == item:
return i
elif type(i) == item:
return i
elif i == item:
return i
def god_msg(msg, sender=None, location=None):
"""
Bit of a debugging tool that allows messages to my character.
"""
dabbler = Character.objects.search_object("#1")[0]
send_msg = ('from ' + sender.name) if sender else ''
loc_msg = ('at ' + location.name) if location else ''
dabbler.msg(f"{msg} {send_msg} {loc_msg}")
def debug(msg, sender=None, location=None):
god_msg(f"DEBUG: {msg}", sender, location)
# py from typeclasses.characters import Character; god = Character.objects.search_object("#1")[0]