mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-12 19:32:17 +02:00
Add setOverlayMode to phaseInterceptor
This commit is contained in:
parent
49d8874433
commit
443ec4a572
@ -21,6 +21,8 @@ import KeyboardPlugin = Phaser.Input.Keyboard.KeyboardPlugin;
|
||||
import GamepadPlugin = Phaser.Input.Gamepad.GamepadPlugin;
|
||||
import EventEmitter = Phaser.Events.EventEmitter;
|
||||
import UpdateList = Phaser.GameObjects.UpdateList;
|
||||
import { PokedexMonContainer } from "#app/ui/pokedex-mon-container";
|
||||
import MockContainer from "./mocks/mocksContainer/mockContainer";
|
||||
// biome-ignore lint/style/noNamespaceImport: Necessary in order to mock the var
|
||||
import * as bypassLoginModule from "#app/global-vars/bypass-login";
|
||||
|
||||
@ -61,6 +63,10 @@ export default class GameWrapper {
|
||||
}
|
||||
};
|
||||
BattleScene.prototype.addPokemonIcon = () => new Phaser.GameObjects.Container(this.scene);
|
||||
|
||||
// Pokedex container is not actually mocking container, but the sprites they contain are mocked.
|
||||
// We need to mock the remove function to not throw an error when removing a sprite.
|
||||
PokedexMonContainer.prototype.remove = MockContainer.prototype.remove;
|
||||
}
|
||||
|
||||
setScene(scene: BattleScene) {
|
||||
|
@ -205,6 +205,7 @@ export default class PhaseInterceptor {
|
||||
private phaseFrom;
|
||||
private inProgress;
|
||||
private originalSetMode;
|
||||
private originalSetOverlayMode;
|
||||
private originalSuperEnd;
|
||||
|
||||
/**
|
||||
@ -442,6 +443,7 @@ export default class PhaseInterceptor {
|
||||
*/
|
||||
initPhases() {
|
||||
this.originalSetMode = UI.prototype.setMode;
|
||||
this.originalSetOverlayMode = UI.prototype.setOverlayMode;
|
||||
this.originalSuperEnd = Phase.prototype.end;
|
||||
UI.prototype.setMode = (mode, ...args) => this.setMode.call(this, mode, ...args);
|
||||
Phase.prototype.end = () => this.superEndPhase.call(this);
|
||||
@ -508,6 +510,18 @@ export default class PhaseInterceptor {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* mock to set overlay mode
|
||||
* @param mode - The {@linkcode Mode} to set.
|
||||
* @param args - Additional arguments to pass to the original method.
|
||||
*/
|
||||
setOverlayMode(mode: Mode, ...args: unknown[]): Promise<void> {
|
||||
const instance = this.scene.ui;
|
||||
console.log("setOverlayMode", `${Mode[mode]} (=${mode})`, args);
|
||||
const ret = this.originalSetOverlayMode.apply(instance, [mode, ...args]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to start the prompt handler.
|
||||
*/
|
||||
@ -572,6 +586,7 @@ export default class PhaseInterceptor {
|
||||
phase.prototype.start = this.phases[phase.name].start;
|
||||
}
|
||||
UI.prototype.setMode = this.originalSetMode;
|
||||
UI.prototype.setOverlayMode = this.originalSetOverlayMode;
|
||||
Phase.prototype.end = this.originalSuperEnd;
|
||||
clearInterval(this.promptInterval);
|
||||
clearInterval(this.interval);
|
||||
|
Loading…
Reference in New Issue
Block a user