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)[source]¶ Bases:
object
This sits on the room and is used to progress through the states.
-
next_state
(next_state=None)[source]¶ Check if the current state is finished. This should be called whenever the players do actions that may affect the state of the room.
- Parameters
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).
- Returns
state_changed (bool) – True if the state changed, False otherwise.
-
-
class
evennia.contrib.full_systems.evscaperoom.state.
BaseState
(handler, room)[source]¶ Bases:
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)[source]¶ Initializer.
- Parameters
room (EvscapeRoom) – The room tied to this state.
handler (StateHandler) – Back-reference to the handler storing this state.
-
msg
(message, target=None, borders=False, cinematic=False)[source]¶ Display messsage to everyone in room, or given target.
-
create_object
(typeclass=None, key='testobj', location=None, **kwargs)[source]¶ This is a convenience-wrapper for quickly building EvscapeRoom objects.
- Keyword Arguments
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.
- Returns
new_obj (Object) – The newly created object, if any.
-
get_object
(key)[source]¶ Find a named non-character object for this state in this room.
- Parameters
key (str) – Object to search for.
- Returns
obj (Object) – Object in the room.
-
next
(next_state=None)[source]¶ Get the next state after this one.
- Parameters
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)
- Returns
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.
-