added playerFaints to SessionSaveData to make the counter saveable

This commit is contained in:
geeil-han 2025-02-07 23:11:07 +01:00
parent 01b4d10b06
commit e50c9564b7
8 changed files with 38 additions and 20 deletions

View File

@ -1336,14 +1336,15 @@ export default class BattleScene extends SceneBase {
} }
this.executeWithSeedOffset(() => { this.executeWithSeedOffset(() => {
this.currentBattle = new Battle(this.gameMode, newWaveIndex, newBattleType, newTrainer, newDouble, this.currentBattle?.playerFaints, this.currentBattle?.enemyFaints); this.currentBattle = new Battle(this.gameMode, newWaveIndex, newBattleType, newTrainer, newDouble, this.currentBattle?.enemyFaints);
}, newWaveIndex << 3, this.waveSeed); }, newWaveIndex << 3, this.waveSeed);
this.currentBattle.incrementTurn(); this.currentBattle.incrementTurn();
if (newBattleType === BattleType.MYSTERY_ENCOUNTER) { if (newBattleType === BattleType.MYSTERY_ENCOUNTER) {
// Will generate the actual Mystery Encounter during NextEncounterPhase, to ensure it uses proper biome // Will generate the actual Mystery Encounter during NextEncounterPhase, to ensure it uses proper biome
this.currentBattle.mysteryEncounterType = mysteryEncounterType; this.currentBattle.mysteryEncounterType = mysteryEncounterType;
this.resetFaintsCount(); this.resetEnemyFaintCount();
this.arena.resetPlayerFaintCount();
} }
//this.pushPhase(new TrainerMessageTestPhase(this, TrainerType.RIVAL, TrainerType.RIVAL_2, TrainerType.RIVAL_3, TrainerType.RIVAL_4, TrainerType.RIVAL_5, TrainerType.RIVAL_6)); //this.pushPhase(new TrainerMessageTestPhase(this, TrainerType.RIVAL, TrainerType.RIVAL_2, TrainerType.RIVAL_3, TrainerType.RIVAL_4, TrainerType.RIVAL_5, TrainerType.RIVAL_6));
@ -1361,7 +1362,8 @@ export default class BattleScene extends SceneBase {
this.arena.updatePoolsForTimeOfDay(); this.arena.updatePoolsForTimeOfDay();
} }
if (resetArenaState) { if (resetArenaState) {
this.resetFaintsCount(); this.resetEnemyFaintCount();
this.arena.resetPlayerFaintCount();
this.arena.resetArenaEffects(); this.arena.resetArenaEffects();
@ -1403,8 +1405,8 @@ export default class BattleScene extends SceneBase {
return this.currentBattle; return this.currentBattle;
} }
newArena(biome: Biome): Arena { newArena(biome: Biome, playerFaints?: number): Arena {
this.arena = new Arena(biome, Biome[biome].toLowerCase()); this.arena = new Arena(biome, Biome[biome].toLowerCase(), playerFaints);
this.eventTarget.dispatchEvent(new NewArenaEvent()); this.eventTarget.dispatchEvent(new NewArenaEvent());
this.arenaBg.pipelineData = { terrainColorRatio: this.arena.getBgTerrainColorRatioForBiome() }; this.arenaBg.pipelineData = { terrainColorRatio: this.arena.getBgTerrainColorRatioForBiome() };
@ -1413,10 +1415,9 @@ export default class BattleScene extends SceneBase {
} }
/** /**
* resets player/enemyFaints count on {@linkcode currentBattle} * resets enemyFaints count on {@linkcode currentBattle}.
*/ */
resetFaintsCount(): void { resetEnemyFaintCount(): void {
this.currentBattle.playerFaints = 0;
this.currentBattle.enemyFaints = 0; this.currentBattle.enemyFaints = 0;
} }

View File

@ -102,9 +102,11 @@ export default class Battle {
private battleSeedState: string | null = null; private battleSeedState: string | null = null;
public moneyScattered: number = 0; public moneyScattered: number = 0;
public lastUsedPokeball: PokeballType | null = null; public lastUsedPokeball: PokeballType | null = null;
/** The number of times a Pokemon on the player's side has fainted this arena encounter */ /**
public playerFaints: number = 0; * Saves the number of times a Pokemon on the enemy's side has fainted during this battle.
/** The number of times a Pokemon on the enemy's side has fainted this arena encounter */ * This is saved here since we encounter a new enemy every wave.
* {@linkcode globalScene.arena.playerFaints} is the corresponding faint counter for the player and needs to be save across waves (reset every arena encounter).
*/
public enemyFaints: number = 0; public enemyFaints: number = 0;
public playerFaintsHistory: FaintLogEntry[] = []; public playerFaintsHistory: FaintLogEntry[] = [];
public enemyFaintsHistory: FaintLogEntry[] = []; public enemyFaintsHistory: FaintLogEntry[] = [];
@ -115,7 +117,7 @@ export default class Battle {
private rngCounter: number = 0; private rngCounter: number = 0;
constructor(gameMode: GameMode, waveIndex: number, battleType: BattleType, trainer?: Trainer, double?: boolean, playerFaints?: number, enemyFaints?: number) { constructor(gameMode: GameMode, waveIndex: number, battleType: BattleType, trainer?: Trainer, double?: boolean, enemyFaints?: number) {
this.gameMode = gameMode; this.gameMode = gameMode;
this.waveIndex = waveIndex; this.waveIndex = waveIndex;
this.battleType = battleType; this.battleType = battleType;
@ -125,7 +127,6 @@ export default class Battle {
? new Array(double ? 2 : 1).fill(null).map(() => this.getLevelForWave()) ? new Array(double ? 2 : 1).fill(null).map(() => this.getLevelForWave())
: trainer?.getPartyLevels(this.waveIndex); : trainer?.getPartyLevels(this.waveIndex);
this.double = double ?? false; this.double = double ?? false;
this.playerFaints = playerFaints ?? 0;
this.enemyFaints = enemyFaints ?? 0; this.enemyFaints = enemyFaints ?? 0;
} }

View File

@ -6275,7 +6275,7 @@ export function initAbilities() {
new Ability(Abilities.SHARPNESS, 9) new Ability(Abilities.SHARPNESS, 9)
.attr(MovePowerBoostAbAttr, (user, target, move) => move.hasFlag(MoveFlags.SLICING_MOVE), 1.5), .attr(MovePowerBoostAbAttr, (user, target, move) => move.hasFlag(MoveFlags.SLICING_MOVE), 1.5),
new Ability(Abilities.SUPREME_OVERLORD, 9) new Ability(Abilities.SUPREME_OVERLORD, 9)
.attr(VariableMovePowerBoostAbAttr, (user, target, move) => 1 + 0.1 * Math.min(user.isPlayer() ? globalScene.currentBattle.playerFaints : globalScene.currentBattle.enemyFaints, 5)), .attr(VariableMovePowerBoostAbAttr, (user, target, move) => 1 + 0.1 * Math.min(user.isPlayer() ? globalScene.arena.playerFaints : globalScene.currentBattle.enemyFaints, 5)),
new Ability(Abilities.COSTAR, 9) new Ability(Abilities.COSTAR, 9)
.attr(PostSummonCopyAllyStatsAbAttr), .attr(PostSummonCopyAllyStatsAbAttr),
new Ability(Abilities.TOXIC_DEBRIS, 9) new Ability(Abilities.TOXIC_DEBRIS, 9)

View File

@ -10917,7 +10917,7 @@ export function initMoves() {
.attr(ConfuseAttr) .attr(ConfuseAttr)
.recklessMove(), .recklessMove(),
new AttackMove(Moves.LAST_RESPECTS, Type.GHOST, MoveCategory.PHYSICAL, 50, 100, 10, -1, 0, 9) new AttackMove(Moves.LAST_RESPECTS, Type.GHOST, MoveCategory.PHYSICAL, 50, 100, 10, -1, 0, 9)
.attr(MovePowerMultiplierAttr, (user, target, move) => 1 + Math.min(user.isPlayer() ? globalScene.currentBattle.playerFaints : globalScene.currentBattle.enemyFaints, 100)) .attr(MovePowerMultiplierAttr, (user, target, move) => 1 + Math.min(user.isPlayer() ? globalScene.arena.playerFaints : globalScene.currentBattle.enemyFaints, 100))
.makesContact(false), .makesContact(false),
new AttackMove(Moves.LUMINA_CRASH, Type.PSYCHIC, MoveCategory.SPECIAL, 80, 100, 10, 100, 0, 9) new AttackMove(Moves.LUMINA_CRASH, Type.PSYCHIC, MoveCategory.SPECIAL, 80, 100, 10, 100, 0, 9)
.attr(StatStageChangeAttr, [ Stat.SPDEF ], -2), .attr(StatStageChangeAttr, [ Stat.SPDEF ], -2),

View File

@ -44,6 +44,11 @@ export class Arena {
public bgm: string; public bgm: string;
public ignoreAbilities: boolean; public ignoreAbilities: boolean;
public ignoringEffectSource: BattlerIndex | null; public ignoringEffectSource: BattlerIndex | null;
/**
* Saves the number of times a party pokemon faints during a arena encounter.
* {@linkcode globalScene.currentBattle.enemyFaints} is the corresponding faint counter for the enemy (this resets every wave).
*/
public playerFaints: number;
private lastTimeOfDay: TimeOfDay; private lastTimeOfDay: TimeOfDay;
@ -52,12 +57,13 @@ export class Arena {
public readonly eventTarget: EventTarget = new EventTarget(); public readonly eventTarget: EventTarget = new EventTarget();
constructor(biome: Biome, bgm: string) { constructor(biome: Biome, bgm: string, playerFaints?: number) {
this.biomeType = biome; this.biomeType = biome;
this.tags = []; this.tags = [];
this.bgm = bgm; this.bgm = bgm;
this.trainerPool = biomeTrainerPools[biome]; this.trainerPool = biomeTrainerPools[biome];
this.updatePoolsForTimeOfDay(); this.updatePoolsForTimeOfDay();
this.playerFaints = playerFaints ?? 0;
} }
init() { init() {
@ -771,6 +777,10 @@ export class Arena {
return 0; return 0;
} }
} }
resetPlayerFaintCount(): void {
this.playerFaints = 0;
}
} }
export function getBiomeKey(biome: Biome): string { export function getBiomeKey(biome: Biome): string {

View File

@ -98,7 +98,7 @@ export class FaintPhase extends PokemonPhase {
// Track total times pokemon have been KO'd for Last Respects/Supreme Overlord // Track total times pokemon have been KO'd for Last Respects/Supreme Overlord
if (pokemon.isPlayer()) { if (pokemon.isPlayer()) {
globalScene.currentBattle.playerFaints += 1; globalScene.arena.playerFaints += 1;
globalScene.currentBattle.playerFaintsHistory.push({ pokemon: pokemon, turn: globalScene.currentBattle.turn }); globalScene.currentBattle.playerFaintsHistory.push({ pokemon: pokemon, turn: globalScene.currentBattle.turn });
} else { } else {
globalScene.currentBattle.enemyFaints += 1; globalScene.currentBattle.enemyFaints += 1;

View File

@ -249,7 +249,8 @@ export class GameOverPhase extends BattlePhase {
timestamp: new Date().getTime(), timestamp: new Date().getTime(),
challenges: globalScene.gameMode.challenges.map(c => new ChallengeData(c)), challenges: globalScene.gameMode.challenges.map(c => new ChallengeData(c)),
mysteryEncounterType: globalScene.currentBattle.mysteryEncounter?.encounterType ?? -1, mysteryEncounterType: globalScene.currentBattle.mysteryEncounter?.encounterType ?? -1,
mysteryEncounterSaveData: globalScene.mysteryEncounterSaveData mysteryEncounterSaveData: globalScene.mysteryEncounterSaveData,
playerFaints: globalScene.arena.playerFaints
} as SessionSaveData; } as SessionSaveData;
} }
} }

View File

@ -141,6 +141,10 @@ export interface SessionSaveData {
challenges: ChallengeData[]; challenges: ChallengeData[];
mysteryEncounterType: MysteryEncounterType | -1; // Only defined when current wave is ME, mysteryEncounterType: MysteryEncounterType | -1; // Only defined when current wave is ME,
mysteryEncounterSaveData: MysteryEncounterSaveData; mysteryEncounterSaveData: MysteryEncounterSaveData;
/**
* Counts the amount of pokemon fainted in your party during the current arena encounter.
*/
playerFaints: number;
} }
interface Unlocks { interface Unlocks {
@ -964,7 +968,8 @@ export class GameData {
timestamp: new Date().getTime(), timestamp: new Date().getTime(),
challenges: globalScene.gameMode.challenges.map(c => new ChallengeData(c)), challenges: globalScene.gameMode.challenges.map(c => new ChallengeData(c)),
mysteryEncounterType: globalScene.currentBattle.mysteryEncounter?.encounterType ?? -1, mysteryEncounterType: globalScene.currentBattle.mysteryEncounter?.encounterType ?? -1,
mysteryEncounterSaveData: globalScene.mysteryEncounterSaveData mysteryEncounterSaveData: globalScene.mysteryEncounterSaveData,
playerFaints: globalScene.arena.playerFaints
} as SessionSaveData; } as SessionSaveData;
} }
@ -1056,7 +1061,7 @@ export class GameData {
globalScene.mysteryEncounterSaveData = new MysteryEncounterSaveData(sessionData.mysteryEncounterSaveData); globalScene.mysteryEncounterSaveData = new MysteryEncounterSaveData(sessionData.mysteryEncounterSaveData);
globalScene.newArena(sessionData.arena.biome); globalScene.newArena(sessionData.arena.biome, sessionData.playerFaints);
const battleType = sessionData.battleType || 0; const battleType = sessionData.battleType || 0;
const trainerConfig = sessionData.trainer ? trainerConfigs[sessionData.trainer.trainerType] : null; const trainerConfig = sessionData.trainer ? trainerConfigs[sessionData.trainer.trainerType] : null;