From 89cb61a105ae6b705a42962275398e83a8ecbfbb Mon Sep 17 00:00:00 2001 From: Temps Ray Date: Tue, 14 May 2024 21:11:26 -0400 Subject: [PATCH 1/4] Fix tinted caught icon false positive --- src/ui/battle-info.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/ui/battle-info.ts b/src/ui/battle-info.ts index f2e48911e..6e3050828 100644 --- a/src/ui/battle-info.ts +++ b/src/ui/battle-info.ts @@ -8,6 +8,7 @@ import BattleScene from '../battle-scene'; import { Type, getTypeRgb } from '../data/type'; import { getVariantTint } from '#app/data/variant'; import { BattleStat } from '#app/data/battle-stat'; +import { DexAttr } from '#app/system/game-data.js'; const battleStatOrder = [ BattleStat.ATK, BattleStat.DEF, BattleStat.SPATK, BattleStat.SPDEF, BattleStat.ACC, BattleStat.EVA, BattleStat.SPD ]; @@ -260,8 +261,21 @@ export default class BattleInfo extends Phaser.GameObjects.Container { if (!this.player) { const dexEntry = pokemon.scene.gameData.dexData[pokemon.species.speciesId]; this.ownedIcon.setVisible(!!dexEntry.caughtAttr); - const dexAttr = pokemon.getDexAttr(); - if ((dexEntry.caughtAttr & dexAttr) < dexAttr || !(pokemon.scene.gameData.starterData[pokemon.species.getRootSpeciesId()].abilityAttr & Math.pow(2, pokemon.abilityIndex))) + const opponentPokemonDexAttr = pokemon.getDexAttr(); + + // Check if Player owns all genders and forms of the Pokemon + const missingDexAttrs = ((dexEntry.caughtAttr & opponentPokemonDexAttr) < opponentPokemonDexAttr); + + // If the opposing Pokemon only has 1 ability and is using the hidden ability, it should have the same + // behavior if it had 2 abilities so it is set to 2 so it lines up with the math checking the proper + // hidden ability abilityAttr which is 4 + const opponentPokemonOneAbility = (pokemon.species.getAbilityCount() == 2); + const opponentPokemonAbilityIndex = (pokemon.abilityIndex === 1 && opponentPokemonOneAbility) ? 2 : pokemon.abilityIndex; + const opponentPokemonAbilityAttr = Math.pow(2, opponentPokemonAbilityIndex); + + const rootFormHasHiddenAbility = pokemon.scene.gameData.starterData[pokemon.species.getRootSpeciesId()].abilityAttr & opponentPokemonAbilityAttr; + + if (missingDexAttrs || !rootFormHasHiddenAbility) this.ownedIcon.setTint(0x808080); if (this.boss) From 83c65529ffa26a2d4f4cf82d31a9726d3a3a245f Mon Sep 17 00:00:00 2001 From: Temps Ray Date: Tue, 14 May 2024 21:12:55 -0400 Subject: [PATCH 2/4] Remove unused import --- src/ui/battle-info.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ui/battle-info.ts b/src/ui/battle-info.ts index 6e3050828..c0335ef3d 100644 --- a/src/ui/battle-info.ts +++ b/src/ui/battle-info.ts @@ -8,7 +8,6 @@ import BattleScene from '../battle-scene'; import { Type, getTypeRgb } from '../data/type'; import { getVariantTint } from '#app/data/variant'; import { BattleStat } from '#app/data/battle-stat'; -import { DexAttr } from '#app/system/game-data.js'; const battleStatOrder = [ BattleStat.ATK, BattleStat.DEF, BattleStat.SPATK, BattleStat.SPDEF, BattleStat.ACC, BattleStat.EVA, BattleStat.SPD ]; From 5d6e04e20da593c4d810f5735464bc8bccf5fde6 Mon Sep 17 00:00:00 2001 From: Temps Ray Date: Tue, 14 May 2024 21:15:08 -0400 Subject: [PATCH 3/4] Rename and optimize --- src/ui/battle-info.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui/battle-info.ts b/src/ui/battle-info.ts index c0335ef3d..056e2f82f 100644 --- a/src/ui/battle-info.ts +++ b/src/ui/battle-info.ts @@ -268,8 +268,8 @@ export default class BattleInfo extends Phaser.GameObjects.Container { // If the opposing Pokemon only has 1 ability and is using the hidden ability, it should have the same // behavior if it had 2 abilities so it is set to 2 so it lines up with the math checking the proper // hidden ability abilityAttr which is 4 - const opponentPokemonOneAbility = (pokemon.species.getAbilityCount() == 2); - const opponentPokemonAbilityIndex = (pokemon.abilityIndex === 1 && opponentPokemonOneAbility) ? 2 : pokemon.abilityIndex; + const opponentPokemonOneNormalAbility = (pokemon.species.getAbilityCount() == 2); + const opponentPokemonAbilityIndex = (opponentPokemonOneNormalAbility && pokemon.abilityIndex === 1) ? 2 : pokemon.abilityIndex; const opponentPokemonAbilityAttr = Math.pow(2, opponentPokemonAbilityIndex); const rootFormHasHiddenAbility = pokemon.scene.gameData.starterData[pokemon.species.getRootSpeciesId()].abilityAttr & opponentPokemonAbilityAttr; From 3a5e169b6731f7cf4e69b1d3341d1711763d70c3 Mon Sep 17 00:00:00 2001 From: Temps Ray Date: Wed, 15 May 2024 13:01:07 -0400 Subject: [PATCH 4/4] Block comment --- src/ui/battle-info.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ui/battle-info.ts b/src/ui/battle-info.ts index 056e2f82f..2ffa2d8b8 100644 --- a/src/ui/battle-info.ts +++ b/src/ui/battle-info.ts @@ -265,9 +265,11 @@ export default class BattleInfo extends Phaser.GameObjects.Container { // Check if Player owns all genders and forms of the Pokemon const missingDexAttrs = ((dexEntry.caughtAttr & opponentPokemonDexAttr) < opponentPokemonDexAttr); - // If the opposing Pokemon only has 1 ability and is using the hidden ability, it should have the same - // behavior if it had 2 abilities so it is set to 2 so it lines up with the math checking the proper - // hidden ability abilityAttr which is 4 + /** + * If the opposing Pokemon only has 1 normal ability and is using the hidden ability it should have the same behavior + * if it had 2 normal abilities. This code checks if that is the case and uses the correct opponent Pokemon abilityIndex (2) + * for calculations so it aligns with where the hidden ability is stored in the starter data's abilityAttr (4) + */ const opponentPokemonOneNormalAbility = (pokemon.species.getAbilityCount() == 2); const opponentPokemonAbilityIndex = (opponentPokemonOneNormalAbility && pokemon.abilityIndex === 1) ? 2 : pokemon.abilityIndex; const opponentPokemonAbilityAttr = Math.pow(2, opponentPokemonAbilityIndex);