Fix crash when trainer has no encounter or victory messages
parent
74f9c51188
commit
6d8ea0ad79
|
@ -580,7 +580,7 @@ export class EncounterPhase extends BattlePhase {
|
||||||
|
|
||||||
const encounterMessages = this.scene.currentBattle.trainer.getEncounterMessages();
|
const encounterMessages = this.scene.currentBattle.trainer.getEncounterMessages();
|
||||||
|
|
||||||
if (!encounterMessages.length)
|
if (!encounterMessages?.length)
|
||||||
doSummon();
|
doSummon();
|
||||||
else {
|
else {
|
||||||
let message: string;
|
let message: string;
|
||||||
|
@ -2746,7 +2746,7 @@ export class TrainerVictoryPhase extends BattlePhase {
|
||||||
this.scene.ui.showText(`You defeated\n${this.scene.currentBattle.trainer.getName(true)}!`, null, () => {
|
this.scene.ui.showText(`You defeated\n${this.scene.currentBattle.trainer.getName(true)}!`, null, () => {
|
||||||
const victoryMessages = this.scene.currentBattle.trainer.getVictoryMessages();
|
const victoryMessages = this.scene.currentBattle.trainer.getVictoryMessages();
|
||||||
let showMessageAndEnd = () => this.end();
|
let showMessageAndEnd = () => this.end();
|
||||||
if (victoryMessages.length) {
|
if (victoryMessages?.length) {
|
||||||
let message: string;
|
let message: string;
|
||||||
this.scene.executeWithSeedOffset(() => message = Phaser.Math.RND.pick(victoryMessages), this.scene.currentBattle.waveIndex);
|
this.scene.executeWithSeedOffset(() => message = Phaser.Math.RND.pick(victoryMessages), this.scene.currentBattle.waveIndex);
|
||||||
const messagePages = message.split(/\$/g).map(m => m.trim());
|
const messagePages = message.split(/\$/g).map(m => m.trim());
|
||||||
|
|
|
@ -126,7 +126,7 @@ export default class Battle {
|
||||||
getBgmOverride(scene: BattleScene): string {
|
getBgmOverride(scene: BattleScene): string {
|
||||||
const battlers = this.enemyParty.slice(0, this.getBattlerCount());
|
const battlers = this.enemyParty.slice(0, this.getBattlerCount());
|
||||||
if (this.battleType === BattleType.TRAINER) {
|
if (this.battleType === BattleType.TRAINER) {
|
||||||
if (!this.started && this.trainer.config.encounterBgm && this.trainer.getEncounterMessages().length)
|
if (!this.started && this.trainer.config.encounterBgm && this.trainer.getEncounterMessages()?.length)
|
||||||
return `encounter_${this.trainer.getEncounterBgm()}`;
|
return `encounter_${this.trainer.getEncounterBgm()}`;
|
||||||
return this.trainer.getBattleBgm();
|
return this.trainer.getBattleBgm();
|
||||||
} else if (this.gameMode === GameMode.CLASSIC && this.waveIndex > 195 && this.battleSpec !== BattleSpec.FINAL_BOSS)
|
} else if (this.gameMode === GameMode.CLASSIC && this.waveIndex > 195 && this.battleSpec !== BattleSpec.FINAL_BOSS)
|
||||||
|
|
Loading…
Reference in New Issue