Update use to take an object
This commit is contained in:
parent
3bdb1d068f
commit
b0618891c8
2 changed files with 31 additions and 12 deletions
|
|
@ -38,23 +38,39 @@ def speech_effect(speech, verb, target, effects):
|
||||||
return (speech, speech, verb)
|
return (speech, speech, verb)
|
||||||
|
|
||||||
|
|
||||||
class CmdUse(Command):
|
class CmdUse(MuxCommand):
|
||||||
"""
|
"""
|
||||||
Use an item, probably something in your inventory, but could
|
Use an item.
|
||||||
also be something in the area.
|
|
||||||
|
The item, probably something in your inventory, could be something
|
||||||
|
in the local area.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
use <item>
|
use <item> [= object]
|
||||||
|
|
||||||
|
This standard from the text adventurer tome is a catch-all command
|
||||||
|
allowing you to use or combine an object with another object.
|
||||||
"""
|
"""
|
||||||
key = "use"
|
key = "use"
|
||||||
|
aliases = ["apply"]
|
||||||
|
rhs_split = ("=", " with ", " on ", " to ")
|
||||||
|
|
||||||
def func(self):
|
def func(self):
|
||||||
"""Call the 'do_use' method."""
|
"""Call the 'do_use' method."""
|
||||||
item = self.caller.search(self.args.strip())
|
if not self.args:
|
||||||
|
self.caller.msg("Use what?")
|
||||||
|
return
|
||||||
|
|
||||||
|
item = self.caller.search(self.lhs)
|
||||||
if item:
|
if item:
|
||||||
|
if self.rhs:
|
||||||
|
obj = self.caller.search(self.rhs)
|
||||||
|
else:
|
||||||
|
obj = None
|
||||||
|
|
||||||
if item.has_method('do_use'):
|
if item.has_method('do_use'):
|
||||||
item.do_use(self.caller)
|
item.do_use(self.caller, obj)
|
||||||
else:
|
else:
|
||||||
self.caller.msg(f"You can't use {item.name}.")
|
self.caller.msg(f"You can't use {item.name}.")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -87,26 +87,29 @@ class Rope(Object):
|
||||||
return (self.search_exit("hut on stilts"),
|
return (self.search_exit("hut on stilts"),
|
||||||
self.search_exit("rope-bound hut"))
|
self.search_exit("rope-bound hut"))
|
||||||
|
|
||||||
def do_use(self, caller):
|
def do_use(self, caller, obj=None):
|
||||||
if caller.location.key == "Mellow Marsh":
|
if caller.location.key == "Mellow Marsh" or (obj and obj.key == "Homey Hut"):
|
||||||
# Randomly miss?
|
# Randomly miss?
|
||||||
hut1_exit, hut2_exit = self.hut_exits()
|
hut1_exit, hut2_exit = self.hut_exits()
|
||||||
hut1_exit.move_to(None, to_none=True, quiet=True)
|
hut1_exit.move_to(None, to_none=True, quiet=True)
|
||||||
hut2_exit.move_to(caller.location, quiet=True)
|
hut2_exit.move_to(caller.location, quiet=True)
|
||||||
caller.location.add_room_state("bound")
|
caller.location.add_room_state("bound")
|
||||||
|
|
||||||
caller.announce_action("$You() $conj(tie) a knot in $pron(your) rope-vines, and $conj(throw) a lasso around the hut, binding the stilts so it can't run away.")
|
caller.announce_action("$You() $conj(tie) a knot in $pron(your) vine rope, and $conj(throw) a lasso around the hut, binding the stilts so it can't run away.")
|
||||||
delay(3, caller.location.msg_contents,
|
delay(3, caller.location.msg_contents,
|
||||||
"Something tells you that the rope won't last for long.")
|
"Something tells you that the rope won't last for long.")
|
||||||
delay(25, self.hut_breaks_free, caller.location)
|
delay(60, self.hut_breaks_free, caller.location)
|
||||||
|
else:
|
||||||
|
caller.msg("Unclear how to use the rope that way.")
|
||||||
|
|
||||||
def hut_breaks_free(self, marsh):
|
def hut_breaks_free(self, marsh):
|
||||||
hut1_exit, hut2_exit = self.hut_exits()
|
hut1_exit, hut2_exit = self.hut_exits()
|
||||||
hut1_exit.move_to(marsh, quiet=True)
|
hut1_exit.move_to(marsh, quiet=True)
|
||||||
hut2_exit.move_to(None, to_none=True, quiet=True)
|
hut2_exit.move_to(None, to_none=True, quiet=True)
|
||||||
marsh.remove_room_state("bound")
|
marsh.remove_room_state("bound")
|
||||||
marsh.msg_contents("The hut, straining against its bounds, finally breaks free to run around the muddy marsh.")
|
marsh.msg_contents("The hut, straining against its bounds, finally breaks free to run around the muddy marsh, rendering the vine rope useless.")
|
||||||
# self.delete()
|
self.delete()
|
||||||
|
|
||||||
|
|
||||||
class Trinket(Object):
|
class Trinket(Object):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue