dkmud/utils/utils.py
Francesco Cappelli 5ef1b78c42 sistemati spells
2022-02-17 18:33:26 +01:00

37 lines
888 B
Python

def has_tag(obj, key, category):
return obj.tags.get(key=key, category=category) is not None;
def fmt_light(message):
return "|r\u2600|y {} |r\u2600|n".format(message)
def fmt_dark(message):
return "|w\u2600|=h {} |w\u2600|n".format(message)
def toggle_effect(obj, effect):
if has_tag(obj, effect, "effect"):
obj.tags.remove(effect, category="effect")
else:
obj.tags.add(effect, category="effect")
def has_effect(obj, effect):
return has_tag(obj, effect, "effect")
def has_effect_in(obj, effects):
return any(True for effect in effects if has_tag(obj, effect, "effect"))
def indefinite_article(name):
"""Return the right english indefinite article for given name."""
the_vowels = ["a","e","i","o","u"]
value = ""
if name[0].lower() in the_vowels:
value = "an"
else:
value = "a"
return value