[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>
This commit is contained in:
AJ Fontaine 2025-04-14 20:13:05 -04:00 committed by GitHub
parent 8216a379bf
commit 3ec8f236f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 25 deletions

View File

@ -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(

View File

@ -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])) {

View File

@ -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()));