mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-19 13:59:27 +02:00
Add player faints to Arena Data
This commit is contained in:
parent
2ff9bd4652
commit
f80574a1a0
@ -1508,8 +1508,8 @@ export class BattleScene extends SceneBase {
|
|||||||
return this.currentBattle;
|
return this.currentBattle;
|
||||||
}
|
}
|
||||||
|
|
||||||
newArena(biome: BiomeId, playerFaints = 0): Arena {
|
newArena(biome: BiomeId): Arena {
|
||||||
this.arena = new Arena(biome, playerFaints);
|
this.arena = new Arena(biome);
|
||||||
this.eventTarget.dispatchEvent(new NewArenaEvent());
|
this.eventTarget.dispatchEvent(new NewArenaEvent());
|
||||||
|
|
||||||
this.arenaBg.pipelineData = {
|
this.arenaBg.pipelineData = {
|
||||||
|
@ -59,7 +59,7 @@ export class Arena {
|
|||||||
* Saves the number of times a party pokemon faints during a arena encounter.
|
* 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).
|
* {@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;
|
private lastTimeOfDay: TimeOfDay;
|
||||||
|
|
||||||
@ -68,12 +68,11 @@ export class Arena {
|
|||||||
|
|
||||||
public readonly eventTarget: EventTarget = new EventTarget();
|
public readonly eventTarget: EventTarget = new EventTarget();
|
||||||
|
|
||||||
constructor(biome: BiomeId, playerFaints = 0) {
|
constructor(biome: BiomeId) {
|
||||||
this.biomeType = biome;
|
this.biomeType = biome;
|
||||||
this.bgm = BiomeId[biome].toLowerCase();
|
this.bgm = BiomeId[biome].toLowerCase();
|
||||||
this.trainerPool = biomeTrainerPools[biome];
|
this.trainerPool = biomeTrainerPools[biome];
|
||||||
this.updatePoolsForTimeOfDay();
|
this.updatePoolsForTimeOfDay();
|
||||||
this.playerFaints = playerFaints;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
@ -854,7 +853,6 @@ export class Arena {
|
|||||||
this.trySetWeather(WeatherType.NONE);
|
this.trySetWeather(WeatherType.NONE);
|
||||||
}
|
}
|
||||||
this.trySetTerrain(TerrainType.NONE, true);
|
this.trySetTerrain(TerrainType.NONE, true);
|
||||||
this.resetPlayerFaintCount();
|
|
||||||
this.removeAllTags();
|
this.removeAllTags();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -940,10 +938,6 @@ export class Arena {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resetPlayerFaintCount(): void {
|
|
||||||
this.playerFaints = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getBiomeKey(biome: BiomeId): string {
|
export function getBiomeKey(biome: BiomeId): string {
|
||||||
|
@ -340,7 +340,6 @@ export class GameOverPhase extends BattlePhase {
|
|||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ export interface SerializedArenaData {
|
|||||||
tags?: ArenaTagTypeData[];
|
tags?: ArenaTagTypeData[];
|
||||||
positionalTags: SerializedPositionalTag[];
|
positionalTags: SerializedPositionalTag[];
|
||||||
playerTerasUsed?: number;
|
playerTerasUsed?: number;
|
||||||
|
playerFaints?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ArenaData {
|
export class ArenaData {
|
||||||
@ -24,6 +25,7 @@ export class ArenaData {
|
|||||||
public tags: ArenaTag[];
|
public tags: ArenaTag[];
|
||||||
public positionalTags: SerializedPositionalTag[] = [];
|
public positionalTags: SerializedPositionalTag[] = [];
|
||||||
public playerTerasUsed: number;
|
public playerTerasUsed: number;
|
||||||
|
public playerFaints: number;
|
||||||
|
|
||||||
constructor(source: Arena | SerializedArenaData) {
|
constructor(source: Arena | SerializedArenaData) {
|
||||||
// Exclude any unserializable tags from the serialized data (such as ones only lasting 1 turn).
|
// 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,
|
// 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.
|
// and that all `PositionalTags` will become their respective interfaces when serialized and de-serialized.
|
||||||
this.positionalTags = (source.positionalTagManager.tags as unknown as SerializedPositionalTag[]) ?? [];
|
this.positionalTags = (source.positionalTagManager.tags as unknown as SerializedPositionalTag[]) ?? [];
|
||||||
|
this.playerFaints = source.playerFaints;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,5 +53,6 @@ export class ArenaData {
|
|||||||
this.weather = source.weather ? new Weather(source.weather.weatherType, source.weather.turnsLeft) : null;
|
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.terrain = source.terrain ? new Terrain(source.terrain.terrainType, source.terrain.turnsLeft) : null;
|
||||||
this.positionalTags = source.positionalTags ?? [];
|
this.positionalTags = source.positionalTags ?? [];
|
||||||
|
this.playerFaints = source.playerFaints ?? 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,10 +134,6 @@ 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 {
|
||||||
@ -941,7 +937,6 @@ export class GameData {
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1079,7 +1074,7 @@ export class GameData {
|
|||||||
|
|
||||||
globalScene.mysteryEncounterSaveData = new MysteryEncounterSaveData(sessionData.mysteryEncounterSaveData);
|
globalScene.mysteryEncounterSaveData = new MysteryEncounterSaveData(sessionData.mysteryEncounterSaveData);
|
||||||
|
|
||||||
globalScene.newArena(sessionData.arena.biome, sessionData.playerFaints);
|
globalScene.newArena(sessionData.arena.biome);
|
||||||
|
|
||||||
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;
|
||||||
|
Loading…
Reference in New Issue
Block a user