Update pokemon-info-container ability highlighting to match tinted ball ability check
This commit is contained in:
parent
e386504977
commit
c9817aa320
|
@ -3786,6 +3786,25 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
const rootForm = getPokemonSpecies(this.species.getRootSpeciesId());
|
||||
return rootForm.getAbility(abilityIndex) === rootForm.getAbility(currentAbilityIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to check if the player already owns the starter data of the Pokemon's
|
||||
* current ability
|
||||
* @param ownedAbilityAttrs the owned abilityAttr of this Pokemon's root form
|
||||
* @returns true if the player already has it, false otherwise
|
||||
*/
|
||||
checkIfPlayerHasAbilityOfStarter(ownedAbilityAttrs: number): boolean {
|
||||
if ((ownedAbilityAttrs & 1) > 0 && this.hasSameAbilityInRootForm(0)) {
|
||||
return true;
|
||||
}
|
||||
if ((ownedAbilityAttrs & 2) > 0 && this.hasSameAbilityInRootForm(1)) {
|
||||
return true;
|
||||
}
|
||||
if ((ownedAbilityAttrs & 4) > 0 && this.hasSameAbilityInRootForm(2)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export default interface Pokemon {
|
||||
|
|
|
@ -381,17 +381,8 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
|
|||
|
||||
const ownedAbilityAttrs = pokemon.scene.gameData.starterData[pokemon.species.getRootSpeciesId()].abilityAttr;
|
||||
|
||||
let playerOwnsThisAbility = false;
|
||||
// Check if the player owns ability for the root form
|
||||
if ((ownedAbilityAttrs & 1) > 0 && pokemon.hasSameAbilityInRootForm(0)) {
|
||||
playerOwnsThisAbility = true;
|
||||
}
|
||||
if ((ownedAbilityAttrs & 2) > 0 && pokemon.hasSameAbilityInRootForm(1)) {
|
||||
playerOwnsThisAbility = true;
|
||||
}
|
||||
if ((ownedAbilityAttrs & 4) > 0 && pokemon.hasSameAbilityInRootForm(2)) {
|
||||
playerOwnsThisAbility = true;
|
||||
}
|
||||
const playerOwnsThisAbility = pokemon.checkIfPlayerHasAbilityOfStarter(ownedAbilityAttrs);
|
||||
|
||||
if (missingDexAttrs || !playerOwnsThisAbility) {
|
||||
this.ownedIcon.setTint(0x808080);
|
||||
|
|
|
@ -267,18 +267,13 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container {
|
|||
this.pokemonAbilityText.setColor(getTextColor(abilityTextStyle, false, this.scene.uiTheme));
|
||||
this.pokemonAbilityText.setShadowColor(getTextColor(abilityTextStyle, true, this.scene.uiTheme));
|
||||
|
||||
/**
|
||||
* 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 = 1 << opponentPokemonAbilityIndex;
|
||||
|
||||
const rootFormHasHiddenAbility = starterEntry.abilityAttr & opponentPokemonAbilityAttr;
|
||||
const ownedAbilityAttrs = pokemon.scene.gameData.starterData[pokemon.species.getRootSpeciesId()].abilityAttr;
|
||||
|
||||
if (!rootFormHasHiddenAbility) {
|
||||
// Check if the playe rowns ability for the root form
|
||||
const playerOwnsThisAbility = pokemon.checkIfPlayerHasAbilityOfStarter(ownedAbilityAttrs);
|
||||
|
||||
if (!playerOwnsThisAbility) {
|
||||
this.pokemonAbilityLabelText.setColor(getTextColor(TextStyle.SUMMARY_BLUE, false, this.scene.uiTheme));
|
||||
this.pokemonAbilityLabelText.setShadowColor(getTextColor(TextStyle.SUMMARY_BLUE, true, this.scene.uiTheme));
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue