mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-02-06 08:07:42 +00:00
a98ec39d00
* Adds special item rewards to fixed classic/challenge battles * remove unintentional overrides changes * remove redundant variable * remove Lock Capsule from Classic item pool * swapped Lock Capsule and Super EXP Charm mistake * address nits and small enhancement to eliminate magic numbers --------- Co-authored-by: ImperialSympathizer <imperialsympathizer@gmail.com> Co-authored-by: damocleas <damocleas25@gmail.com> Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com>
98 lines
5.0 KiB
TypeScript
98 lines
5.0 KiB
TypeScript
import BattleScene from "#app/battle-scene";
|
|
import { BattlerIndex, BattleType, ClassicFixedBossWaves } from "#app/battle";
|
|
import { CustomModifierSettings, modifierTypes } from "#app/modifier/modifier-type";
|
|
import { BattleEndPhase } from "./battle-end-phase";
|
|
import { NewBattlePhase } from "./new-battle-phase";
|
|
import { PokemonPhase } from "./pokemon-phase";
|
|
import { AddEnemyBuffModifierPhase } from "./add-enemy-buff-modifier-phase";
|
|
import { EggLapsePhase } from "./egg-lapse-phase";
|
|
import { GameOverPhase } from "./game-over-phase";
|
|
import { ModifierRewardPhase } from "./modifier-reward-phase";
|
|
import { SelectModifierPhase } from "./select-modifier-phase";
|
|
import { TrainerVictoryPhase } from "./trainer-victory-phase";
|
|
import { handleMysteryEncounterVictory } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
|
|
|
|
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 */
|
|
isExpOnly: boolean;
|
|
|
|
constructor(scene: BattleScene, battlerIndex: BattlerIndex | integer, isExpOnly: boolean = false) {
|
|
super(scene, battlerIndex);
|
|
|
|
this.isExpOnly = isExpOnly;
|
|
}
|
|
|
|
start() {
|
|
super.start();
|
|
|
|
this.scene.gameData.gameStats.pokemonDefeated++;
|
|
|
|
const expValue = this.getPokemon().getExpValue();
|
|
this.scene.applyPartyExp(expValue, true);
|
|
|
|
if (this.scene.currentBattle.battleType === BattleType.MYSTERY_ENCOUNTER) {
|
|
handleMysteryEncounterVictory(this.scene, false, this.isExpOnly);
|
|
return this.end();
|
|
}
|
|
|
|
if (!this.scene.getEnemyParty().find(p => this.scene.currentBattle.battleType === BattleType.WILD ? p.isOnField() : !p?.isFainted(true))) {
|
|
this.scene.pushPhase(new BattleEndPhase(this.scene));
|
|
if (this.scene.currentBattle.battleType === BattleType.TRAINER) {
|
|
this.scene.pushPhase(new TrainerVictoryPhase(this.scene));
|
|
}
|
|
if (this.scene.gameMode.isEndless || !this.scene.gameMode.isWaveFinal(this.scene.currentBattle.waveIndex)) {
|
|
this.scene.pushPhase(new EggLapsePhase(this.scene));
|
|
if (this.scene.gameMode.isClassic && this.scene.currentBattle.waveIndex === ClassicFixedBossWaves.EVIL_BOSS_2) {
|
|
// Should get Lock Capsule on 165 before shop phase so it can be used in the rewards shop
|
|
this.scene.pushPhase(new ModifierRewardPhase(this.scene, modifierTypes.LOCK_CAPSULE));
|
|
}
|
|
if (this.scene.currentBattle.waveIndex % 10) {
|
|
this.scene.pushPhase(new SelectModifierPhase(this.scene, undefined, undefined, this.getFixedBattleCustomModifiers()));
|
|
} else if (this.scene.gameMode.isDaily) {
|
|
this.scene.pushPhase(new ModifierRewardPhase(this.scene, modifierTypes.EXP_CHARM));
|
|
if (this.scene.currentBattle.waveIndex > 10 && !this.scene.gameMode.isWaveFinal(this.scene.currentBattle.waveIndex)) {
|
|
this.scene.pushPhase(new ModifierRewardPhase(this.scene, modifierTypes.GOLDEN_POKEBALL));
|
|
}
|
|
} else {
|
|
const superExpWave = !this.scene.gameMode.isEndless ? (this.scene.offsetGym ? 0 : 20) : 10;
|
|
if (this.scene.gameMode.isEndless && this.scene.currentBattle.waveIndex === 10) {
|
|
this.scene.pushPhase(new ModifierRewardPhase(this.scene, modifierTypes.EXP_SHARE));
|
|
}
|
|
if (this.scene.currentBattle.waveIndex <= 750 && (this.scene.currentBattle.waveIndex <= 500 || (this.scene.currentBattle.waveIndex % 30) === superExpWave)) {
|
|
this.scene.pushPhase(new ModifierRewardPhase(this.scene, (this.scene.currentBattle.waveIndex % 30) !== superExpWave || this.scene.currentBattle.waveIndex > 250 ? modifierTypes.EXP_CHARM : modifierTypes.SUPER_EXP_CHARM));
|
|
}
|
|
if (this.scene.currentBattle.waveIndex <= 150 && !(this.scene.currentBattle.waveIndex % 50)) {
|
|
this.scene.pushPhase(new ModifierRewardPhase(this.scene, modifierTypes.GOLDEN_POKEBALL));
|
|
}
|
|
if (this.scene.gameMode.isEndless && !(this.scene.currentBattle.waveIndex % 50)) {
|
|
this.scene.pushPhase(new ModifierRewardPhase(this.scene, !(this.scene.currentBattle.waveIndex % 250) ? modifierTypes.VOUCHER_PREMIUM : modifierTypes.VOUCHER_PLUS));
|
|
this.scene.pushPhase(new AddEnemyBuffModifierPhase(this.scene));
|
|
}
|
|
}
|
|
this.scene.pushPhase(new NewBattlePhase(this.scene));
|
|
} else {
|
|
this.scene.currentBattle.battleType = BattleType.CLEAR;
|
|
this.scene.score += this.scene.gameMode.getClearScoreBonus();
|
|
this.scene.updateScoreText();
|
|
this.scene.pushPhase(new GameOverPhase(this.scene, true));
|
|
}
|
|
}
|
|
|
|
this.end();
|
|
}
|
|
|
|
/**
|
|
* If this wave is a fixed battle with special custom modifier rewards,
|
|
* will pass those settings to the upcoming {@linkcode SelectModifierPhase}`.
|
|
*/
|
|
getFixedBattleCustomModifiers(): CustomModifierSettings | undefined {
|
|
const gameMode = this.scene.gameMode;
|
|
const waveIndex = this.scene.currentBattle.waveIndex;
|
|
if (gameMode.isFixedBattle(waveIndex)) {
|
|
return gameMode.getFixedBattle(waveIndex).customModifierRewardSettings;
|
|
}
|
|
|
|
return undefined;
|
|
}
|
|
}
|