Add separate sub-legendary stats

pull/462/merge
Flashfyre 2024-05-05 17:11:29 -04:00
parent f7f235cdec
commit 6a3ca62490
3 changed files with 46 additions and 9 deletions

View File

@ -358,8 +358,11 @@ export class GameData {
this.starterData = systemData.starterData; this.starterData = systemData.starterData;
} }
if (systemData.gameStats) if (systemData.gameStats) {
if (systemData.gameStats.legendaryPokemonCaught !== undefined && systemData.gameStats.subLegendaryPokemonCaught === undefined)
this.fixLegendaryStats(systemData);
this.gameStats = systemData.gameStats; this.gameStats = systemData.gameStats;
}
if (systemData.unlocks) { if (systemData.unlocks) {
for (let key of Object.keys(systemData.unlocks)) { for (let key of Object.keys(systemData.unlocks)) {
@ -1005,7 +1008,9 @@ export class GameData {
if (incrementCount) { if (incrementCount) {
dexEntry.seenCount++; dexEntry.seenCount++;
this.gameStats.pokemonSeen++; this.gameStats.pokemonSeen++;
if (!trainer && pokemon.species.subLegendary || pokemon.species.legendary) if (!trainer && pokemon.species.subLegendary)
this.gameStats.subLegendaryPokemonSeen++;
else if (!trainer && pokemon.species.legendary)
this.gameStats.legendaryPokemonSeen++; this.gameStats.legendaryPokemonSeen++;
else if (!trainer && pokemon.species.mythical) else if (!trainer && pokemon.species.mythical)
this.gameStats.mythicalPokemonSeen++; this.gameStats.mythicalPokemonSeen++;
@ -1043,7 +1048,9 @@ export class GameData {
if (!fromEgg) { if (!fromEgg) {
dexEntry.caughtCount++; dexEntry.caughtCount++;
this.gameStats.pokemonCaught++; this.gameStats.pokemonCaught++;
if (pokemon.species.subLegendary || pokemon.species.legendary) if (pokemon.species.subLegendary)
this.gameStats.subLegendaryPokemonCaught++;
else if (pokemon.species.legendary)
this.gameStats.legendaryPokemonCaught++; this.gameStats.legendaryPokemonCaught++;
else if (pokemon.species.mythical) else if (pokemon.species.mythical)
this.gameStats.mythicalPokemonCaught++; this.gameStats.mythicalPokemonCaught++;
@ -1052,7 +1059,9 @@ export class GameData {
} else { } else {
dexEntry.hatchedCount++; dexEntry.hatchedCount++;
this.gameStats.pokemonHatched++; this.gameStats.pokemonHatched++;
if (pokemon.species.subLegendary || pokemon.species.legendary) if (pokemon.species.subLegendary)
this.gameStats.subLegendaryPokemonHatched++;
else if (pokemon.species.legendary)
this.gameStats.legendaryPokemonHatched++; this.gameStats.legendaryPokemonHatched++;
else if (pokemon.species.mythical) else if (pokemon.species.mythical)
this.gameStats.mythicalPokemonHatched++; this.gameStats.mythicalPokemonHatched++;
@ -1311,4 +1320,22 @@ export class GameData {
for (let starterId of defaultStarterSpecies) for (let starterId of defaultStarterSpecies)
systemData.starterData[starterId].abilityAttr |= AbilityAttr.ABILITY_1; systemData.starterData[starterId].abilityAttr |= AbilityAttr.ABILITY_1;
} }
fixLegendaryStats(systemData: SystemSaveData): void {
systemData.gameStats.subLegendaryPokemonSeen = 0;
systemData.gameStats.subLegendaryPokemonCaught = 0;
systemData.gameStats.subLegendaryPokemonHatched = 0;
allSpecies.filter(s => s.subLegendary).forEach(s => {
const dexEntry = systemData.dexData[s.speciesId];
systemData.gameStats.subLegendaryPokemonSeen += dexEntry.seenCount;
systemData.gameStats.legendaryPokemonSeen = Math.max(systemData.gameStats.legendaryPokemonSeen - dexEntry.seenCount, 0);
systemData.gameStats.subLegendaryPokemonCaught += dexEntry.caughtCount;
systemData.gameStats.legendaryPokemonCaught = Math.max(systemData.gameStats.legendaryPokemonCaught - dexEntry.caughtCount, 0);
systemData.gameStats.subLegendaryPokemonHatched += dexEntry.hatchedCount;
systemData.gameStats.legendaryPokemonHatched = Math.max(systemData.gameStats.legendaryPokemonHatched - dexEntry.hatchedCount, 0);
});
systemData.gameStats.subLegendaryPokemonSeen = Math.max(systemData.gameStats.subLegendaryPokemonSeen, systemData.gameStats.subLegendaryPokemonCaught);
systemData.gameStats.legendaryPokemonSeen = Math.max(systemData.gameStats.legendaryPokemonSeen, systemData.gameStats.legendaryPokemonCaught);
systemData.gameStats.mythicalPokemonSeen = Math.max(systemData.gameStats.mythicalPokemonSeen, systemData.gameStats.mythicalPokemonCaught);
}
} }

View File

@ -18,6 +18,9 @@ export class GameStats {
public pokemonDefeated: integer; public pokemonDefeated: integer;
public pokemonCaught: integer; public pokemonCaught: integer;
public pokemonHatched: integer; public pokemonHatched: integer;
public subLegendaryPokemonSeen: integer;
public subLegendaryPokemonCaught: integer;
public subLegendaryPokemonHatched: integer;
public legendaryPokemonSeen: integer; public legendaryPokemonSeen: integer;
public legendaryPokemonCaught: integer; public legendaryPokemonCaught: integer;
public legendaryPokemonHatched: integer; public legendaryPokemonHatched: integer;
@ -52,6 +55,10 @@ export class GameStats {
this.pokemonDefeated = source?.pokemonDefeated || 0; this.pokemonDefeated = source?.pokemonDefeated || 0;
this.pokemonCaught = source?.pokemonCaught || 0; this.pokemonCaught = source?.pokemonCaught || 0;
this.pokemonHatched = source?.pokemonHatched || 0; this.pokemonHatched = source?.pokemonHatched || 0;
// Currently handled by migration
this.subLegendaryPokemonSeen = source?.subLegendaryPokemonSeen;
this.subLegendaryPokemonCaught = source?.subLegendaryPokemonCaught;
this.subLegendaryPokemonHatched = source?.subLegendaryPokemonHatched;
this.legendaryPokemonSeen = source?.legendaryPokemonSeen || 0; this.legendaryPokemonSeen = source?.legendaryPokemonSeen || 0;
this.legendaryPokemonCaught = source?.legendaryPokemonCaught || 0; this.legendaryPokemonCaught = source?.legendaryPokemonCaught || 0;
this.legendaryPokemonHatched = source?.legendaryPokemonHatched || 0; this.legendaryPokemonHatched = source?.legendaryPokemonHatched || 0;

View File

@ -64,13 +64,16 @@ const displayStats: DisplayStats = {
pokemonDefeated: 'Pokémon Defeated', pokemonDefeated: 'Pokémon Defeated',
pokemonCaught: 'Pokémon Caught', pokemonCaught: 'Pokémon Caught',
pokemonHatched: 'Eggs Hatched', pokemonHatched: 'Eggs Hatched',
legendaryPokemonSeen: 'Legendary Encounters?', subLegendaryPokemonSeen: 'Sub-Legends Seen?',
legendaryPokemonCaught: 'Legendaries Caught?', subLegendaryPokemonCaught: 'Sub-Legends Caught?',
legendaryPokemonHatched: 'Legendaries Hatched?', subLegendaryPokemonHatched: 'Sub-Legends Hatched?',
mythicalPokemonSeen: 'Mythical Encounters?', legendaryPokemonSeen: 'Legends Seen?',
legendaryPokemonCaught: 'Legends Caught?',
legendaryPokemonHatched: 'Legends Hatched?',
mythicalPokemonSeen: 'Mythicals Seen?',
mythicalPokemonCaught: 'Mythicals Caught?', mythicalPokemonCaught: 'Mythicals Caught?',
mythicalPokemonHatched: 'Mythicals Hatched?', mythicalPokemonHatched: 'Mythicals Hatched?',
shinyPokemonSeen: 'Shiny Encounters?', shinyPokemonSeen: 'Shinies Seen?',
shinyPokemonCaught: 'Shinies Caught?', shinyPokemonCaught: 'Shinies Caught?',
shinyPokemonHatched: 'Shinies Hatched?', shinyPokemonHatched: 'Shinies Hatched?',
pokemonFused: 'Pokémon Fused?', pokemonFused: 'Pokémon Fused?',