From 8f6ee80f301b996a37a0ce5e876ecafdaf153641 Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Tue, 14 Jul 2026 12:38:35 +0200 Subject: [PATCH] fix(quests): tick the escort engine before the quest engine; guard the valve Two independent world-logic bugs: - Game.publishHud ticked QuestEngine before EscortEngine, so the twins_reunited flag set by the escort was only observed a full turn later. On the turn the twins were reunited, 'quests' still listed the objective as active. - The valve_wheel/valve recipe had neither 'consume' nor 'requires', so it could be repeated indefinitely, minting a fresh ceramic fuse every time. It now requires notFlag cellar_drained and explains itself once the cellar is dry. --- .../java/thb/jeanluc/adventure/game/Game.java | 15 ++++++++++++--- .../src/main/resources/world/combinations.yaml | 4 ++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Semesterprojekt/src/main/java/thb/jeanluc/adventure/game/Game.java b/Semesterprojekt/src/main/java/thb/jeanluc/adventure/game/Game.java index 3ef935b..e6e4e42 100644 --- a/Semesterprojekt/src/main/java/thb/jeanluc/adventure/game/Game.java +++ b/Semesterprojekt/src/main/java/thb/jeanluc/adventure/game/Game.java @@ -7,7 +7,6 @@ import thb.jeanluc.adventure.command.CommandRegistry; import thb.jeanluc.adventure.command.ParsedCommand; import thb.jeanluc.adventure.io.text.Hud; import thb.jeanluc.adventure.io.text.MapView; -import thb.jeanluc.adventure.map.MapLayout; import thb.jeanluc.adventure.model.Ending; import java.util.Optional; @@ -35,7 +34,11 @@ public class Game { /** Optional onboarding guide; null in normal/loaded play. */ private TutorialGuide tutorialGuide; - /** Wires the interactive tutorial (New Game only). */ + /** + * Wires the interactive tutorial (New Game only). + * + * @param tutorialGuide the guide to run alongside the loop + */ public void setTutorialGuide(TutorialGuide tutorialGuide) { this.tutorialGuide = tutorialGuide; } @@ -96,9 +99,15 @@ public class Game { } } + /** + * Ticks the per-turn engines and republishes the whole view state — HUD, + * map, quest panel, and room music — to the IO channel. + */ private void publishHud() { - QuestEngine.tick(ctx); + // EscortEngine first: it sets flags (e.g. twins_reunited) that + // QuestEngine's stage-completion conditions read in the same turn. EscortEngine.tick(ctx); + QuestEngine.tick(ctx); ctx.getIo().setHud(new Hud( ctx.getPlayer().getCurrentRoom().getName(), ctx.getPlayer().getGold(), diff --git a/Semesterprojekt/src/main/resources/world/combinations.yaml b/Semesterprojekt/src/main/resources/world/combinations.yaml index 67ac8ee..4b6f244 100644 --- a/Semesterprojekt/src/main/resources/world/combinations.yaml +++ b/Semesterprojekt/src/main/resources/world/combinations.yaml @@ -13,8 +13,12 @@ - a: valve_wheel b: valve produce: fuse + requires: + - { notFlag: cellar_drained } effects: - { setFlag: cellar_drained } + failText: | + The cellar is already drained; the valve turns freely on nothing. response: | You fit the wheel and crank it hard. The valve groans, the black water drops away — and a ceramic fuse, washed loose, settles at your feet.