Fix fiery fallout message bug

This commit is contained in:
Sirz Benjie 2025-05-17 23:50:24 -05:00
parent 22f5ed1232
commit e0e307c4d4
No known key found for this signature in database
GPG Key ID: 4A524B4D196C759E

View File

@ -35,20 +35,18 @@ export class MessagePhase extends Phase {
this.text = this.text.split(pokename[p]).join(repname[p]); this.text = this.text.split(pokename[p]).join(repname[p]);
} }
const pageIndex = this.text.indexOf("$"); const pageIndex = this.text.indexOf("$");
for (let p = 0; p < globalScene.getPlayerField().length; p++) {
this.text = this.text.split(repname[p]).join(pokename[p]);
}
if (pageIndex !== -1) { if (pageIndex !== -1) {
let page0 = this.text.slice(0, pageIndex);
let page1 = this.text.slice(pageIndex + 1);
// Pokemon names must be re-inserted _after_ the split, otherwise the index will be wrong
for (let p = 0; p < globalScene.getPlayerField().length; p++) {
page0 = page0.split(repname[p]).join(pokename[p]);
page1 = page1.split(repname[p]).join(pokename[p]);
}
globalScene.unshiftPhase( globalScene.unshiftPhase(
new MessagePhase( new MessagePhase(page1, this.callbackDelay, this.prompt, this.promptDelay, this.speaker),
this.text.slice(pageIndex + 1),
this.callbackDelay,
this.prompt,
this.promptDelay,
this.speaker,
),
); );
this.text = this.text.slice(0, pageIndex).trim(); this.text = page0.trim();
} }
} }