#!/usr/bin/env python

from evennia import Command, CmdSet
# from .command import Command

class CmdLight(Command):
    """
    Creates light where there was none. Something to burn.
    """

    key = "light"
    # only allow this command if command.obj is carried by caller.
    # locks = "cmd:holds()"

    def func(self):
        """
        Implements the light command. Since this command is designed
        to sit on a "lightable" object, we operate only on self.obj.
        """
        if self.obj.light():
            self.caller.msg("You light %s." % self.obj.key)
            self.caller.location.msg_contents(
                "%s lights %s!" % (self.caller, self.obj.key), exclude=[self.caller])
        else:
            self.caller.msg("%s is already burning." % self.obj.key)


class CmdSetLight(CmdSet):
    """CmdSet for the lightsource commands"""

    def at_cmdset_creation(self):
        """called at cmdset creation"""
        self.add(CmdLight)
