#!/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):
    dabbler = Character.objects.search_object("#1")[0]
    dabbler.msg(f"{msg} {'from ' + sender if sender else ''} {'at ' + location if location else ''}")

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]
