Types
Cheat
interface Cheat
From @phaser-ae/kernel
A debug control ("cheat"): a way into a game that playing would take minutes to reach. Jump to a level, a wave or a screen; give a power-up, lives or money; switch on infinite lives; win the level now. A game registers each one once, by name, with what it does; then anyone can run it:
bake play:cheatlists them,cheat level 4runs one, so an agent checking a build reaches any part of the game in one command instead of playing there;- a person: the backquote key (
), or?cheats` in the page's address for a button on a phone, opens a panel with every control.
A control's run is the game's own code, so it can reach anything. A jump should start the game as a player would
find it there (the earlier levels' progress in place), and an outcome should go through the game's own path (win
the level the way the game wins it), or what is checked is not what a player gets. Packs register theirs the same
way, so a game built on a pack has the pack's controls too.
readonly name: string— What it is called: short, lowercase, words joined by-(level,infinite-lives,give). Unique.readonly does: string— What it does, in one line, as the panel andcheatshow it ("Start at level n, the levels before it cleared").readonly args?: string— What it takes, if anything, in words ("n: 1-5", "item: shield, magnet or bomb"). Omitted: nothing.run(...args: string[]): string | void— Do it. Arguments arrive as the words typed after the name (cheat give shield→run('shield')); parse numbers yourself. Return a line saying what happened, or nothing. Throw with a message when the arguments are wrong.on?(): boolean— For a switch (infinite lives, invincible): whether it is on now. The panel shows it;runflips it.
CheatInfo
interface CheatInfo
From @phaser-ae/kernel
One control as list() gives it: what it is, not how it runs.
name: string— The control's name, asruntakes it.does: string— What it does, in one line.args?: string— What it takes, in words; absent when it takes nothing.on?: boolean— For a switch, whether it is on now; absent for a control that is not a switch.
Cheats
interface Cheats
From @phaser-ae/kernel
The game's debug controls: add them once at boot, run them by name, list them.
add(control: Cheat): void— Register a control for the life of the game (not a scene's), so it works from any screen. A name that is not lowercase words joined by-, or one used twice, throws.run(name: string, ...args: string[]): string— Run one by name: what it reported, ordone, with(on)or(off)after it for a switch. An unknown name throws, naming the ones there are. Before the game is ready (game.ready) a control is QUEUED, in order, and runs the moment it is;runthen answers "queued until the game is ready" instead of the control's own answer.list(): CheatInfo[]— Every control, in the order added.
