moss-n-puddles/commands/feedables.py
2025-04-21 21:55:13 -07:00

48 lines
1.3 KiB
Python
Executable file

#!/usr/bin/env python
from evennia import CmdSet
from evennia.commands.default.general import CmdGive, NumberedTargetCommand
from commands.command import Command
class CmdFeed(Command, NumberedTargetCommand):
"""
Feed or give something to an object that can eat.
Typically this is used to feed wood to a fire, or
berries to a beast.
"""
key = "feed"
rhs_split = ("=", " to ")
def func(self):
"""
Implements the feed (or give) command.
"""
if not self.args:
self.caller.msg("Feed what?")
elif not self.rhs:
target = self.caller.search(self.lhs)
if target:
target.feed(self.caller)
else:
self.caller.msg(f"Don't see a '{self.lhs}' to feed.")
else:
self.caller.msg(f"give {self.args}")
self.caller.execute_cmd("give " + self.args)
# # Pass this off to CmdGive?
# supercmd = CmdGive()
# supercmd.caller = self.caller
# supercmd.args = self.args
# supercmd.lhs = self.lhs
# supercmd.rhs = self.rhs
# supercmd.func()
class CmdFeedSet(CmdSet):
"""
Things that can be fed. Like a pet.
"""
def at_cmdset_creation(self):
self.add(CmdFeed)