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

Method revert

src/actions/HideCharacter.ts:141–157  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

139 }
140
141 override async revert(): Promise<void> {
142 const history = this.engine.history('character') as { statement: string; previous: string | null }[];
143 for (let i = history.length - 1; i >= 0; i--) {
144 const { statement } = history[i];
145 const [, , asset] = statement.split(' ');
146
147 if (asset === this.asset) {
148 const action = this.engine.prepareAction(statement, { cycle: 'Application' }) as import('../lib/types').ActionInstance | null;
149 if (action !== null) {
150 await action.apply();
151 await action.didApply({ updateHistory: false, updateState: true });
152 }
153 return;
154 }
155 }
156 throw new Error('Failed to revert HideCharacter');
157 }
158
159 override async didRevert(): Promise<ActionRevertResult> {
160 return { advance: true, step: true };

Callers

nothing calls this directly

Calls 4

historyMethod · 0.80
prepareActionMethod · 0.80
applyMethod · 0.45
didApplyMethod · 0.45

Tested by

no test coverage detected