Add an open and close command
This commit is contained in:
parent
192dd83000
commit
02c640c7ad
1 changed files with 67 additions and 0 deletions
|
|
@ -117,6 +117,73 @@ class CmdPull(Command):
|
|||
self.caller.msg(f"You can't pull {item.name}.")
|
||||
|
||||
|
||||
class CmdOpen(Command):
|
||||
"""
|
||||
Open something.
|
||||
|
||||
Usage:
|
||||
|
||||
open <item>
|
||||
"""
|
||||
key = "open"
|
||||
|
||||
def func(self):
|
||||
"""
|
||||
Call an item's 'do_open' method.
|
||||
|
||||
Note that if the room the caller is in has a 'do_open', we
|
||||
call that first to see if the room can open something (like an
|
||||
exit).
|
||||
"""
|
||||
opener = self.caller
|
||||
room = opener.location
|
||||
to_open = self.args.strip()
|
||||
|
||||
if room.has_method('do_open'):
|
||||
if room.do_open(opener, to_open):
|
||||
return
|
||||
|
||||
item = opener.search(to_open)
|
||||
if item:
|
||||
if item.has_method('do_open'):
|
||||
item.do_open(opener)
|
||||
else:
|
||||
opener.msg(f"You can't open {item.name}.")
|
||||
|
||||
|
||||
class CmdClose(Command):
|
||||
"""
|
||||
Close something.
|
||||
|
||||
Usage:
|
||||
|
||||
close <item>
|
||||
"""
|
||||
key = "close"
|
||||
|
||||
def func(self):
|
||||
"""Call the 'do_close' method.
|
||||
|
||||
Note that if the room the caller is in has a 'do_close', we
|
||||
call that first to see if the room can close something (like
|
||||
an exit).
|
||||
"""
|
||||
closer = self.caller
|
||||
room = closer.location
|
||||
to_open = self.args.strip()
|
||||
|
||||
if room.has_method('do_close'):
|
||||
if room.do_close(closer, to_open):
|
||||
return
|
||||
|
||||
item = closer.search(to_open)
|
||||
if item:
|
||||
if item.has_method('do_close'):
|
||||
item.do_close(closer)
|
||||
else:
|
||||
closer.msg(f"You can't close {item.name}.")
|
||||
|
||||
|
||||
class CmdWhisper(MuxCommand):
|
||||
"""
|
||||
Speak privately as your character to another.
|
||||
|
|
|
|||
Loading…
Reference in a new issue