From 1a4de942f7675300b7e8100e9a43d43193399acc Mon Sep 17 00:00:00 2001 From: Wlowscha <54003515+Wlowscha@users.noreply.github.com> Date: Mon, 8 Sep 2025 16:09:20 +0200 Subject: [PATCH] Renamed fields in `StarterPreferences` --- src/system/game-data.ts | 4 +- src/ui/containers/starter-summary.ts | 2 +- src/ui/handlers/pokedex-page-ui-handler.ts | 44 ++++++++++---------- src/ui/handlers/pokedex-ui-handler.ts | 14 +++---- src/ui/handlers/starter-select-ui-handler.ts | 31 +++++++------- test/ui/pokedex.test.ts | 4 +- 6 files changed, 50 insertions(+), 49 deletions(-) diff --git a/src/system/game-data.ts b/src/system/game-data.ts index 4ec15aa70ca..d7cacaf5697 100644 --- a/src/system/game-data.ts +++ b/src/system/game-data.ts @@ -169,9 +169,9 @@ export interface StarterMoveData { export interface StarterPreferences { nature?: number; - ability?: number; + abilityIndex?: number; variant?: number; - form?: number; + formIndex?: number; female?: boolean; shiny?: boolean; favorite?: boolean; diff --git a/src/ui/containers/starter-summary.ts b/src/ui/containers/starter-summary.ts index ca75897b567..95a88182249 100644 --- a/src/ui/containers/starter-summary.ts +++ b/src/ui/containers/starter-summary.ts @@ -548,7 +548,7 @@ export class StarterSummary extends Phaser.GameObjects.Container { } const props = globalScene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr); - props.formIndex = starterPreferences?.form ?? props.formIndex; + props.formIndex = starterPreferences?.formIndex ?? props.formIndex; const speciesForm = getPokemonSpeciesForm(species.speciesId, props.formIndex); this.setTypeIcons(speciesForm.type1, speciesForm.type2); diff --git a/src/ui/handlers/pokedex-page-ui-handler.ts b/src/ui/handlers/pokedex-page-ui-handler.ts index 6d726ae896e..3bf9ed7e95c 100644 --- a/src/ui/handlers/pokedex-page-ui-handler.ts +++ b/src/ui/handlers/pokedex-page-ui-handler.ts @@ -727,7 +727,7 @@ export class PokedexPageUiHandler extends MessageUiHandler { variant: 0, form: 0, }; - this.formIndex = this.savedStarterPreferences.form ?? 0; + this.formIndex = this.savedStarterPreferences.formIndex ?? 0; this.filteredIndices = args[2] ?? null; this.starterSetup(); @@ -1632,8 +1632,8 @@ export class PokedexPageUiHandler extends MessageUiHandler { : ""; const matchingForm = newSpecies?.forms.find(form => form.formKey === newFormKey); const newFormIndex = matchingForm ? matchingForm.formIndex : 0; - this.starterPreferences.form = newFormIndex; - this.savedStarterPreferences.form = newFormIndex; + this.starterPreferences.formIndex = newFormIndex; + this.savedStarterPreferences.formIndex = newFormIndex; this.moveInfoOverlay.clear(); this.clearText(); ui.setMode(UiMode.POKEDEX_PAGE, newSpecies, this.savedStarterPreferences); @@ -1674,8 +1674,8 @@ export class PokedexPageUiHandler extends MessageUiHandler { handler: () => { this.previousSpecies.push(this.species); this.previousStarterPreferences.push({ ...this.savedStarterPreferences }); - this.starterPreferences.form = newFormIndex; - this.savedStarterPreferences.form = newFormIndex; + this.starterPreferences.formIndex = newFormIndex; + this.savedStarterPreferences.formIndex = newFormIndex; this.moveInfoOverlay.clear(); this.clearText(); ui.setMode(UiMode.POKEDEX_PAGE, evoSpecies, this.savedStarterPreferences); @@ -1718,8 +1718,8 @@ export class PokedexPageUiHandler extends MessageUiHandler { this.previousStarterPreferences.push({ ...this.savedStarterPreferences }); const newSpecies = this.species; const newFormIndex = this.species.forms.find(f => f.formKey === bf.formKey)?.formIndex; - this.starterPreferences.form = newFormIndex; - this.savedStarterPreferences.form = newFormIndex; + this.starterPreferences.formIndex = newFormIndex; + this.savedStarterPreferences.formIndex = newFormIndex; this.moveInfoOverlay.clear(); this.clearText(); ui.setMode( @@ -1879,8 +1879,8 @@ export class PokedexPageUiHandler extends MessageUiHandler { break; } } while (newFormIndex !== props.formIndex || this.species.forms[newFormIndex].isUnobtainable); - starterPreferences.form = newFormIndex; // store the selected form - this.savedStarterPreferences.form = starterPreferences.form; + starterPreferences.formIndex = newFormIndex; // store the selected form + this.savedStarterPreferences.formIndex = starterPreferences.formIndex; this.formIndex = newFormIndex; // Some forms are tied to the gender and should change accordingly let newFemale = props.female; @@ -1906,8 +1906,8 @@ export class PokedexPageUiHandler extends MessageUiHandler { if (this.isFormGender) { newFormIndex = this.formIndex === 0 ? 1 : 0; } - starterPreferences.form = newFormIndex; // store the selected form - this.savedStarterPreferences.form = starterPreferences.form; + starterPreferences.formIndex = newFormIndex; // store the selected form + this.savedStarterPreferences.formIndex = starterPreferences.formIndex; this.formIndex = newFormIndex; this.starterSetup(); this.setSpeciesDetails(this.species, { @@ -2107,8 +2107,8 @@ export class PokedexPageUiHandler extends MessageUiHandler { form => form.formKey === this.species?.forms[this.formIndex]?.formKey, ); const newFormIndex = matchingForm ? matchingForm.formIndex : 0; - this.starterPreferences.form = newFormIndex; - this.savedStarterPreferences.form = newFormIndex; + this.starterPreferences.formIndex = newFormIndex; + this.savedStarterPreferences.formIndex = newFormIndex; this.moveInfoOverlay.clear(); this.clearText(); ui.setModeForceTransition( @@ -2146,8 +2146,8 @@ export class PokedexPageUiHandler extends MessageUiHandler { form => form.formKey === this.species?.forms[this.formIndex]?.formKey, ); const newFormIndex = matchingForm ? matchingForm.formIndex : 0; - this.starterPreferences.form = newFormIndex; - this.savedStarterPreferences.form = newFormIndex; + this.starterPreferences.formIndex = newFormIndex; + this.savedStarterPreferences.formIndex = newFormIndex; this.moveInfoOverlay.clear(); this.clearText(); ui.setModeForceTransition( @@ -2336,12 +2336,12 @@ export class PokedexPageUiHandler extends MessageUiHandler { props.variant = starterPreferences.variant as Variant; } } - props.form = starterPreferences?.form ?? props.form; + props.formIndex = starterPreferences?.formIndex ?? props.formIndex; props.female = starterPreferences?.female ?? props.female; this.setSpeciesDetails(species, { shiny: props.shiny, - formIndex: props.form, + formIndex: props.formIndex, female: props.female, variant: props.variant ?? 0, }); @@ -2443,7 +2443,7 @@ export class PokedexPageUiHandler extends MessageUiHandler { variant = oldProps?.variant ?? 0; } if (formIndex === undefined) { - formIndex = oldProps?.form ?? 0; + formIndex = oldProps?.formIndex ?? 0; } } @@ -2463,8 +2463,8 @@ export class PokedexPageUiHandler extends MessageUiHandler { if (shiny === undefined || shiny !== props.shiny) { shiny = props.shiny; } - if (formIndex === undefined || formIndex !== props.form) { - formIndex = props.form; + if (formIndex === undefined || formIndex !== props.formIndex) { + formIndex = props.formIndex; } if (female === undefined || female !== props.female) { female = props.female; @@ -2763,9 +2763,9 @@ export class PokedexPageUiHandler extends MessageUiHandler { props += DexAttr.NON_SHINY; props += DexAttr.DEFAULT_VARIANT; // we add the default variant here because non shiny versions are listed as default variant } - if (this.starterPreferences?.form) { + if (this.starterPreferences?.formIndex) { // this checks for the form of the pokemon - props += BigInt(Math.pow(2, this.starterPreferences?.form)) * DexAttr.DEFAULT_FORM; + props += BigInt(Math.pow(2, this.starterPreferences?.formIndex)) * DexAttr.DEFAULT_FORM; } else { // Get the first unlocked form props += globalScene.gameData.getFormAttr(globalScene.gameData.getFormIndex(caughtAttr)); diff --git a/src/ui/handlers/pokedex-ui-handler.ts b/src/ui/handlers/pokedex-ui-handler.ts index 1b0bea111fc..f817bb6cb0b 100644 --- a/src/ui/handlers/pokedex-ui-handler.ts +++ b/src/ui/handlers/pokedex-ui-handler.ts @@ -732,7 +732,7 @@ export class PokedexUiHandler extends MessageUiHandler { } } - if (starterPreferences.ability !== undefined) { + if (starterPreferences.abilityIndex !== undefined) { const speciesHasSingleAbility = species.ability2 === species.ability1; const abilityAttr = starterData.abilityAttr; const hasAbility1 = abilityAttr & AbilityAttr.ABILITY_1; @@ -745,20 +745,20 @@ export class PokedexUiHandler extends MessageUiHandler { speciesHasSingleAbility ? hasAbility2 && !hasAbility1 : hasAbility2, hasHiddenAbility, ]; - if (!unlockedAbilities[starterPreferences.ability]) { + if (!unlockedAbilities[starterPreferences.abilityIndex]) { // requested ability wasn't unlocked, purging setting - starterPreferences.ability = undefined; + starterPreferences.abilityIndex = undefined; } } - const selectedForm = starterPreferences.form; + const selectedForm = starterPreferences.formIndex; if ( selectedForm !== undefined && (!species.forms[selectedForm]?.isStarterSelectable || !(caughtAttr & globalScene.gameData.getFormAttr(selectedForm))) ) { // requested form wasn't unlocked/isn't a starter form, purging setting - starterPreferences.form = undefined; + starterPreferences.formIndex = undefined; } if (starterPreferences.nature !== undefined) { @@ -2357,9 +2357,9 @@ export class PokedexUiHandler extends MessageUiHandler { props += DexAttr.NON_SHINY; props += DexAttr.DEFAULT_VARIANT; // we add the default variant here because non shiny versions are listed as default variant } - if (this.starterPreferences[speciesId]?.form) { + if (this.starterPreferences[speciesId]?.formIndex) { // this checks for the form of the pokemon - props += BigInt(Math.pow(2, this.starterPreferences[speciesId]?.form)) * DexAttr.DEFAULT_FORM; + props += BigInt(Math.pow(2, this.starterPreferences[speciesId]?.formIndex)) * DexAttr.DEFAULT_FORM; } else { // Get the first unlocked form props += globalScene.gameData.getFormAttr(globalScene.gameData.getFormIndex(caughtAttr)); diff --git a/src/ui/handlers/starter-select-ui-handler.ts b/src/ui/handlers/starter-select-ui-handler.ts index 8851be92c95..95e3a9703f7 100644 --- a/src/ui/handlers/starter-select-ui-handler.ts +++ b/src/ui/handlers/starter-select-ui-handler.ts @@ -858,7 +858,7 @@ export class StarterSelectUiHandler extends MessageUiHandler { } } - if (starterPreferences.ability !== undefined) { + if (starterPreferences.abilityIndex !== undefined) { const speciesHasSingleAbility = species.ability2 === species.ability1; const abilityAttr = starterData.abilityAttr; const hasAbility1 = abilityAttr & AbilityAttr.ABILITY_1; @@ -871,20 +871,20 @@ export class StarterSelectUiHandler extends MessageUiHandler { speciesHasSingleAbility ? hasAbility2 && !hasAbility1 : hasAbility2, hasHiddenAbility, ]; - if (!unlockedAbilities[starterPreferences.ability]) { + if (!unlockedAbilities[starterPreferences.abilityIndex]) { // requested ability wasn't unlocked, purging setting - starterPreferences.ability = undefined; + starterPreferences.abilityIndex = undefined; } } - const selectedForm = starterPreferences.form; + const selectedForm = starterPreferences.formIndex; if ( selectedForm !== undefined && (!species.forms[selectedForm]?.isStarterSelectable || !(caughtAttr & globalScene.gameData.getFormAttr(selectedForm))) ) { // requested form wasn't unlocked/isn't a starter form, purging setting - starterPreferences.form = undefined; + starterPreferences.formIndex = undefined; } if (starterPreferences.nature !== undefined) { @@ -1457,8 +1457,8 @@ export class StarterSelectUiHandler extends MessageUiHandler { break; } } while (newFormIndex !== props.formIndex); - starterPreferences.form = newFormIndex; // store the selected form - originalStarterPreferences.form = newFormIndex; + starterPreferences.formIndex = newFormIndex; // store the selected form + originalStarterPreferences.formIndex = newFormIndex; starterPreferences.tera = this.lastSpecies.forms[newFormIndex].type1; originalStarterPreferences.tera = starterPreferences.tera; this.setSpeciesDetails(this.lastSpecies, { @@ -1502,8 +1502,8 @@ export class StarterSelectUiHandler extends MessageUiHandler { } } } while (newAbilityIndex !== this.abilityCursor); - starterPreferences.ability = newAbilityIndex; // store the selected ability - originalStarterPreferences.ability = newAbilityIndex; + starterPreferences.abilityIndex = newAbilityIndex; // store the selected ability + originalStarterPreferences.abilityIndex = newAbilityIndex; this.setSpeciesDetails(this.lastSpecies, { abilityIndex: newAbilityIndex, @@ -1527,7 +1527,7 @@ export class StarterSelectUiHandler extends MessageUiHandler { break; case Button.CYCLE_TERA: if (this.canCycleTera) { - const speciesForm = getPokemonSpeciesForm(this.lastSpecies.speciesId, starterPreferences.form ?? 0); + const speciesForm = getPokemonSpeciesForm(this.lastSpecies.speciesId, starterPreferences.formIndex ?? 0); if (speciesForm.type1 === this.teraCursor && !isNullOrUndefined(speciesForm.type2)) { starterPreferences.tera = speciesForm.type2; originalStarterPreferences.tera = starterPreferences.tera; @@ -2097,7 +2097,7 @@ export class StarterSelectUiHandler extends MessageUiHandler { const attributes = { shiny: starterPreferences.shiny, variant: starterPreferences.variant, - form: starterPreferences.form, + form: starterPreferences.formIndex, female: starterPreferences.female, }; ui.setOverlayMode(UiMode.POKEDEX_PAGE, this.lastSpecies, attributes, null, null, () => { @@ -3007,8 +3007,8 @@ export class StarterSelectUiHandler extends MessageUiHandler { if (starterPreferences?.nature) { this.natureCursor = starterPreferences.nature; } - if (starterPreferences?.ability && !Number.isNaN(starterPreferences.ability)) { - this.abilityCursor = starterPreferences.ability; + if (starterPreferences?.abilityIndex && !Number.isNaN(starterPreferences.abilityIndex)) { + this.abilityCursor = starterPreferences.abilityIndex; } if (starterPreferences?.tera) { this.teraCursor = starterPreferences.tera; @@ -3027,7 +3027,8 @@ export class StarterSelectUiHandler extends MessageUiHandler { const props = this.getSpeciesPropsFromPreferences(species); - const ability = starterPreferences?.ability ?? globalScene.gameData.getStarterSpeciesDefaultAbilityIndex(species); + const ability = + starterPreferences?.abilityIndex ?? globalScene.gameData.getStarterSpeciesDefaultAbilityIndex(species); const nature = starterPreferences?.nature || globalScene.gameData.getSpeciesDefaultNature(species, dexEntry); // TODO: are these checks necessary? getSpeciesPropsFromPreferences should have already done this. @@ -3036,7 +3037,7 @@ export class StarterSelectUiHandler extends MessageUiHandler { props.variant = starterPreferences.variant as Variant; } } - props.formIndex = starterPreferences?.form ?? props.formIndex; + props.formIndex = starterPreferences?.formIndex ?? props.formIndex; props.female = starterPreferences?.female ?? props.female; this.setSpeciesDetails( diff --git a/test/ui/pokedex.test.ts b/test/ui/pokedex.test.ts index 6490d968528..22f1b5bedf7 100644 --- a/test/ui/pokedex.test.ts +++ b/test/ui/pokedex.test.ts @@ -514,7 +514,7 @@ describe("UI - Pokedex", () => { it("should show caught battle form as caught", async () => { await game.importData("./test/test-utils/saves/data_pokedex_tests_v2.prsv"); - const pageHandler = await runToPokedexPage(getPokemonSpecies(SpeciesId.VENUSAUR), { form: 1 }); + const pageHandler = await runToPokedexPage(getPokemonSpecies(SpeciesId.VENUSAUR), { formIndex: 1 }); // @ts-expect-error - `species` is private expect(pageHandler.species.speciesId).toEqual(SpeciesId.VENUSAUR); @@ -529,7 +529,7 @@ describe("UI - Pokedex", () => { //TODO: check tint of the sprite it("should show uncaught battle form as seen", async () => { await game.importData("./test/test-utils/saves/data_pokedex_tests_v2.prsv"); - const pageHandler = await runToPokedexPage(getPokemonSpecies(SpeciesId.VENUSAUR), { form: 2 }); + const pageHandler = await runToPokedexPage(getPokemonSpecies(SpeciesId.VENUSAUR), { formIndex: 2 }); // @ts-expect-error - `species` is private expect(pageHandler.species.speciesId).toEqual(SpeciesId.VENUSAUR);