dkmud/world/spells.py
Francesco Cappelli db12c674ef da da da.
2022-01-25 22:23:39 +01:00

45 lines
No EOL
1.4 KiB
Python

from evennia import utils, create_script, logger
from evennia.utils import inherits_from
from typeclasses import effects
from typeclasses.mobs import Mob
from utils.utils import has_effect
def spell_light(caller, target, **kwargs):
if not target:
target_obj = caller
else:
target_obj = caller.search(target, location=[caller, caller.location])
if not target_obj:
return
if has_effect(target_obj, "emit_magic_light"):
caller.msg("{} already has a magical light on itself.".format(target_obj.name))
return
light_script = create_script(effects.EffectMagicalLight, obj=target_obj)
caller.msg("You cast |wlight|n on {}.".format(target_obj.name))
def spell_charm(caller, target, **kwargs):
if not target:
caller.msg("You need someone to place your charm on.")
return
target_obj = caller.search(target, location=[caller.location])
if not target_obj:
return
if not inherits_from(target_obj, Mob):
caller.msg("You cannot charm {}".format(target_obj.name))
return
if has_effect(target_obj, "charm"):
caller.msg("{} is already charmed.".format(target_obj.name))
return
charm_script = create_script(effects.EffectCharm, obj=target_obj, attributes=[("source", caller.dbref)])
caller.msg("You cast |wcharm|n on {}.".format(target_obj.name))