Fix bug when taking objects from non-characters
Not that you _can_, but it shouldn't give a stack trace.
This commit is contained in:
parent
583c94433a
commit
853b1c2504
2 changed files with 16 additions and 6 deletions
|
|
@ -407,7 +407,17 @@ class CmdTake(CmdGet, NumberedTargetCommand):
|
|||
else:
|
||||
super().func() # Call the 'get' function instead.
|
||||
else:
|
||||
self.caller.do_take(self.lhs, self.rhs)
|
||||
location = self.caller.search(self.rhs, quiet=True)
|
||||
if len(location) == 0:
|
||||
self.caller.msg(f"Can't take '{self.lhs}' from '{self.rhs}'.")
|
||||
return
|
||||
|
||||
location = location[0]
|
||||
if location.is_typeclass("typeclasses.rooms.Room"):
|
||||
self.args = self.lhs
|
||||
super().func() # Call the 'get' function instead.
|
||||
return
|
||||
self.caller.do_take(self.lhs, location)
|
||||
|
||||
|
||||
class CmdDrink(Command):
|
||||
|
|
|
|||
|
|
@ -229,19 +229,19 @@ class Character(Object, GenderCharacter, ContribRPCharacter):
|
|||
def get_display_things(self, looker, *args, **kwargs):
|
||||
return super().get_display_things(looker, pose=False)
|
||||
|
||||
def do_take(self, to_take, from_whom):
|
||||
def do_take(self, to_take, victim):
|
||||
"""
|
||||
A character has a _steal_command. What are the limitations?
|
||||
"""
|
||||
victim = self.search(from_whom)
|
||||
if victim:
|
||||
thing = victim.has(to_take)
|
||||
thing = None
|
||||
if hasattr(victim, 'has') and callable(getattr(victim, 'has')):
|
||||
thing = victim.has(to_take)
|
||||
if thing and thing.db.can_take:
|
||||
self.msg(f"You take {thing.key} from {victim.key}.")
|
||||
thing.move_to(self, quiet=True, use_destination=True)
|
||||
return
|
||||
|
||||
self.msg(f"{victim.key} doesn't have a {to_take} you can take.")
|
||||
self.msg(f"{victim.key} doesn't have a {to_take} you can take.")
|
||||
|
||||
def pronoun_subjective(self, uppercase=False):
|
||||
gender = self.attributes.get('gender')
|
||||
|
|
|
|||
Loading…
Reference in a new issue