From 3ec8f236f92b022e370eedcc6b695c057c6d7ac2 Mon Sep 17 00:00:00 2001 From: AJ Fontaine <36677462+Fontbane@users.noreply.github.com> Date: Mon, 14 Apr 2025 20:13:05 -0400 Subject: [PATCH] [Refactor] Change how rival event rewards are generated (#5638) * Change how rival event rewards are generated * Simplify to switch case Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> --- src/data/trainers/trainer-config.ts | 13 ------------- src/phases/trainer-victory-phase.ts | 6 ------ src/phases/victory-phase.ts | 21 +++++++++++++++------ 3 files changed, 15 insertions(+), 25 deletions(-) diff --git a/src/data/trainers/trainer-config.ts b/src/data/trainers/trainer-config.ts index 0ab7119dab9..4efe294f7d0 100644 --- a/src/data/trainers/trainer-config.ts +++ b/src/data/trainers/trainer-config.ts @@ -116,7 +116,6 @@ export class TrainerConfig { public modifierRewardFuncs: ModifierTypeFunc[] = []; public partyTemplates: TrainerPartyTemplate[]; public partyTemplateFunc: PartyTemplateFunc; - public eventRewardFuncs: ModifierTypeFunc[] = []; public partyMemberFuncs: PartyMemberFuncs = {}; public speciesPools: TrainerTierPools; public speciesFilter: PokemonSpeciesFilter; @@ -517,16 +516,6 @@ export class TrainerConfig { // return ret; // } - /** - * Sets eventRewardFuncs to the active event rewards for the specified wave - * @param wave Associated with {@linkcode getFixedBattleEventRewards} - * @returns this - */ - setEventModifierRewardFuncs(wave: number): TrainerConfig { - this.eventRewardFuncs = timedEventManager.getFixedBattleEventRewards(wave).map(r => modifierTypes[r]); - return this; - } - setModifierRewardFuncs(...modifierTypeFuncs: (() => ModifierTypeFunc)[]): TrainerConfig { this.modifierRewardFuncs = modifierTypeFuncs.map(func => () => { const modifierTypeFunc = func(); @@ -3692,7 +3681,6 @@ export const trainerConfigs: TrainerConfigs = { () => modifierTypes.SUPER_EXP_CHARM, () => modifierTypes.EXP_SHARE, ) - .setEventModifierRewardFuncs(8) .setPartyMemberFunc( 0, getRandomPartyMemberFunc( @@ -3760,7 +3748,6 @@ export const trainerConfigs: TrainerConfigs = { .setMixedBattleBgm("battle_rival") .setPartyTemplates(trainerPartyTemplates.RIVAL_2) .setModifierRewardFuncs(() => modifierTypes.EXP_SHARE) - .setEventModifierRewardFuncs(25) .setPartyMemberFunc( 0, getRandomPartyMemberFunc( diff --git a/src/phases/trainer-victory-phase.ts b/src/phases/trainer-victory-phase.ts index 637ddea8b56..f17071f118e 100644 --- a/src/phases/trainer-victory-phase.ts +++ b/src/phases/trainer-victory-phase.ts @@ -26,12 +26,6 @@ export class TrainerVictoryPhase extends BattlePhase { globalScene.unshiftPhase(new ModifierRewardPhase(modifierRewardFunc)); } - if (timedEventManager.isEventActive()) { - for (const rewardFunc of globalScene.currentBattle.trainer?.config.eventRewardFuncs!) { - globalScene.unshiftPhase(new ModifierRewardPhase(rewardFunc)); - } - } - const trainerType = globalScene.currentBattle.trainer?.config.trainerType!; // TODO: is this bang correct? // Validate Voucher for boss trainers if (vouchers.hasOwnProperty(TrainerType[trainerType])) { diff --git a/src/phases/victory-phase.ts b/src/phases/victory-phase.ts index 78bf72195e8..9f4412fe270 100644 --- a/src/phases/victory-phase.ts +++ b/src/phases/victory-phase.ts @@ -13,6 +13,7 @@ import { SelectModifierPhase } from "./select-modifier-phase"; import { TrainerVictoryPhase } from "./trainer-victory-phase"; import { handleMysteryEncounterVictory } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import { globalScene } from "#app/global-scene"; +import { timedEventManager } from "#app/global-event-manager"; export class VictoryPhase extends PokemonPhase { /** If true, indicates that the phase is intended for EXP purposes only, and not to continue a battle to next phase */ @@ -53,12 +54,20 @@ export class VictoryPhase extends PokemonPhase { } if (globalScene.gameMode.isEndless || !globalScene.gameMode.isWaveFinal(globalScene.currentBattle.waveIndex)) { globalScene.pushPhase(new EggLapsePhase()); - if ( - globalScene.gameMode.isClassic && - globalScene.currentBattle.waveIndex === ClassicFixedBossWaves.EVIL_BOSS_2 - ) { - // Should get Lock Capsule on 165 before shop phase so it can be used in the rewards shop - globalScene.pushPhase(new ModifierRewardPhase(modifierTypes.LOCK_CAPSULE)); + if (globalScene.gameMode.isClassic) { + switch (globalScene.currentBattle.waveIndex) { + case ClassicFixedBossWaves.RIVAL_1: + case ClassicFixedBossWaves.RIVAL_2: + // Get event modifiers for this wave + timedEventManager + .getFixedBattleEventRewards(globalScene.currentBattle.waveIndex) + .map(r => globalScene.pushPhase(new ModifierRewardPhase(modifierTypes[r]))); + break; + case ClassicFixedBossWaves.EVIL_BOSS_2: + // Should get Lock Capsule on 165 before shop phase so it can be used in the rewards shop + globalScene.pushPhase(new ModifierRewardPhase(modifierTypes.LOCK_CAPSULE)); + break; + } } if (globalScene.currentBattle.waveIndex % 10) { globalScene.pushPhase(new SelectModifierPhase(undefined, undefined, this.getFixedBattleCustomModifiers()));