pokerogue/src/phases/message-phase.ts
ImperialSympathizer 5888a7758c
Mystery Encounter bug fixes and minor adjustments (#4299)
* various bug fixes for MEs

* various bug fixes for MEs

* fix final isTransferable rename that was missed

* change Trainer's test vouchers for second option

* change unit test skips

* cut down excess ME track length and loop properly

* ME bug fix cleanup

* updating AI for Slumbering Snorlax ME, and small ME balance changes

* fix ts error

* fix bug type superfan dialogue discrepancy

* ME bug fixes PR feedback

* ME PR nits and fixes

---------

Co-authored-by: ImperialSympathizer <imperialsympathizer@gmail.com>
2024-09-19 14:44:10 +01:00

45 lines
1.5 KiB
TypeScript

import BattleScene from "#app/battle-scene";
import { Phase } from "#app/phase";
export class MessagePhase extends Phase {
private text: string;
private callbackDelay: integer | null;
private prompt: boolean | null;
private promptDelay: integer | null;
private speaker?: string;
constructor(scene: BattleScene, text: string, callbackDelay?: integer | null, prompt?: boolean | null, promptDelay?: integer | null, speaker?: string) {
super(scene);
this.text = text;
this.callbackDelay = callbackDelay!; // TODO: is this bang correct?
this.prompt = prompt!; // TODO: is this bang correct?
this.promptDelay = promptDelay!; // TODO: is this bang correct?
this.speaker = speaker;
}
start() {
super.start();
if (this.text.indexOf("$") > -1) {
const pageIndex = this.text.indexOf("$");
this.scene.unshiftPhase(new MessagePhase(this.scene, this.text.slice(pageIndex + 1), this.callbackDelay, this.prompt, this.promptDelay, this.speaker));
this.text = this.text.slice(0, pageIndex).trim();
}
if (this.speaker) {
this.scene.ui.showDialogue(this.text, this.speaker, null, () => this.end(), this.callbackDelay || (this.prompt ? 0 : 1500), this.promptDelay ?? 0);
} else {
this.scene.ui.showText(this.text, null, () => this.end(), this.callbackDelay || (this.prompt ? 0 : 1500), this.prompt, this.promptDelay);
}
}
end() {
if (this.scene.abilityBar.shown) {
this.scene.abilityBar.hide();
}
super.end();
}
}