Skip to content
Fungi

Stage a moment with a test scenario

Open a fresh world already set up for one moment, for a proof or a quick look.

Some moments take a long time to reach in play: the third night, a horde at the door, a ship low on shot. A test scenario opens a fresh world already set up for that moment. Declare it on the cartridge by id. It holds host actions (spawn a few actors, say) and commands the player “has already given”:

TS
export default defineCartridge({
// ...
scenarios: {
"door-siege": {
actions: [
spawn(brute, { receipt: "siege.1", cause: "scenario", at: [0, 3] }),
],
commands: [{ command: "walk", input: { target: { cell: [0, 0, -1] } } }],
},
},
});

Open the game with ?scenario=door-siege to start a fresh local world in it. In a test, pass it to testWorld:

TS
const world = testWorld(game, { scenario: "door-siege" });

The scenario’s actions run after the world’s initial actions, and then its commands queue. A world started without a scenario never sees them, so your game never needs to check whether it is under test. An unknown id is refused.