Quest System¶
The quests module provides quest tracking, objectives, and quest management functionality.
Quest Classes¶
Quest system for managing objectives and storylines.
This module provides a flexible quest system for tracking player progress, objectives, and rewards.
- class barebones_rpg.quests.quest.QuestStatus(value)[source]¶
Bases:
EnumQuest status states.
- NOT_STARTED = 1¶
- ACTIVE = 2¶
- COMPLETED = 3¶
- FAILED = 4¶
- class barebones_rpg.quests.quest.ObjectiveType(value)[source]¶
Bases:
EnumTypes of quest objectives.
- KILL_ENEMY = 1¶
- COLLECT_ITEM = 2¶
- TALK_TO_NPC = 3¶
- REACH_LOCATION = 4¶
- CUSTOM = 5¶
- class barebones_rpg.quests.quest.QuestObjective(**data)[source]¶
Bases:
BaseModelA single objective within a quest.
Example
>>> objective = QuestObjective( ... description="Defeat 5 goblins", ... objective_type=ObjectiveType.KILL_ENEMY, ... target="Goblin", ... target_count=5 ... )
-
objective_type:
ObjectiveType¶
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- get_progress_text()[source]¶
Get progress text for this objective.
- Return type:
- Returns:
Progress string like “3/5”
-
objective_type:
- class barebones_rpg.quests.quest.Quest(*, id=<factory>, name, description='', status=QuestStatus.NOT_STARTED, objectives=<factory>, exp_reward=0, gold_reward=0, item_rewards=<factory>, giver_npc_id=None, required_level=1, required_quests=<factory>, on_start=None, on_complete=None, on_fail=None, metadata=<factory>)[source]¶
Bases:
BaseModelA quest with objectives and rewards.
Quests automatically register themselves with the QuestManager singleton when created.
Example
>>> quest = Quest( ... name="Save the Village", ... description="The village is under attack by goblins!" ... ) # Automatically registers to QuestManager >>> quest.add_objective(QuestObjective( ... description="Defeat goblin chief", ... objective_type=ObjectiveType.KILL_ENEMY, ... target="Goblin Chief" ... ))
-
status:
QuestStatus¶
-
objectives:
List[QuestObjective]¶
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- __init__(**data)[source]¶
Initialize quest.
Note: Quests are not automatically registered to QuestManager. Call QuestManager().add_quest(quest) explicitly if you want to use the quest manager.
- add_objective(objective)[source]¶
Add an objective to the quest.
- Parameters:
objective (
QuestObjective) – Objective to add- Return type:
- Returns:
True if objective was added successfully
- complete(events=None)[source]¶
Complete the quest.
- Parameters:
events (
Optional[EventManager]) – Event manager for publishing events- Return type:
- fail(events=None)[source]¶
Fail the quest.
- Parameters:
events (
Optional[EventManager]) – Event manager for publishing events- Return type:
- check_completion(events=None)[source]¶
Check if all objectives are completed.
- Parameters:
events (
Optional[EventManager]) – Event manager for publishing events- Return type:
- Returns:
True if quest should be completed
- is_completed()[source]¶
Check if quest is completed.
- Return type:
- Returns:
True if quest is completed
- get_progress_percentage()[source]¶
Get overall progress percentage.
- Return type:
- Returns:
Progress from 0.0 to 1.0
- check_retroactive_progress(events=None, location=None, world=None)[source]¶
Check for retroactive progress on objectives.
This method checks if objectives can be completed based on current world state, even if the required actions happened before the quest was started.
For example, if a quest requires killing a unique enemy (tracked by ID) and that enemy is already dead when the quest starts, this will mark the objective complete.
Objectives with ID-based targets (UUIDs) are considered unique and will be checked retroactively. Name-based targets are considered generic and won’t be checked.
-
status:
- class barebones_rpg.quests.quest.QuestManager(*args, **kwargs)[source]¶
Bases:
objectManages all quests in the game (Singleton).
This is a framework-managed singleton. Access by instantiating directly: QuestManager()
Example
>>> quest = Quest(name="Tutorial Quest") # Auto-registers >>> QuestManager().start_quest(quest.id) >>> # Or via game instance: >>> game.quests.start_quest(quest.id)
- classmethod reset()[source]¶
Reset manager to initial state (for testing).
Clears the singleton instance, causing the next access to create a fresh instance with default initialization.
- Return type:
- add_quest(quest)[source]¶
Add a quest to the manager.
Automatically registers any callbacks (on_start, on_complete, on_fail) to the CallbackRegistry for serialization support.
- start_quest(quest_id, events=None)[source]¶
Start a quest.
- Parameters:
quest_id (
str) – Quest ID to startevents (
Optional[EventManager]) – Event manager
- Return type:
- Returns:
True if quest was started
- complete_quest(quest_id, events=None)[source]¶
Complete a quest.
- Parameters:
quest_id (
str) – Quest IDevents (
Optional[EventManager]) – Event manager
- Return type:
- Returns:
True if quest was completed
- update_objective(quest_id, objective_type, target, amount=1, events=None)[source]¶
Update progress on matching objectives.
This is a helper method for common objective updates like killing enemies or collecting items.
- Parameters:
quest_id (
str) – Quest IDobjective_type (
ObjectiveType) – Type of objectivetarget (
str) – Target identifieramount (
int) – Amount to incrementevents (
Optional[EventManager]) – Event manager
- Return type:
- Returns:
True if any objectives were updated