Fix tinted caught icon false positive (#892)

* Fix tinted caught icon false positive

* Remove unused import

* Rename and optimize

* Block comment

* use 3 equals
This commit is contained in:
Tempoanon 2024-05-17 06:28:22 -04:00 committed by GitHub
parent 4362d49e6b
commit edf3a6aa36
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -260,8 +260,23 @@ 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 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);
const rootFormHasHiddenAbility = pokemon.scene.gameData.starterData[pokemon.species.getRootSpeciesId()].abilityAttr & opponentPokemonAbilityAttr;
if (missingDexAttrs || !rootFormHasHiddenAbility)
this.ownedIcon.setTint(0x808080);
if (this.boss)