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