Broke ExitCommand out for easier override.
This commit is contained in:
parent
e35a42c9fd
commit
c6be8b4a66
1 changed files with 40 additions and 33 deletions
|
|
@ -1441,38 +1441,10 @@ class DefaultRoom(DefaultObject):
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Base Exit object
|
# Default Exit command, used by the base exit object
|
||||||
#
|
#
|
||||||
|
|
||||||
class DefaultExit(DefaultObject):
|
class ExitCommand(command.Command):
|
||||||
"""
|
|
||||||
This is the base exit object - it connects a location to another.
|
|
||||||
This is done by the exit assigning a "command" on itself with the
|
|
||||||
same name as the exit object (to do this we need to remember to
|
|
||||||
re-create the command when the object is cached since it must be
|
|
||||||
created dynamically depending on what the exit is called). This
|
|
||||||
command (which has a high priority) will thus allow us to traverse
|
|
||||||
exits simply by giving the exit-object's name on its own.
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
# Helper classes and methods to implement the Exit. These need not
|
|
||||||
# be overloaded unless one want to change the foundation for how
|
|
||||||
# Exits work. See the end of the class for hook methods to overload.
|
|
||||||
|
|
||||||
def create_exit_cmdset(self, exidbobj):
|
|
||||||
"""
|
|
||||||
Helper function for creating an exit command set + command.
|
|
||||||
|
|
||||||
The command of this cmdset has the same name as the Exit
|
|
||||||
object and allows the exit to react when the player enter the
|
|
||||||
exit's name, triggering the movement between rooms.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
exiddobj (Object): The DefaultExit object to base the command on.
|
|
||||||
|
|
||||||
"""
|
|
||||||
class ExitCommand(command.Command):
|
|
||||||
"""
|
"""
|
||||||
This is a command that simply cause the caller to traverse
|
This is a command that simply cause the caller to traverse
|
||||||
the object it is attached to.
|
the object it is attached to.
|
||||||
|
|
@ -1497,9 +1469,44 @@ class DefaultExit(DefaultObject):
|
||||||
# No shorthand error message. Call hook.
|
# No shorthand error message. Call hook.
|
||||||
self.obj.at_failed_traverse(self.caller)
|
self.obj.at_failed_traverse(self.caller)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Base Exit object
|
||||||
|
#
|
||||||
|
|
||||||
|
class DefaultExit(DefaultObject):
|
||||||
|
"""
|
||||||
|
This is the base exit object - it connects a location to another.
|
||||||
|
This is done by the exit assigning a "command" on itself with the
|
||||||
|
same name as the exit object (to do this we need to remember to
|
||||||
|
re-create the command when the object is cached since it must be
|
||||||
|
created dynamically depending on what the exit is called). This
|
||||||
|
command (which has a high priority) will thus allow us to traverse
|
||||||
|
exits simply by giving the exit-object's name on its own.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
exit_command = ExitCommand
|
||||||
|
priority = 101
|
||||||
|
# Helper classes and methods to implement the Exit. These need not
|
||||||
|
# be overloaded unless one want to change the foundation for how
|
||||||
|
# Exits work. See the end of the class for hook methods to overload.
|
||||||
|
|
||||||
|
def create_exit_cmdset(self, exidbobj):
|
||||||
|
"""
|
||||||
|
Helper function for creating an exit command set + command.
|
||||||
|
|
||||||
|
The command of this cmdset has the same name as the Exit
|
||||||
|
object and allows the exit to react when the player enter the
|
||||||
|
exit's name, triggering the movement between rooms.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
exiddobj (Object): The DefaultExit object to base the command on.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
# create an exit command. We give the properties here,
|
# create an exit command. We give the properties here,
|
||||||
# to always trigger metaclass preparations
|
# to always trigger metaclass preparations
|
||||||
cmd = ExitCommand(key=exidbobj.db_key.strip().lower(),
|
cmd = self.exit_command(key=exidbobj.db_key.strip().lower(),
|
||||||
aliases=exidbobj.aliases.all(),
|
aliases=exidbobj.aliases.all(),
|
||||||
locks=str(exidbobj.locks),
|
locks=str(exidbobj.locks),
|
||||||
auto_help=False,
|
auto_help=False,
|
||||||
|
|
@ -1510,7 +1517,7 @@ class DefaultExit(DefaultObject):
|
||||||
# create a cmdset
|
# create a cmdset
|
||||||
exit_cmdset = cmdset.CmdSet(None)
|
exit_cmdset = cmdset.CmdSet(None)
|
||||||
exit_cmdset.key = '_exitset'
|
exit_cmdset.key = '_exitset'
|
||||||
exit_cmdset.priority = 101
|
exit_cmdset.priority = self.priority
|
||||||
exit_cmdset.duplicates = True
|
exit_cmdset.duplicates = True
|
||||||
# add command to cmdset
|
# add command to cmdset
|
||||||
exit_cmdset.add(cmd)
|
exit_cmdset.add(cmd)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue