What it does
createRun generates a run map from a seed and a difficulty: columns of encounters from a single start to a single
boss, each node a fight, an elite, a rest or a shop, with edges to the next column. Every node is reachable and every
route reaches the boss, and there is always at least one shop and one rest. Harder difficulties make deeper maps.
Each node also carries its own seed, so your game can build the same encounter for it every time.
The run then enforces the order of play. Your game reports an encounter's result with finish(reward), which pays
the credits once and offers a draft of upgrades; choose takes one, and only then does travel accept a move, and
only along a connected edge. At a shop, buy checks the credits, that the upgrade is eligible and that it has not
already been bought in that shop. Clearing the boss wins the run and records it in the profile.
Upgrades are data: an id, a name, a level cap, a price, prerequisite levels of other upgrades and a list of upgrades it replaces. That is enough for evolutions: the built-in set has Star nova, which needs Bolt at level 3 and Haste at level 1, removes Bolt when taken, and stops Bolt being drafted again. The draft and availability functions also work on their own, without a map, for any game that offers upgrades.
Features
- Seeded run maps — a reachable graph of fights, elites, rests, shops and a boss, the same for the same seed and difficulty, with a seed per node for its encounter.
- Rules of travel — moves only along connected routes, and only once the encounter is finished and its reward chosen.
- Reward drafts — a stable, seeded draft of up to three eligible upgrades after each encounter, the same until one is chosen.
- Shops — buy with credits, one purchase of each upgrade per shop.
- Levels, prerequisites and evolutions — upgrades cap at a level, require levels of others, and can replace the ones they evolve from.
- A persistent profile — completed runs and unlocks carry through
fail,restartandnewRun. - Save and restore —
snapshotandrestoretake the whole run as plain data, and a restore checks the map still matches its seed.
Good for
- Action roguelites that move between arenas on a branching map, in the style of Slay the Spire's route choice.
- Survivor-style games with level-up drafts and weapons that evolve when two upgrades meet.
- Shooters with a shop between stages, where credits from each stage buy upgrades.
- Any game with a draft of upgrades, using
draftUpgradesandavailableUpgradeswithout the map. - Server checks and tests, since the rules run headless and every run is seeded.
Make it yours
The installer has no options; you pass definitions to the constructors. Your own upgrade list replaces the built-in
actionUpgrades, so the names, caps, prices, prerequisites and evolutions are yours. You choose the seed (any
unsigned 32-bit number, zero included), the difficulty (easy, medium, hard or very-hard), the credits each
encounter pays, and a starting profile loaded from wherever you store it. draftUpgrades takes its own count when
you use it directly.
Two different uses: a ship shooter where each node launches a wave, the boss node a boss fight, and upgrades are
weapons that evolve; and a card-free dungeon crawl that ignores the map and calls draftUpgrades after every floor to
offer three of its own perks with prerequisites between them.
A quick look
A run where the game reports a win, takes the first upgrade on offer and moves on:
import { createRun } from '@phaser-ae/run-progression';
const run = createRun(29, 'medium');
run.finish(20); // the game reports an encounter result
if (run.state.draft[0]) run.choose(run.state.draft[0]);
run.travel(run.node().next[0]!); // only connected routes are legal
Works with
survivor-rules— survivor-style combat to run inside each encounter.save— to store the profile and run snapshots between sessions.
Good to know
- The map's shape comes from the seed and the difficulty alone: its depth, width and mix of node kinds are not options.
- It guarantees a connected map with a boss route, not the balance of whatever combat you attach to a node.
- There is no deck system and no economy beyond credits; reward amounts come from your game.
- Profiles are local data, not authenticated progression.






