feat: implement quest lifecycle

This commit is contained in:
goose
2026-10-03 17:07:20 -04:00
parent 477c013474
commit 5139563d10
17 changed files with 741 additions and 2 deletions
+16
View File
@@ -16,6 +16,7 @@ const QUEST_BOARD_PROMPT := "Espace — Lire le tableau des quêtes"
@onready var spell_label: Label = $SpellLabel
@onready var deadline_label: Label = $DeadlineLabel
@onready var gold_label: Label = $GoldLabel
@onready var quest_tracker_label: Label = $QuestTrackerLabel
@onready var enemy_health_label: Label = $EnemyHealthLabel
@onready var combat_summary_label: Label = $CombatSummaryLabel
@onready var event_log: RichTextLabel = $EventLog
@@ -40,6 +41,7 @@ func refresh(state: GameState, events: Array[GameEvent] = [], run_state: RunStat
combat_summary_label.text = combat_summary
deadline_label.text = _deadline_status()
gold_label.text = "Or: %d" % (_run_state.gold if _run_state != null else 0)
quest_tracker_label.text = _quest_tracker()
context_prompt_label.text = get_context_prompt()
# The supplied RunState journal events are the only source for journal text.
event_log.clear()
@@ -75,6 +77,20 @@ func get_context_prompt() -> String:
_:
return ""
func _quest_tracker() -> String:
if _run_state == null or not "quest_manager" in _run_state or _run_state.quest_manager == null:
return "Quêtes : aucune"
var active: Array[QuestState] = _run_state.quest_manager.active_states()
if active.is_empty():
return "Quêtes : aucune active"
var state := active[0]
var definition := _run_state.quest_manager.catalog.get_quest(state.quest_id)
for objective: Dictionary in definition.get("objectives", []):
var objective_id := StringName(objective.get("id", ""))
if state.objectives.get(objective_id, 0) < int(objective.get("count", 1)):
return "%s — %s (%d/%d)" % [String(definition.get("title", state.quest_id)), String(objective.get("description", objective_id)), state.objectives.get(objective_id, 0), int(objective.get("count", 1))]
return "%s — terminée" % String(definition.get("title", state.quest_id))
func _deadline_status() -> String:
if _run_state == null:
return ""