mini_arcade_core.engine.cheats

Cheats module for Mini Arcade Core. Provides cheat codes and related functionality.

Attributes

Classes

CheatCode

Represents a registered cheat code.

CheatManager

Reusable cheat code matcher.

Module Contents

mini_arcade_core.engine.cheats.TContext
class mini_arcade_core.engine.cheats.CheatCode

Represents a registered cheat code.

Variables:
  • (str) (name) – Unique name of the cheat code.

  • ...]) (sequence (tuple[str,) – Sequence of key strings that trigger the cheat.

  • (CheatAction) (action) – BaseCheatCommand to call when the cheat is activated.

  • (bool) (enabled) – Whether to clear the input buffer after a match.

  • (bool) – Whether the cheat code is enabled.

name: str
sequence: tuple[str, Ellipsis]
command_factory: Callable[[TContext], mini_arcade_core.engine.commands.Command] | None = None
clear_buffer_on_match: bool = False
enabled: bool = True
class mini_arcade_core.engine.cheats.CheatManager

Reusable cheat code matcher. Keeps a rolling buffer of recent keys and triggers callbacks on sequence match.

buffer_size: int = 16
enabled: bool = True
__post_init__()
register(name: str, *, sequence: Sequence[str], command_factory: Callable[[TContext], mini_arcade_core.engine.commands.Command], clear_buffer_on_match: bool = False, enabled: bool = True)

Register a new cheat code.

Parameters:
  • name (str) – Unique name of the cheat code.

  • sequence (Sequence[str]) – Sequence of key strings that trigger the cheat.

  • command_factory (Callable[[TContext], Command]) – Factory function to create the Command when the cheat is activated.

  • clear_buffer_on_match (bool) – Whether to clear the input buffer after a match.

  • enabled (bool) – Whether the cheat code is enabled.

Raises:

ValueError – If name is empty or sequence is empty.

process_frame(input_frame: mini_arcade_core.runtime.input_frame.InputFrame, *, context: TContext, queue: mini_arcade_core.engine.commands.CommandQueue) list[str]

Process an InputFrame for cheat code matches.

Parameters:
  • input_frame (InputFrame) – InputFrame containing current inputs.

  • context (TContext) – Context to pass to command factories.

  • queue (CommandQueue) – CommandQueue to push matched commands into.

Returns:

List of names of matched cheat codes.

Return type:

list[str]

process_key(key: str, *, context: TContext, queue: mini_arcade_core.engine.commands.CommandQueue) list[str]

Process a single key input.

Parameters:
  • key (str) – The key string to process.

  • context (TContext) – Context to pass to command factories.

  • queue (CommandQueue) – CommandQueue to push matched commands into.

Returns:

List of names of matched cheat codes.

Return type:

list[str]