game.core.commands.command
core/commands/command.py
Implements the notorius game programming command pattern.
Defines the abstract Command interface and concrete game commands. (Fly, Map, QuestLog, Refresh, Exit). Includes a registry of commands and utilities for matching user input and executing commands.
Functions
|
Get a Command object matching the input_text. |
|
Decorator to register a Command class in the COMMAND registry. |
Classes
|
Abstract base class for game commands. |
Command to fly to a chosen airport. |
|
Command to view the map. |
|
Command to view the quest log. |
|
Command to refresh the game status. |
- class game.core.commands.command.Command
Bases:
ABC
Abstract base class for game commands.
- _abc_impl = <_abc._abc_data object>
- aliases: tuple[str, ...] = ()
- abstract execute(game, args: str = '') CommandResult
Execute the game command.
- Parameters:
game (Game) – The game instance.
args (str) – Optional arguments (e.g. 1,2,3..)
- Returns:
Result including messages and result status (ok | error).
- Return type:
- matches(text: str) bool
Check if text matches the command name or any aliases.
- name: str
- class game.core.commands.command.ExitCommand
Bases:
Command
- _abc_impl = <_abc._abc_data object>
- aliases: tuple[str, ...] = ('q', 'quit')
- execute(game, args='') CommandResult
Execute the game command.
- Parameters:
game (Game) – The game instance.
args (str) – Optional arguments (e.g. 1,2,3..)
- Returns:
Result including messages and result status (ok | error).
- Return type:
- name: str = 'exit'
- class game.core.commands.command.FlyCommand
Bases:
Command
Command to fly to a chosen airport.
- _abc_impl = <_abc._abc_data object>
- execute(game, args='') CommandResult
Execute flying to the chosen airport.
- matches(text: str) bool
Match digits as valid input.
- name: str = 'fly'
- class game.core.commands.command.MapCommand
Bases:
Command
Command to view the map.
- _abc_impl = <_abc._abc_data object>
- aliases: tuple[str, ...] = ('m',)
- execute(game, args='') CommandResult
Render the map including airports, target and player.
- name: str = 'map'
- class game.core.commands.command.QuestLogCommand
Bases:
Command
Command to view the quest log.
- _abc_impl = <_abc._abc_data object>
- aliases: tuple[str, ...] = ('quest', 'questlog')
- execute(game, args='') CommandResult
Display the quest log including active and completed quests.
- name: str = 'quests'
- class game.core.commands.command.RefreshCommand
Bases:
Command
Command to refresh the game status.
- _abc_impl = <_abc._abc_data object>
- aliases: tuple[str, ...] = ('r', 'i')
- execute(game, args='') CommandResult
Refresh the game status.
- name: str = 'refresh'