Interface: ReactTextGameDebug
Defined in: packages/core/src/global.d.ts:5
Properties
currentPassage
readonlycurrentPassage:Passage|null
Defined in: packages/core/src/global.d.ts:8
Game
Game: typeof
Game
Defined in: packages/core/src/global.d.ts:6
getPassage()
getPassage: (
passageId) =>Passage|null
Defined in: packages/core/src/global.d.ts:12
Retrieves a passage by its unique identifier.
Parameters
passageId
string
The unique ID of the passage to retrieve.
Returns
Passage | null
The passage object if found, or null if no passage exists with the given ID.
Throws
Error if Game.init() has not been called
getState()
getState: (
_fromI) =>GameSaveState
Defined in: packages/core/src/global.d.ts:13
Captures the complete game state including all entities and passages.
This method:
- Saves the Game's internal state (current passage)
- Saves all registered entity states
- Returns the complete state object
Parameters
_fromI
boolean = false
Returns
The complete serializable game state
Throws
Error if Game.init() has not been called
Example
const savedState = Game.getState();
localStorage.setItem('save1', JSON.stringify(savedState));
jumpTo()
jumpTo: (
passage) =>void
Defined in: packages/core/src/global.d.ts:11
Navigates the game to a specified passage.
On each call, generates a new unique renderId to enable React components to force remounts when revisiting the same passage. This is useful for resetting component state, restarting animations, or clearing forms.
Parameters
passage
The passage object or identifier of the passage to jump to.
string | Passage
Returns
void
Does not return any value.
Throws
Throws an error if the specified passage is not found or if Game.init() has not been called
Example
// Jump to a passage by ID
Game.jumpTo('intro');
// Jump to a passage object
const chapter1 = newStory('chapter1', () => [...]);
Game.jumpTo(chapter1);
// Jumping to the same passage multiple times will generate different renderIds
Game.jumpTo('combat'); // renderId: "1234567890-0.123"
Game.jumpTo('combat'); // renderId: "1234567891-0.456" (different!)
passages
readonlypassages:Passage[]
Defined in: packages/core/src/global.d.ts:10
setState()
setState: (
state) =>void
Defined in: packages/core/src/global.d.ts:14
Restores the complete game state including all entities and passages.
This method:
- Sets the Storage state
- Loads the Game's internal state (current passage)
- Loads all registered entity states
Parameters
state
The game state to restore
Returns
void
Throws
Error if Game.init() has not been called
Example
const savedState = JSON.parse(localStorage.getItem('save1'));
Game.setState(savedState);
state
readonlystate:Record<string,unknown>
Defined in: packages/core/src/global.d.ts:9
Storage
Storage: typeof
Storage
Defined in: packages/core/src/global.d.ts:7