Add player faints to Arena Data

This commit is contained in:
AJ Fontaine 2025-08-17 21:41:39 -04:00
parent 2ff9bd4652
commit f80574a1a0
5 changed files with 9 additions and 17 deletions

View File

@ -1508,8 +1508,8 @@ export class BattleScene extends SceneBase {
return this.currentBattle;
}
newArena(biome: BiomeId, playerFaints = 0): Arena {
this.arena = new Arena(biome, playerFaints);
newArena(biome: BiomeId): Arena {
this.arena = new Arena(biome);
this.eventTarget.dispatchEvent(new NewArenaEvent());
this.arenaBg.pipelineData = {

View File

@ -59,7 +59,7 @@ export class Arena {
* 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;
public playerFaints = 0;
private lastTimeOfDay: TimeOfDay;
@ -68,12 +68,11 @@ export class Arena {
public readonly eventTarget: EventTarget = new EventTarget();
constructor(biome: BiomeId, playerFaints = 0) {
constructor(biome: BiomeId) {
this.biomeType = biome;
this.bgm = BiomeId[biome].toLowerCase();
this.trainerPool = biomeTrainerPools[biome];
this.updatePoolsForTimeOfDay();
this.playerFaints = playerFaints;
}
init() {
@ -854,7 +853,6 @@ export class Arena {
this.trySetWeather(WeatherType.NONE);
}
this.trySetTerrain(TerrainType.NONE, true);
this.resetPlayerFaintCount();
this.removeAllTags();
}
@ -940,10 +938,6 @@ export class Arena {
return 0;
}
}
resetPlayerFaintCount(): void {
this.playerFaints = 0;
}
}
export function getBiomeKey(biome: BiomeId): string {

View File

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

View File

@ -15,6 +15,7 @@ export interface SerializedArenaData {
tags?: ArenaTagTypeData[];
positionalTags: SerializedPositionalTag[];
playerTerasUsed?: number;
playerFaints?: number;
}
export class ArenaData {
@ -24,6 +25,7 @@ export class ArenaData {
public tags: ArenaTag[];
public positionalTags: SerializedPositionalTag[] = [];
public playerTerasUsed: number;
public playerFaints: number;
constructor(source: Arena | SerializedArenaData) {
// Exclude any unserializable tags from the serialized data (such as ones only lasting 1 turn).
@ -43,6 +45,7 @@ export class ArenaData {
// The assertion here is ok - we ensure that all tags are inside the `posTagConstructorMap` map,
// and that all `PositionalTags` will become their respective interfaces when serialized and de-serialized.
this.positionalTags = (source.positionalTagManager.tags as unknown as SerializedPositionalTag[]) ?? [];
this.playerFaints = source.playerFaints;
return;
}
@ -50,5 +53,6 @@ export class ArenaData {
this.weather = source.weather ? new Weather(source.weather.weatherType, source.weather.turnsLeft) : null;
this.terrain = source.terrain ? new Terrain(source.terrain.terrainType, source.terrain.turnsLeft) : null;
this.positionalTags = source.positionalTags ?? [];
this.playerFaints = source.playerFaints ?? 0;
}
}

View File

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