Merged shiny and variant options

This commit is contained in:
Wlowscha 2025-01-30 01:19:00 +01:00
parent ee6115f49d
commit 366729ea68
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04

View File

@ -315,7 +315,6 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
private canCycleGender: boolean; private canCycleGender: boolean;
private canCycleAbility: boolean; private canCycleAbility: boolean;
private canCycleNature: boolean; private canCycleNature: boolean;
private canCycleVariant: boolean;
private assetLoadCancelled: BooleanHolder | null; private assetLoadCancelled: BooleanHolder | null;
public cursorObj: Phaser.GameObjects.Image; public cursorObj: Phaser.GameObjects.Image;
@ -1995,29 +1994,22 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
switch (button) { switch (button) {
case Button.CYCLE_SHINY: case Button.CYCLE_SHINY:
if (this.canCycleShiny) { if (this.canCycleShiny) {
starterAttributes.shiny = starterAttributes.shiny !== undefined ? !starterAttributes.shiny : false; if (starterAttributes.shiny === false) {
// If not shiny, we change to shiny and get the proper default variant
if (starterAttributes.shiny) {
// Change to shiny, we need to get the proper default variant
const newProps = globalScene.gameData.getSpeciesDexAttrProps(this.lastSpecies, this.getCurrentDexProps(this.lastSpecies.speciesId)); const newProps = globalScene.gameData.getSpeciesDexAttrProps(this.lastSpecies, this.getCurrentDexProps(this.lastSpecies.speciesId));
const newVariant = starterAttributes.variant ? starterAttributes.variant as Variant : newProps.variant; const newVariant = starterAttributes.variant ? starterAttributes.variant as Variant : newProps.variant;
this.setSpeciesDetails(this.lastSpecies, { shiny: true, variant: newVariant }); this.setSpeciesDetails(this.lastSpecies, { shiny: true, variant: newVariant });
globalScene.playSound("se/sparkle"); globalScene.playSound("se/sparkle");
// Set the variant label to the shiny tint // Cycle tint based on current sprite tint
const tint = getVariantTint(newVariant); const tint = getVariantTint(newVariant);
this.pokemonShinyIcon.setFrame(getVariantIcon(newVariant)); this.pokemonShinyIcon.setFrame(getVariantIcon(newVariant));
this.pokemonShinyIcon.setTint(tint); this.pokemonShinyIcon.setTint(tint);
this.pokemonShinyIcon.setVisible(true); this.pokemonShinyIcon.setVisible(true);
starterAttributes.shiny = true;
} else { } else {
this.setSpeciesDetails(this.lastSpecies, { shiny: false, variant: 0 }); // If shiny, we update the variant
this.pokemonShinyIcon.setVisible(false);
success = true;
}
}
break;
case Button.V:
if (this.canCycleVariant) {
let newVariant = props.variant; let newVariant = props.variant;
do { do {
newVariant = (newVariant + 1) % 3; newVariant = (newVariant + 1) % 3;
@ -2036,12 +2028,22 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
} }
} while (newVariant !== props.variant); } while (newVariant !== props.variant);
starterAttributes.variant = newVariant; // store the selected variant starterAttributes.variant = newVariant; // store the selected variant
// If going to a higher variant, display that
if (newVariant > props.variant) {
this.setSpeciesDetails(this.lastSpecies, { variant: newVariant as Variant }); this.setSpeciesDetails(this.lastSpecies, { variant: newVariant as Variant });
// Cycle tint based on current sprite tint // Cycle tint based on current sprite tint
const tint = getVariantTint(newVariant as Variant); const tint = getVariantTint(newVariant as Variant);
this.pokemonShinyIcon.setFrame(getVariantIcon(newVariant as Variant)); this.pokemonShinyIcon.setFrame(getVariantIcon(newVariant as Variant));
this.pokemonShinyIcon.setTint(tint); this.pokemonShinyIcon.setTint(tint);
success = true; success = true;
// If we have run out of variants, go back to non shiny
} else {
this.setSpeciesDetails(this.lastSpecies, { shiny: false, variant: 0 });
this.pokemonShinyIcon.setVisible(false);
success = true;
starterAttributes.shiny = false;
}
}
} }
break; break;
case Button.CYCLE_FORM: case Button.CYCLE_FORM:
@ -2368,9 +2370,6 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
case SettingKeyboard.Button_Cycle_Nature: case SettingKeyboard.Button_Cycle_Nature:
iconPath = "N.png"; iconPath = "N.png";
break; break;
case SettingKeyboard.Button_Cycle_Variant:
iconPath = "V.png";
break;
case SettingKeyboard.Button_Stats: case SettingKeyboard.Button_Stats:
iconPath = "C.png"; iconPath = "C.png";
break; break;
@ -2451,9 +2450,6 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
if (this.canCycleNature) { if (this.canCycleNature) {
this.updateButtonIcon(SettingKeyboard.Button_Cycle_Nature, gamepadType, this.natureIconElement, this.natureLabel); this.updateButtonIcon(SettingKeyboard.Button_Cycle_Nature, gamepadType, this.natureIconElement, this.natureLabel);
} }
if (this.canCycleVariant) {
this.updateButtonIcon(SettingKeyboard.Button_Cycle_Variant, gamepadType, this.variantIconElement, this.variantLabel);
}
} }
// if filter mode is inactivated and gamepadType is not undefined, update the button icons // if filter mode is inactivated and gamepadType is not undefined, update the button icons
@ -3249,12 +3245,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
const isNonShinyCaught = !!(caughtAttr & DexAttr.NON_SHINY); const isNonShinyCaught = !!(caughtAttr & DexAttr.NON_SHINY);
const isShinyCaught = !!(caughtAttr & DexAttr.SHINY); const isShinyCaught = !!(caughtAttr & DexAttr.SHINY);
const isVariant1Caught = isShinyCaught && !!(caughtAttr & DexAttr.DEFAULT_VARIANT);
const isVariant2Caught = isShinyCaught && !!(caughtAttr & DexAttr.VARIANT_2);
const isVariant3Caught = isShinyCaught && !!(caughtAttr & DexAttr.VARIANT_3);
this.canCycleShiny = isNonShinyCaught && isShinyCaught; this.canCycleShiny = isNonShinyCaught && isShinyCaught;
this.canCycleVariant = !!shiny && [ isVariant1Caught, isVariant2Caught, isVariant3Caught ].filter(v => v).length > 1;
const isMaleCaught = !!(caughtAttr & DexAttr.MALE); const isMaleCaught = !!(caughtAttr & DexAttr.MALE);
const isFemaleCaught = !!(caughtAttr & DexAttr.FEMALE); const isFemaleCaught = !!(caughtAttr & DexAttr.FEMALE);