escapy.mixins

Mixin classes providing reusable unlock and decode behaviour.

These mixins are designed to be composed with protocol classes via multiple inheritance. They supply concrete implementations of unlock() and insert_code() so that game-object classes don’t have to re-implement the same logic.

class escapy.mixins.UnlockableMixin[source]

Bases: object

Mixin that implements unlock() for Unlockable.

Sets state to "unlocked" and returns the stored on_unlock command so that follow-up effects can be executed.

unlock()[source]

Unlock the object and return its on_unlock command.

Parameters:

self (Unlockable)

Return type:

Command

class escapy.mixins.DecodableMixin[source]

Bases: object

Mixin that implements insert_code() for Decodable.

Compares the supplied code against code. On a match the on_decode command is returned; otherwise a WrongCodeEvent is emitted.

insert_code(code)[source]

Check code and return the appropriate command.

Parameters:
  • code (str) – The code string entered by the player.

  • self (Decodable)

Returns:

The on_decode command if the code is correct, or a command that emits WrongCodeEvent.

Return type:

Command