evennia.contrib.full_systems.evscaperoom.state

States represent the sequence of states the room goes through.

This module includes the BaseState class and the StateHandler for managing states on the room.

The state handler operates on an Evscaperoom and changes its state from one to another.

A given state is given as a module in states/ package. The state is identified by its module name.

class evennia.contrib.full_systems.evscaperoom.state.StateHandler(room)[源代码]

基类:object

This sits on the room and is used to progress through the states.

__init__(room)[源代码]

Initialize self. See help(type(self)) for accurate signature.

load_state(statename)[源代码]

Load state without initializing it

init_state()[源代码]

Initialize a new state

next_state(next_state=None)[源代码]

Check if the current state is finished. This should be called whenever the players do actions that may affect the state of the room.

参数

next_state (str, optional) – If given, override the next_state given by the current state’s check() method with this - this allows for branching paths (but the current state must still first agree that the check passes).

返回

state_changed (bool) – True if the state changed, False otherwise.

class evennia.contrib.full_systems.evscaperoom.state.BaseState(handler, room)[源代码]

基类:object

Base object holding all callables for a state. This is here to allow easy overriding for child states.

next_state = 'unset'
hints = []
__init__(handler, room)[源代码]

Initializer.

参数
  • room (EvscapeRoom) – The room tied to this state.

  • handler (StateHandler) – Back-reference to the handler storing this state.

get_hint()[源代码]

Get a hint for how to solve this state.

msg(message, target=None, borders=False, cinematic=False)[源代码]

Display messsage to everyone in room, or given target.

cinematic(message, target=None)[源代码]

Display a ‘cinematic’ sequence - centered, with borders.

create_object(typeclass=None, key='testobj', location=None, **kwargs)[源代码]

This is a convenience-wrapper for quickly building EvscapeRoom objects.

关键字参数
  • typeclass (str) – This can take just the class-name in the evscaperoom’s objects.py module. Otherwise, a full path or the actual class is needed (for custom state objects, just give the class directly).

  • key (str) – Name of object.

  • location (Object) – If not given, this will be the current room.

  • kwargs (any) – Will be passed into create_object.

返回

new_obj (Object) – The newly created object, if any.

get_object(key)[源代码]

Find a named non-character object for this state in this room.

参数

key (str) – Object to search for.

返回

obj (Object) – Object in the room.

init()[源代码]

Initializes the state (usually by modifying the room in some way)

clean()[源代码]

Any cleanup operations after the state ends.

next(next_state=None)[源代码]

Get the next state after this one.

参数

next_state (str, optional) – This allows the calling code to redirect to a different state than the ‘default’ one (creating branching paths in the game). Override this method to customize (by default the input will always override default set on the class)

返回

state_name (str or None)

Name of next state to switch to. None

to remain in this state. By default we check the room for the “finished” flag be set.

character_enters(character)[源代码]

Called when character enters the room in this state.

character_leaves(character)[源代码]

Called when character is whisked away (usually because of quitting). This method cannot influence the move itself; it happens just before room.character_cleanup()