mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-25 00:39:27 +02:00
add isBattleMysteryEncounter() helper function
This commit is contained in:
parent
5ce9ab4855
commit
f49e487c0b
@ -3002,7 +3002,7 @@ export default class BattleScene extends SceneBase {
|
||||
if (participantIds.size > 0) {
|
||||
if (this.currentBattle.battleType === BattleType.TRAINER || this.currentBattle.mysteryEncounter?.encounterMode === MysteryEncounterMode.TRAINER_BATTLE) {
|
||||
expValue = Math.floor(expValue * 1.5);
|
||||
} else if (this.currentBattle.battleType === BattleType.MYSTERY_ENCOUNTER && this.currentBattle.mysteryEncounter) {
|
||||
} else if (this.currentBattle.isBattleMysteryEncounter() && this.currentBattle.mysteryEncounter) {
|
||||
expValue = Math.floor(expValue * this.currentBattle.mysteryEncounter.expMultiplier);
|
||||
}
|
||||
for (const partyMember of nonFaintedPartyMembers) {
|
||||
|
@ -213,7 +213,7 @@ export default class Battle {
|
||||
|
||||
getBgmOverride(scene: BattleScene): string | null {
|
||||
const battlers = this.enemyParty.slice(0, this.getBattlerCount());
|
||||
if (this.battleType === BattleType.MYSTERY_ENCOUNTER && this.mysteryEncounter?.encounterMode === MysteryEncounterMode.DEFAULT) {
|
||||
if (this.isBattleMysteryEncounter() && this.mysteryEncounter?.encounterMode === MysteryEncounterMode.DEFAULT) {
|
||||
// Music is overridden for MEs during ME onInit()
|
||||
// Should not use any BGM overrides before swapping from DEFAULT mode
|
||||
return null;
|
||||
@ -409,6 +409,10 @@ export default class Battle {
|
||||
scene.rngSeedOverride = tempSeedOverride;
|
||||
return ret;
|
||||
}
|
||||
|
||||
isBattleMysteryEncounter(): boolean {
|
||||
return this.isBattleMysteryEncounter();
|
||||
}
|
||||
}
|
||||
|
||||
export class FixedBattle extends Battle {
|
||||
|
@ -5290,7 +5290,7 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!player && user.scene.currentBattle.battleType === BattleType.MYSTERY_ENCOUNTER && !user.scene.currentBattle.mysteryEncounter?.fleeAllowed) {
|
||||
if (!player && user.scene.currentBattle.isBattleMysteryEncounter() && !user.scene.currentBattle.mysteryEncounter?.fleeAllowed) {
|
||||
// Don't allow wild opponents to be force switched during MEs with flee disabled
|
||||
return false;
|
||||
}
|
||||
|
@ -832,7 +832,7 @@ export function transitionMysteryEncounterIntroVisuals(scene: BattleScene, hide:
|
||||
*/
|
||||
export function handleMysteryEncounterBattleStartEffects(scene: BattleScene) {
|
||||
const encounter = scene.currentBattle.mysteryEncounter;
|
||||
if (scene.currentBattle.battleType === BattleType.MYSTERY_ENCOUNTER && encounter && encounter.encounterMode !== MysteryEncounterMode.NO_BATTLE && !encounter.startOfBattleEffectsComplete) {
|
||||
if (scene.currentBattle.isBattleMysteryEncounter() && encounter && encounter.encounterMode !== MysteryEncounterMode.NO_BATTLE && !encounter.startOfBattleEffectsComplete) {
|
||||
const effects = encounter.startOfBattleEffects;
|
||||
effects.forEach(effect => {
|
||||
let source;
|
||||
@ -871,7 +871,7 @@ export function handleMysteryEncounterBattleStartEffects(scene: BattleScene) {
|
||||
*/
|
||||
export function handleMysteryEncounterTurnStartEffects(scene: BattleScene): boolean {
|
||||
const encounter = scene.currentBattle.mysteryEncounter;
|
||||
if (scene.currentBattle.battleType === BattleType.MYSTERY_ENCOUNTER && encounter && encounter.onTurnStart) {
|
||||
if (scene.currentBattle.isBattleMysteryEncounter() && encounter && encounter.onTurnStart) {
|
||||
return encounter.onTurnStart(scene);
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ export class CommandPhase extends FieldPhase {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (this.scene.currentBattle.battleType === BattleType.MYSTERY_ENCOUNTER && this.scene.currentBattle.mysteryEncounter?.skipToFightInput) {
|
||||
if (this.scene.currentBattle.isBattleMysteryEncounter() && this.scene.currentBattle.mysteryEncounter?.skipToFightInput) {
|
||||
this.scene.ui.clearText();
|
||||
this.scene.ui.setMode(Mode.FIGHT, this.fieldIndex);
|
||||
} else {
|
||||
@ -141,7 +141,7 @@ export class CommandPhase extends FieldPhase {
|
||||
this.scene.ui.showText("", 0);
|
||||
this.scene.ui.setMode(Mode.COMMAND, this.fieldIndex);
|
||||
}, null, true);
|
||||
} else if (this.scene.currentBattle.battleType === BattleType.MYSTERY_ENCOUNTER && !this.scene.currentBattle.mysteryEncounter!.catchAllowed) {
|
||||
} else if (this.scene.currentBattle.isBattleMysteryEncounter() && !this.scene.currentBattle.mysteryEncounter!.catchAllowed) {
|
||||
this.scene.ui.setMode(Mode.COMMAND, this.fieldIndex);
|
||||
this.scene.ui.setMode(Mode.MESSAGE);
|
||||
this.scene.ui.showText(i18next.t("battle:noPokeballMysteryEncounter"), null, () => {
|
||||
|
@ -64,7 +64,7 @@ export class EncounterPhase extends BattlePhase {
|
||||
const battle = this.scene.currentBattle;
|
||||
|
||||
// Generate and Init Mystery Encounter
|
||||
if (battle.battleType === BattleType.MYSTERY_ENCOUNTER && !battle.mysteryEncounter) {
|
||||
if (battle.isBattleMysteryEncounter() && !battle.mysteryEncounter) {
|
||||
this.scene.executeWithSeedOffset(() => {
|
||||
const currentSessionEncounterType = battle.mysteryEncounterType;
|
||||
battle.mysteryEncounter = this.scene.getMysteryEncounter(currentSessionEncounterType);
|
||||
@ -95,7 +95,7 @@ export class EncounterPhase extends BattlePhase {
|
||||
let totalBst = 0;
|
||||
|
||||
battle.enemyLevels?.every((level, e) => {
|
||||
if (battle.battleType === BattleType.MYSTERY_ENCOUNTER) {
|
||||
if (battle.isBattleMysteryEncounter()) {
|
||||
// Skip enemy loading for MEs, those are loaded elsewhere
|
||||
return false;
|
||||
}
|
||||
@ -161,7 +161,7 @@ export class EncounterPhase extends BattlePhase {
|
||||
|
||||
if (battle.battleType === BattleType.TRAINER) {
|
||||
loadEnemyAssets.push(battle.trainer?.loadAssets().then(() => battle.trainer?.initSprite())!); // TODO: is this bang correct?
|
||||
} else if (battle.battleType === BattleType.MYSTERY_ENCOUNTER) {
|
||||
} else if (battle.isBattleMysteryEncounter()) {
|
||||
if (battle.mysteryEncounter?.introVisuals) {
|
||||
loadEnemyAssets.push(battle.mysteryEncounter.introVisuals.loadAssets().then(() => battle.mysteryEncounter!.introVisuals!.initSprite()));
|
||||
}
|
||||
@ -193,7 +193,7 @@ export class EncounterPhase extends BattlePhase {
|
||||
|
||||
Promise.all(loadEnemyAssets).then(() => {
|
||||
battle.enemyParty.every((enemyPokemon, e) => {
|
||||
if (battle.battleType === BattleType.MYSTERY_ENCOUNTER) {
|
||||
if (battle.isBattleMysteryEncounter()) {
|
||||
return false;
|
||||
}
|
||||
if (e < (battle.double ? 2 : 1)) {
|
||||
@ -367,7 +367,7 @@ export class EncounterPhase extends BattlePhase {
|
||||
showDialogueAndSummon();
|
||||
}
|
||||
}
|
||||
} else if (this.scene.currentBattle.battleType === BattleType.MYSTERY_ENCOUNTER && this.scene.currentBattle.mysteryEncounter) {
|
||||
} else if (this.scene.currentBattle.isBattleMysteryEncounter() && this.scene.currentBattle.mysteryEncounter) {
|
||||
const encounter = this.scene.currentBattle.mysteryEncounter;
|
||||
const introVisuals = encounter.introVisuals;
|
||||
introVisuals?.playAnim();
|
||||
|
@ -6,7 +6,6 @@ import { StatusEffect } from "#app/enums/status-effect";
|
||||
import { PokemonPhase } from "./pokemon-phase";
|
||||
import { MysteryEncounterPostSummonTag } from "#app/data/battler-tags";
|
||||
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||
import { BattleType } from "#app/battle";
|
||||
|
||||
export class PostSummonPhase extends PokemonPhase {
|
||||
constructor(scene: BattleScene, battlerIndex: BattlerIndex) {
|
||||
@ -24,7 +23,7 @@ export class PostSummonPhase extends PokemonPhase {
|
||||
this.scene.arena.applyTags(ArenaTrapTag, pokemon);
|
||||
|
||||
// If this is mystery encounter and has post summon phase tag, apply post summon effects
|
||||
if (this.scene.currentBattle.battleType === BattleType.MYSTERY_ENCOUNTER && pokemon.findTags(t => t instanceof MysteryEncounterPostSummonTag).length > 0) {
|
||||
if (this.scene.currentBattle.isBattleMysteryEncounter() && pokemon.findTags(t => t instanceof MysteryEncounterPostSummonTag).length > 0) {
|
||||
pokemon.lapseTag(BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON);
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ export class SummonPhase extends PartyMemberPokemonPhase {
|
||||
|
||||
this.scene.pbTrayEnemy.hide();
|
||||
this.scene.ui.showText(message, null, () => this.summon());
|
||||
} else if (this.scene.currentBattle.battleType === BattleType.MYSTERY_ENCOUNTER) {
|
||||
} else if (this.scene.currentBattle.isBattleMysteryEncounter()) {
|
||||
this.scene.pbTrayEnemy.hide();
|
||||
this.summonWild();
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ export class VictoryPhase extends PokemonPhase {
|
||||
const expValue = this.getPokemon().getExpValue();
|
||||
this.scene.applyPartyExp(expValue, true);
|
||||
|
||||
if (this.scene.currentBattle.battleType === BattleType.MYSTERY_ENCOUNTER) {
|
||||
if (this.scene.currentBattle.isBattleMysteryEncounter()) {
|
||||
handleMysteryEncounterVictory(this.scene, false, this.isExpOnly);
|
||||
return this.end();
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ class RunEntryContainer extends Phaser.GameObjects.Container {
|
||||
const genderIndex = this.scene.gameData.gender ?? PlayerGender.UNSET;
|
||||
const genderStr = PlayerGender[genderIndex].toLowerCase();
|
||||
// Defeats from wild Pokemon battles will show the Pokemon responsible by the text of the run result.
|
||||
if (data.battleType === BattleType.WILD || (data.battleType === BattleType.MYSTERY_ENCOUNTER && !data.trainer)) {
|
||||
if (data.battleType === BattleType.WILD || (data.isBattleMysteryEncounter() && !data.trainer)) {
|
||||
const enemyContainer = this.scene.add.container(8, 5);
|
||||
const gameOutcomeLabel = addTextObject(this.scene, 0, 0, `${i18next.t("runHistory:defeatedWild", { context: genderStr })}`, TextStyle.WINDOW);
|
||||
enemyContainer.add(gameOutcomeLabel);
|
||||
@ -311,7 +311,7 @@ class RunEntryContainer extends Phaser.GameObjects.Container {
|
||||
enemy.destroy();
|
||||
});
|
||||
this.add(enemyContainer);
|
||||
} else if (data.battleType === BattleType.TRAINER || (data.battleType === BattleType.MYSTERY_ENCOUNTER && data.trainer)) { // Defeats from Trainers show the trainer's title and name
|
||||
} else if (data.battleType === BattleType.TRAINER || (data.isBattleMysteryEncounter() && data.trainer)) { // Defeats from Trainers show the trainer's title and name
|
||||
const tObj = data.trainer.toTrainer(this.scene);
|
||||
// Because of the interesting mechanics behind rival names, the rival name and title have to be retrieved differently
|
||||
const RIVAL_TRAINER_ID_THRESHOLD = 375;
|
||||
|
@ -207,7 +207,7 @@ export default class RunInfoUiHandler extends UiHandler {
|
||||
if (!this.isVictory) {
|
||||
const enemyContainer = this.scene.add.container(0, 0);
|
||||
// Wild - Single and Doubles
|
||||
if (this.runInfo.battleType === BattleType.WILD || (this.runInfo.battleType === BattleType.MYSTERY_ENCOUNTER && !this.runInfo.trainer)) {
|
||||
if (this.runInfo.battleType === BattleType.WILD || (this.runInfo.isBattleMysteryEncounter() && !this.runInfo.trainer)) {
|
||||
switch (this.runInfo.enemyParty.length) {
|
||||
case 1:
|
||||
// Wild - Singles
|
||||
@ -218,7 +218,7 @@ export default class RunInfoUiHandler extends UiHandler {
|
||||
this.parseWildDoubleDefeat(enemyContainer);
|
||||
break;
|
||||
}
|
||||
} else if (this.runInfo.battleType === BattleType.TRAINER || (this.runInfo.battleType === BattleType.MYSTERY_ENCOUNTER && this.runInfo.trainer)) {
|
||||
} else if (this.runInfo.battleType === BattleType.TRAINER || (this.runInfo.isBattleMysteryEncounter() && this.runInfo.trainer)) {
|
||||
this.parseTrainerDefeat(enemyContainer);
|
||||
}
|
||||
this.runResultContainer.add(enemyContainer);
|
||||
|
Loading…
Reference in New Issue
Block a user