Combine 'get' and 'take'

Depends on if you have a from something at the end.
This commit is contained in:
Howard Abrams 2025-06-25 20:13:53 -07:00
parent c23a9856c9
commit cb88d646f9

View file

@ -4,7 +4,7 @@ from random import random
from re import split from re import split
from commands.command import Command from commands.command import Command
from evennia.commands.default.general import NumberedTargetCommand from evennia.commands.default.general import CmdGet, NumberedTargetCommand
from evennia.commands.default.muxcommand import MuxCommand from evennia.commands.default.muxcommand import MuxCommand
from evennia.contrib.rpg.rpsystem import send_emote from evennia.contrib.rpg.rpsystem import send_emote
from evennia.utils import iter_to_str, logger from evennia.utils import iter_to_str, logger
@ -94,7 +94,7 @@ class CmdSay(MuxCommand):
Usage: Usage:
say phrase say phrase
say/to char1, [char2 ...] = phrase say/to char1 [, char2 ...] = phrase
say[/switches] phrase say[/switches] phrase
Where switches can be any of the following: Where switches can be any of the following:
@ -313,19 +313,18 @@ class CmdRead(Command):
self.caller.msg(book.db.inside) self.caller.msg(book.db.inside)
class CmdTake(Command, NumberedTargetCommand): class CmdTake(CmdGet, NumberedTargetCommand):
""" """
Take an object from another character or NPC. Get something, possibly from another character or NPC.
Usage: Usage:
take <thing> from <character> get <thing> [ from <character> ]
Note that only some things can be stolen. Note that only some things can be stolen.
For instance, the brass ring from the door knocker. For instance, the brass ring from the door knocker.
""" """
key = "take" key = "take"
aliases = ["steal"] aliases = ["steal", "get"]
rhs_split = ("=", " from ") rhs_split = ("=", " from ")
def func(self): def func(self):
@ -336,9 +335,15 @@ class CmdTake(Command, NumberedTargetCommand):
operate only on self.obj. operate only on self.obj.
""" """
if not self.args: if not self.args:
self.caller.msg("What do you want to take?") self.caller.msg("What do you want to get?")
elif not self.rhs: elif not self.rhs:
self.caller.msg(f"You want to take {self.lhs}, but from whom?") # This is soo bad to hard-code this game logic, but enough
# people complained about not being able to 'get' the
# ring, I need to:
if self.lhs == "ring" and self.caller.location.key == "Grotto":
self.caller.msg("From whom do you want to get this ring?")
else:
super().func() # Call the 'get' function instead.
else: else:
self.caller.do_take(self.lhs, self.rhs) self.caller.do_take(self.lhs, self.rhs)