Merge pull request #3617 from KimJeongSun/fix-only-variant-form-bugs
[Hotfix] Fixed a bug occurring when only single rare/epic variant or a single rare form in Starter UI
This commit is contained in:
commit
c40717fd33
|
@ -2916,14 +2916,18 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
||||||
const isCaught = this.scene.gameData.dexData[species.speciesId]?.caughtAttr || BigInt(0);
|
const isCaught = this.scene.gameData.dexData[species.speciesId]?.caughtAttr || BigInt(0);
|
||||||
const isVariant3Caught = !!(isCaught & DexAttr.VARIANT_3);
|
const isVariant3Caught = !!(isCaught & DexAttr.VARIANT_3);
|
||||||
const isVariant2Caught = !!(isCaught & DexAttr.VARIANT_2);
|
const isVariant2Caught = !!(isCaught & DexAttr.VARIANT_2);
|
||||||
|
const isDefaultVariantCaught = !!(isCaught & DexAttr.DEFAULT_VARIANT);
|
||||||
const isVariantCaught = !!(isCaught & DexAttr.SHINY);
|
const isVariantCaught = !!(isCaught & DexAttr.SHINY);
|
||||||
const isMaleCaught = !!(isCaught & DexAttr.MALE);
|
const isMaleCaught = !!(isCaught & DexAttr.MALE);
|
||||||
const isFemaleCaught = !!(isCaught & DexAttr.FEMALE);
|
const isFemaleCaught = !!(isCaught & DexAttr.FEMALE);
|
||||||
|
|
||||||
|
const starterAttributes = this.starterPreferences[species.speciesId];
|
||||||
|
|
||||||
|
const props = this.scene.gameData.getSpeciesDexAttrProps(species, this.getCurrentDexProps(species.speciesId));
|
||||||
|
const defaultAbilityIndex = this.scene.gameData.getStarterSpeciesDefaultAbilityIndex(species);
|
||||||
|
const defaultNature = this.scene.gameData.getSpeciesDefaultNature(species);
|
||||||
|
|
||||||
if (!dexEntry.caughtAttr) {
|
if (!dexEntry.caughtAttr) {
|
||||||
const props = this.scene.gameData.getSpeciesDexAttrProps(species, this.getCurrentDexProps(species.speciesId));
|
|
||||||
const defaultAbilityIndex = this.scene.gameData.getStarterSpeciesDefaultAbilityIndex(species);
|
|
||||||
const defaultNature = this.scene.gameData.getSpeciesDefaultNature(species);
|
|
||||||
if (shiny === undefined || shiny !== props.shiny) {
|
if (shiny === undefined || shiny !== props.shiny) {
|
||||||
shiny = props.shiny;
|
shiny = props.shiny;
|
||||||
}
|
}
|
||||||
|
@ -2942,6 +2946,83 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
||||||
if (natureIndex === undefined || natureIndex !== defaultNature) {
|
if (natureIndex === undefined || natureIndex !== defaultNature) {
|
||||||
natureIndex = defaultNature;
|
natureIndex = defaultNature;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// compare current shiny, formIndex, female, variant, abilityIndex, natureIndex with the caught ones
|
||||||
|
// if the current ones are not caught, we need to find the next caught ones
|
||||||
|
if (shiny) {
|
||||||
|
if (!(isVariantCaught || isVariant2Caught || isVariant3Caught)) {
|
||||||
|
shiny = false;
|
||||||
|
starterAttributes.shiny = false;
|
||||||
|
variant = 0;
|
||||||
|
starterAttributes.variant = 0;
|
||||||
|
} else {
|
||||||
|
shiny = true;
|
||||||
|
starterAttributes.shiny = true;
|
||||||
|
if (variant === 0 && !isDefaultVariantCaught) {
|
||||||
|
if (isVariant2Caught) {
|
||||||
|
variant = 1;
|
||||||
|
starterAttributes.variant = 1;
|
||||||
|
} else if (isVariant3Caught) {
|
||||||
|
variant = 2;
|
||||||
|
starterAttributes.variant = 2;
|
||||||
|
} else {
|
||||||
|
variant = 0;
|
||||||
|
starterAttributes.variant = 0;
|
||||||
|
}
|
||||||
|
} else if (variant === 1 && !isVariant2Caught) {
|
||||||
|
if (isVariantCaught) {
|
||||||
|
variant = 0;
|
||||||
|
starterAttributes.variant = 0;
|
||||||
|
} else if (isVariant3Caught) {
|
||||||
|
variant = 2;
|
||||||
|
starterAttributes.variant = 2;
|
||||||
|
} else {
|
||||||
|
variant = 0;
|
||||||
|
starterAttributes.variant = 0;
|
||||||
|
}
|
||||||
|
} else if (variant === 2 && !isVariant3Caught) {
|
||||||
|
if (isVariantCaught) {
|
||||||
|
variant = 0;
|
||||||
|
starterAttributes.variant = 0;
|
||||||
|
} else if (isVariant2Caught) {
|
||||||
|
variant = 1;
|
||||||
|
starterAttributes.variant = 1;
|
||||||
|
} else {
|
||||||
|
variant = 0;
|
||||||
|
starterAttributes.variant = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (female) {
|
||||||
|
if (!isFemaleCaught) {
|
||||||
|
female = false;
|
||||||
|
starterAttributes.female = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!isMaleCaught) {
|
||||||
|
female = true;
|
||||||
|
starterAttributes.female = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (species.forms) {
|
||||||
|
const formCount = species.forms.length;
|
||||||
|
let newFormIndex = formIndex??0;
|
||||||
|
if (species.forms[newFormIndex]) {
|
||||||
|
const isValidForm = species.forms[newFormIndex].isStarterSelectable && dexEntry.caughtAttr & this.scene.gameData.getFormAttr(newFormIndex);
|
||||||
|
if (!isValidForm) {
|
||||||
|
do {
|
||||||
|
newFormIndex = (newFormIndex + 1) % formCount;
|
||||||
|
if (species.forms[newFormIndex].isStarterSelectable && dexEntry.caughtAttr & this.scene.gameData.getFormAttr(newFormIndex)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} while (newFormIndex !== props.formIndex);
|
||||||
|
formIndex = newFormIndex;
|
||||||
|
starterAttributes.form = formIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.shinyOverlay.setVisible(shiny ?? false); // TODO: is false the correct default?
|
this.shinyOverlay.setVisible(shiny ?? false); // TODO: is false the correct default?
|
||||||
|
@ -2993,12 +3074,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dexEntry.caughtAttr && species.malePercent !== null) {
|
if (dexEntry.caughtAttr && species.malePercent !== null) {
|
||||||
let gender: Gender;
|
const gender = !female ? Gender.MALE : Gender.FEMALE;
|
||||||
if ((female && isFemaleCaught) || (!female && !isMaleCaught)) {
|
|
||||||
gender = Gender.FEMALE;
|
|
||||||
} else {
|
|
||||||
gender = Gender.MALE;
|
|
||||||
}
|
|
||||||
this.pokemonGenderText.setText(getGenderSymbol(gender));
|
this.pokemonGenderText.setText(getGenderSymbol(gender));
|
||||||
this.pokemonGenderText.setColor(getGenderColor(gender));
|
this.pokemonGenderText.setColor(getGenderColor(gender));
|
||||||
this.pokemonGenderText.setShadowColor(getGenderColor(gender, true));
|
this.pokemonGenderText.setShadowColor(getGenderColor(gender, true));
|
||||||
|
@ -3479,7 +3555,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
||||||
|
|
||||||
checkIconId(icon: Phaser.GameObjects.Sprite, species: PokemonSpecies, female: boolean, formIndex: number, shiny: boolean, variant: number) {
|
checkIconId(icon: Phaser.GameObjects.Sprite, species: PokemonSpecies, female: boolean, formIndex: number, shiny: boolean, variant: number) {
|
||||||
if (icon.frame.name !== species.getIconId(female, formIndex, shiny, variant)) {
|
if (icon.frame.name !== species.getIconId(female, formIndex, shiny, variant)) {
|
||||||
console.log(`${species.name}'s variant icon does not exist. Replacing with default.`);
|
console.log(`${species.name}'s icon ${icon.frame.name} does not match getIconId with female: ${female}, formIndex: ${formIndex}, shiny: ${shiny}, variant: ${variant}`);
|
||||||
icon.setTexture(species.getIconAtlasKey(formIndex, false, variant));
|
icon.setTexture(species.getIconAtlasKey(formIndex, false, variant));
|
||||||
icon.setFrame(species.getIconId(female, formIndex, false, variant));
|
icon.setFrame(species.getIconId(female, formIndex, false, variant));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue