MCPcopy Create free account
hub / github.com/Monogatari/Monogatari / resetGame

Function resetGame

src/engine/persistence.ts:111–152  ·  view source on GitHub ↗
(engine: VisualNovelEngine)

Source from the content-addressed store, hash-verified

109// ============================================================================
110
111export function resetGame (engine: VisualNovelEngine): Promise<unknown[]> {
112 // Stop autoplay
113 engine.autoPlay (false);
114
115 const skipSetting = engine.setting ('Skip');
116
117 if (skipSetting > 0) {
118 engine.skip (false);
119 }
120
121 // Reset Storage
122 const storageStructure = engine.global ('storageStructure');
123
124 engine.storage (JSON.parse(storageStructure));
125
126 // Reset Conditions
127 engine.state ({
128 step: 0,
129 label: engine.setting ('Label')
130 });
131
132 engine.global ('block', false);
133
134 // Reset History
135 for (const history of Object.keys (engine._history)) {
136 engine._history[history] = [];
137 }
138
139 // Run the reset method of all the actions so each of them can reset
140 // their own elements correctly
141 const promises: Promise<unknown>[] = [];
142
143 for (const action of engine.actions ()) {
144 promises.push (action.reset ());
145 }
146
147 for (const component of engine.components ()) {
148 promises.push (component.onReset ());
149 }
150
151 return Promise.all (promises);
152}
153
154// ============================================================================
155// Upgrade

Callers 1

loadFromSlotFunction · 0.85

Calls 12

autoPlayMethod · 0.80
settingMethod · 0.80
skipMethod · 0.80
globalMethod · 0.80
storageMethod · 0.80
stateMethod · 0.80
componentsMethod · 0.80
keysMethod · 0.65
actionsMethod · 0.45
resetMethod · 0.45
onResetMethod · 0.45
allMethod · 0.45

Tested by

no test coverage detected