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

Function rollback

src/engine/lifecycle.ts:503–530  ·  view source on GitHub ↗
(engine: VisualNovelEngine)

Source from the content-addressed store, hash-verified

501}
502
503export async function rollback (engine: VisualNovelEngine): Promise<void> {
504 const allowRollback = engine.setting ('AllowRollback') === true;
505
506 if (!allowRollback) {
507 return;
508 }
509
510 const stateObj = engine.state() as { step: number; label: string };
511
512 if (stateObj.step === 0) {
513 const jumpHistory = engine.history ('jump') as { destination: { label: string; step: number } }[];
514 const jump = [...jumpHistory].reverse ().find (o => {
515 return o.destination.label === stateObj.label && o.destination.step === 0;
516 });
517
518 if (typeof jump === 'undefined') {
519 engine.debug.debug ('Will not attempt rollback since this is the beginning of the game.');
520 return;
521 }
522 }
523
524 await shouldRollback (engine);
525
526 engine.global ('_engine_block', true);
527
528 await willRollback (engine);
529 await engine.previous ();
530}
531
532// ============================================================================
533// Proceed/Rollback Checks

Callers

nothing calls this directly

Calls 8

shouldRollbackFunction · 0.85
willRollbackFunction · 0.85
settingMethod · 0.80
stateMethod · 0.80
historyMethod · 0.80
debugMethod · 0.80
globalMethod · 0.80
previousMethod · 0.80

Tested by

no test coverage detected