Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Moved code preventing MBH's transfer to post modifier generation #4858

Open
wants to merge 8 commits into
base: beta
Choose a base branch
from
39 changes: 36 additions & 3 deletions src/battle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import BattleScene from "./battle-scene";
import { Command } from "./ui/command-ui-handler";
import * as Utils from "./utils";
import Trainer, { TrainerVariant } from "./field/trainer";
import { GameMode } from "./game-mode";
import { GameMode, GameModes } from "./game-mode";
import { MoneyMultiplierModifier, PokemonHeldItemModifier } from "./modifier/modifier";
import { PokeballType } from "#enums/pokeball";
import { trainerConfigs } from "#app/data/trainer-config";
Expand All @@ -28,6 +28,13 @@ export enum ClassicFixedBossWaves {
EVIL_BOSS_2 = 165,
}

export enum EndlessBossType {
STANDARD = 50,
ETERNATUS = 250,
ETERNAMAX = 1000,
NONE
}

export enum BattleType {
WILD,
TRAINER,
Expand Down Expand Up @@ -438,6 +445,32 @@ export default class Battle {
isBattleMysteryEncounter(): boolean {
return this.battleType === BattleType.MYSTERY_ENCOUNTER;
}

/**
* @returns `true` if the current battle is against classic mode's final boss
*/
isBattleClassicFinalBoss(): boolean {
frutescens marked this conversation as resolved.
Show resolved Hide resolved
return (this.gameMode.modeId === GameModes.CLASSIC || this.gameMode.modeId === GameModes.CHALLENGE) && this.waveIndex === 200;
}

/**
* Uses modulos to determine what type of boss is faced by the player in Endless mode.
* @returns the type of Endless boss faced by the player {@linkcode EndlessBossType}
*/
getEndlessBossType(): EndlessBossType {
if (this.gameMode.modeId !== GameModes.ENDLESS && this.gameMode.modeId !== GameModes.SPLICED_ENDLESS) {
return EndlessBossType.NONE;
} else {
if (!(this.waveIndex % EndlessBossType.ETERNAMAX)) {
return EndlessBossType.ETERNAMAX;
} else if (!(this.waveIndex % EndlessBossType.ETERNATUS)) {
return EndlessBossType.ETERNATUS;
} else if (!(this.waveIndex % EndlessBossType.STANDARD)) {
return EndlessBossType.STANDARD;
}
return EndlessBossType.NONE;
}
}
}

export class FixedBattle extends Battle {
Expand Down Expand Up @@ -499,7 +532,7 @@ export class FixedBattleConfig {
* @param seedOffset the seed offset to use for the random generation of the trainer
* @returns the generated trainer
*/
function getRandomTrainerFunc(trainerPool: (TrainerType | TrainerType[])[], randomGender: boolean = false, seedOffset: number = 0): GetTrainerFunc {
function getRandomTrainerFunc(trainerPool: (TrainerType | TrainerType[])[], randomGender: boolean = false, seedOffset: number = 0): GetTrainerFunc {
return (scene: BattleScene) => {
const rand = Utils.randSeedInt(trainerPool.length);
const trainerTypes: TrainerType[] = [];
Expand Down Expand Up @@ -531,7 +564,7 @@ function getRandomTrainerFunc(trainerPool: (TrainerType | TrainerType[])[], rand
}

export interface FixedBattleConfigs {
[key: number]: FixedBattleConfig
[key: number]: FixedBattleConfig
}
/**
* Youngster/Lass on 5
Expand Down
4 changes: 2 additions & 2 deletions src/phases/encounter-phase.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BattlerIndex, BattleType } from "#app/battle";
import { BattlerIndex, BattleType, EndlessBossType } from "#app/battle";
import BattleScene from "#app/battle-scene";
import { PLAYER_PARTY_MAX_SIZE } from "#app/constants";
import { applyAbAttrs, SyncEncounterNatureAbAttr } from "#app/data/ability";
Expand Down Expand Up @@ -217,7 +217,7 @@ export class EncounterPhase extends BattlePhase {
regenerateModifierPoolThresholds(this.scene.getEnemyField(), battle.battleType === BattleType.TRAINER ? ModifierPoolType.TRAINER : ModifierPoolType.WILD);
this.scene.generateEnemyModifiers();
// This checks if the current battle is an Endless E-Max battle/Classic final boss and sets the MBH held by the boss to untransferrable
if (this.scene.currentBattle.waveIndex % 1000 || battle.battleSpec === BattleSpec.FINAL_BOSS) {
if (this.scene.currentBattle.getEndlessBossType() === EndlessBossType.ETERNAMAX || battle.isBattleClassicFinalBoss()) {
const enemyPokemon = this.scene.getEnemyPokemon();
if (enemyPokemon) {
const bossMBH = this.scene.findModifier(m => m instanceof TurnHeldItemTransferModifier && m.pokemonId === enemyPokemon.id, false) as TurnHeldItemTransferModifier;
Expand Down
Loading