Quite pleased with the results. This also fixed a utils issue to see if an object has an item. I'm surprised this isn't in the standard library.
32 lines
877 B
Python
Executable file
32 lines
877 B
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 debug(msg, sender=None, location=None):
|
|
dabbler = Character.objects.search_object("Dabbler")[0]
|
|
full_msg = "DEBUG:"
|
|
if sender:
|
|
full_msg += f" (from {sender})"
|
|
if location:
|
|
full_msg += f" (at {location})"
|
|
full_msg += f" {msg}"
|
|
dabbler.msg(full_msg)
|