diff --git a/commands/everyone.py b/commands/everyone.py index 8bfeae6..fec9dd9 100755 --- a/commands/everyone.py +++ b/commands/everyone.py @@ -38,23 +38,39 @@ def speech_effect(speech, verb, target, effects): return (speech, speech, verb) -class CmdUse(Command): +class CmdUse(MuxCommand): """ - Use an item, probably something in your inventory, but could - also be something in the area. + Use an item. + + The item, probably something in your inventory, could be something + in the local area. Usage: - use + use [= 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" + aliases = ["apply"] + rhs_split = ("=", " with ", " on ", " to ") def func(self): """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 self.rhs: + obj = self.caller.search(self.rhs) + else: + obj = None + if item.has_method('do_use'): - item.do_use(self.caller) + item.do_use(self.caller, obj) else: self.caller.msg(f"You can't use {item.name}.") diff --git a/typeclasses/things.py b/typeclasses/things.py index bf39880..7052283 100755 --- a/typeclasses/things.py +++ b/typeclasses/things.py @@ -87,26 +87,29 @@ class Rope(Object): return (self.search_exit("hut on stilts"), self.search_exit("rope-bound hut")) - def do_use(self, caller): - if caller.location.key == "Mellow Marsh": + def do_use(self, caller, obj=None): + if caller.location.key == "Mellow Marsh" or (obj and obj.key == "Homey Hut"): # Randomly miss? hut1_exit, hut2_exit = self.hut_exits() hut1_exit.move_to(None, to_none=True, quiet=True) hut2_exit.move_to(caller.location, quiet=True) 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, "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): hut1_exit, hut2_exit = self.hut_exits() hut1_exit.move_to(marsh, quiet=True) hut2_exit.move_to(None, to_none=True, quiet=True) marsh.remove_room_state("bound") - marsh.msg_contents("The hut, straining against its bounds, finally breaks free to run around the muddy marsh.") - # self.delete() + 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() + class Trinket(Object): """