Spielerando

The Quest Is Done Before the Player Did Anything

When a quest, a detective case or a door counts as done the moment it starts, its list of goals is almost always empty. A check written as "every goal is met" answers yes to an empty list, because there is nothing in it that is not met. We had exactly this in our own clue journal, and a model check found it.

What you see

Why does an empty quest count as done?

In our clue journal, the player finds clues, connects them into deductions, and may close the case when every deduction it needs is made. The code asked need.every(...). For a case that needs no deductions, every has nothing to look at and says yes, so the case could be closed with an empty journal.

The blueprint's own list of pitfalls already said what should happen: a case that asks for nothing counts as done once the first clue is found. The code did not follow it, and our tests did not ask. The TLA+ check of the blueprint did: TLC tried every order of finding, connecting and closing, and showed the shortest way there: the case at its start, then one close, with nothing in the journal. Our diagram did not even have an arrow for that move.

How to check your game for it

The test has to ask the one question the bug gets wrong: a quest with nothing in its list, and a player who has done nothing, is it done? The answer must be no. Two more tests make sure the fix does not break the normal cases: the empty quest is done once the player has done something, and a quest with goals waits for all of them.

The test: fix.test.ts

TypeScript for Node's own test runner. The tests named below as the catch are the ones that fail on the bug.

import assert from "node:assert/strict";
import test from "node:test";
import { canClose } from "./fix.ts";

const nothingYet = { found: [], met: [] };

test("a quest that asks for nothing is not done before the player did anything", () => {
  assert.equal(canClose({ need: [] }, nothingYet), false, "the empty quest was done before the player did anything");
});

test("a quest that asks for nothing is done once the player did something", () => {
  assert.equal(canClose({ need: [] }, { found: ["torn letter"], met: [] }), true);
});

test("a quest with goals waits for every one of them", () => {
  const quest = { need: ["who wrote it", "where they went"] };
  assert.equal(canClose(quest, { found: ["torn letter"], met: ["who wrote it"] }), false);
  assert.equal(canClose(quest, { found: ["torn letter", "train ticket"], met: ["who wrote it", "where they went"] }), true);
});

The catch:

What it said on the code with the bug put back

✖ a quest that asks for nothing is not done before the player did anything
    the empty quest was done before the player did anything
    got true, expected false
✔ a quest that asks for nothing is done once the player did something
✔ a quest with goals waits for every one of them
3 tests: 2 passed, 1 failed

What it said on the fixed code

✔ a quest that asks for nothing is not done before the player did anything
✔ a quest that asks for nothing is done once the player did something
✔ a quest with goals waits for every one of them
3 tests: 3 passed, 0 failed

Run by pnpm fixes:check on 2026-11-26 with Node v24.15.0. The text above is its output.

The fix

Ask for one more thing besides "every goal is met": that the player has done something for this quest. In the clue journal that is the first clue found. In your game it may be the first item picked up or the first step of the quest.

Better still, do not ship a quest that asks for nothing by accident. When the game reads its quests, have it list every quest with an empty list of goals, and look at each one. Our blueprint's pitfall goes one step further: better never to ship one at all.

What changed

Lines with - are the code with the bug, lines with + the fix.

  export function canClose(quest: Quest, progress: Progress): boolean {
    const allMet = quest.need.every((goal) => progress.met.includes(goal));
-   return allMet;
+   // An empty list passes every "all of them" check: without this, a quest that asks for nothing
+   // is done before the player has done anything.
+   return allMet && progress.found.length > 0;
  }

The fixed code: fix.ts

/* When may a quest, a case or a door count as done? Every goal it asks for has to be met, and the
   player has to have done something for it. From the clue journal blueprint:
   https://spielerando.com/en/mechanics/clue-journal */

export interface Quest {
  /** The goals that must be met first. Empty means the quest asks for nothing. */
  need: string[];
}

export interface Progress {
  /** What the player has found or done for this quest so far. */
  found: string[];
  /** The goals met so far. */
  met: string[];
}

/** Whether the player may close the quest now. */
export function canClose(quest: Quest, progress: Progress): boolean {
  const allMet = quest.need.every((goal) => progress.met.includes(goal));
  // An empty list passes every "all of them" check: without this, a quest that asks for nothing
  // is done before the player has done anything.
  return allMet && progress.found.length > 0;
}

Paste this to your AI

In my game a quest (or a case, a level, a door) can count as done before the player has done anything for it. I think its list of goals is empty, and a check like "every goal is met" says yes to an empty list.

1. Before you change anything, find every place where my game decides that something is done. For each one, write down the steps it can be in (not started, started, ready, done) and what moves it from one step to the next. Point to the move that lets a quest with no goals jump straight to done.
2. For each place, write a test like the one below: when a quest has an empty list of goals and the player has done nothing yet, the quest must not count as done. Run the tests and paste me the real output.
3. Where a test fails, fix it the way the code below does: done only when every goal is met and the player has done something for it. Run the tests again and paste the output.
4. Let the quest close on "every goal is met" alone again for a moment, run the test, and show me that it fails. Then undo that.
5. List every quest in my game's data whose list of goals is empty, so I can decide whether that is on purpose.

Do not tell me it is fixed unless the test output shows it.

The button copies this text together with the fixed code and the test above, so your AI has everything.

Where we found it

The blueprint the bug was in, and the test that guards it there:

How we found them: the bugs our proofs found in our own code

Was this page helpful?

One click, no account. It shows us which pages help.

Next step

Code recipe

Quest state machine

The text to paste asks your AI to write down each quest's steps; this recipe keeps quests that way, so done is reached by a step you can point to, not by a yes to an empty list.

Last updated: 2026-11-26