mirror of
https://github.com/cliffe/BreakEscape.git
synced 2026-02-21 11:18:08 +00:00
4.1 KiB
4.1 KiB
Objectives System - Quick Reference
Task Types at a Glance
| Type | Trigger | Event Name | Example |
|---|---|---|---|
collect_items |
Player picks up items | item_picked_up:* |
Find 3 documents |
unlock_room |
Door unlocked | door_unlocked (use connectedRoom) |
Access server room |
unlock_object |
Container unlocked | item_unlocked (NOT object_unlocked) |
Open the safe |
npc_conversation |
Ink tag #complete_task:X |
task_completed_by_npc |
Talk to handler |
enter_room |
Player enters room | room_entered |
Explore the lab |
custom |
Ink tag #complete_task:X |
task_completed_by_npc |
Any other trigger |
Ink Tags
# complete_task:taskId -> Marks task complete
# unlock_task:taskId -> Makes locked task active
# unlock_aim:aimId -> Makes locked aim active
Scenario JSON Template
{
"objectives": [
{
"aimId": "unique_aim_id",
"title": "High-level goal",
"description": "Optional longer description",
"status": "active|locked",
"order": 1,
"unlockCondition": { "aimCompleted": "other_aim_id" },
"tasks": [
{
"taskId": "unique_task_id",
"title": "What player sees",
"type": "collect_items|unlock_room|unlock_object|npc_conversation|enter_room|custom",
"targetItems": ["item_type"],
"targetCount": 3,
"targetRoom": "room_id",
"targetObject": "Object Name",
"targetNpc": "npc_id",
"status": "active|locked",
"showProgress": true,
"onComplete": {
"unlockTask": "next_task_id",
"unlockAim": "next_aim_id"
}
}
]
}
]
}
API Endpoints (RESTful)
GET /break_escape/games/:id/objectives # Get current state
POST /break_escape/games/:id/objectives/tasks/:task_id # Complete a task
PUT /break_escape/games/:id/objectives/tasks/:task_id # Update progress
Events Emitted
// Task completed
eventDispatcher.emit('objective_task_completed', { taskId, aimId, task });
// Aim completed
eventDispatcher.emit('objective_aim_completed', { aimId, aim });
Events Listened To
'item_picked_up:*' // For collect_items (wildcard pattern)
'door_unlocked' // For unlock_room (use data.connectedRoom)
'item_unlocked' // For unlock_object (NOT object_unlocked!)
'room_entered' // For enter_room
'task_completed_by_npc' // From ink tags
Initialization Order
main.js: CreateObjectivesManagerinstance (manager only)game.js create(): RestoreobjectivesStatefrom server towindow.gameState.objectivesgame.js create(): CallobjectivesManager.initialize(gameScenario.objectives)game.js create(): CreateObjectivesPanelinstance
CRITICAL: Objectives data initialization MUST happen in
game.js create(), NOTmain.js. Scenario JSON isn't available untilcreate()runs.
CSS Classes
.objectives-panel /* Main container */
.objectives-panel.collapsed
.objective-aim /* Aim container */
.aim-active / .aim-completed
.objective-task /* Task container */
.task-active / .task-completed
Global Access
window.objectivesManager.completeTask('taskId');
window.objectivesManager.unlockTask('taskId');
window.objectivesManager.unlockAim('aimId');
window.objectivesManager.getActiveAims();
window.objectivesManager.reconcileWithGameState();
// Debug utilities
window.debugObjectives.showAll();
window.debugObjectives.reset();
Key Gotchas
- Event name:
item_unlockedNOTobject_unlocked - Door unlock events: Emitted from
unlock-system.js:560(NOT doors.js) - Door event data: Provides both
roomIdANDconnectedRoom(useconnectedRoomfor unlock tasks) - Key pickup events: Now emitted as
item_picked_up:keyfromaddKeyToInventory() - State restoration: Server passes
objectivesStatein scenario bootstrap - Reconciliation: Call
reconcileWithGameState()after init for late-loaded scenarios