A WIP Evennia escape room themed MUD
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

64 lines
3.0 KiB

"""
Exits
Exits are connectors between Rooms. An exit always has a destination property
set and has a single command defined on itself with the same name as its key,
for allowing Characters to traverse the exit to its destination.
"""
from evennia import DefaultExit
from commands.keypad import CmdSetKeypad
from evennia.utils import delay
class Exit(DefaultExit):
"""
Exits are connectors between rooms. Exits are normal Objects except
they defines the `destination` property. It also does work in the
following methods:
basetype_setup() - sets default exit locks (to change, use `at_object_creation` instead).
at_cmdset_get(**kwargs) - this is called when the cmdset is accessed and should
rebuild the Exit cmdset along with a command matching the name
of the Exit object. Conventionally, a kwarg `force_init`
should force a rebuild of the cmdset, this is triggered
by the `@alias` command when aliases are changed.
at_failed_traverse() - gives a default error message ("You cannot
go there") if exit traversal fails and an
attribute `err_traverse` is not defined.
Relevant hooks to overload (compared to other types of Objects):
at_traverse(traveller, target_loc) - called to do the actual traversal and calling of the other hooks.
If overloading this, consider using super() to use the default
movement implementation (and hook-calling).
at_after_traverse(traveller, source_loc) - called by at_traverse just after traversing.
at_failed_traverse(traveller) - called by at_traverse if traversal failed for some reason. Will
not be called if the attribute `err_traverse` is
defined, in which case that will simply be echoed.
"""
def return_appearance(self, looker, **kwargs):
'Modified version of what users normally see when using look'
if not looker:
return ''
return self.db.desc
class KeypadDoor(Exit):
def at_object_creation(self):
self.cmdset.add(CmdSetKeypad, permanent=True)
self.db.keycode = '0000'
self.db.desc = 'You see a locked door, |xunlock|n it with the keypad'
def at_traverse(self, traveller, target_loc):
if self.db.locked:
traveller.msg('The door is locked, |xuse the keypad|n to unlock it')
return
self.db.locked = True
traveller.msg('You hear the door lock itself again')
super().at_traverse(traveller, target_loc)
def attempt_unlock(self, traveller, keycode):
if keycode == self.db.keycode:
traveller.msg("The keypad flashes green, the door is unlocked")
self.db.locked = False
else:
traveller.msg(f"The keypad flashes red, {keycode} is not the correct keycode")