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:
objectMixin that implements
unlock()forUnlockable.Sets
stateto"unlocked"and returns the storedon_unlockcommand so that follow-up effects can be executed.
- class escapy.mixins.DecodableMixin[source]
Bases:
objectMixin that implements
insert_code()forDecodable.Compares the supplied code against
code. On a match theon_decodecommand is returned; otherwise aWrongCodeEventis 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_decodecommand if the code is correct, or a command that emitsWrongCodeEvent.- Return type:
Command