From 88de47d8d89131f3ead65ca3d4c6af0dd0a63f1e Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Tue, 9 Apr 2024 11:52:34 -0400 Subject: [PATCH] Fix starter moveset logic for starters with forms --- src/ui/starter-select-ui-handler.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index a56687783..993a76b14 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -638,7 +638,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { return { label: allMoves[sm].name, handler: () => { - this.swichMoveHandler(i, sm, m) + this.switchMoveHandler(i, sm, m) showSwapOptions(this.starterMoveset); } }; @@ -787,7 +787,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { return success || error; } - swichMoveHandler(i: number, newMove: Moves, move: Moves) { + switchMoveHandler(i: number, newMove: Moves, move: Moves) { const speciesId = this.lastSpecies.speciesId; const existingMoveIndex = this.starterMoveset.indexOf(newMove); this.starterMoveset[i] = newMove; @@ -796,21 +796,21 @@ export default class StarterSelectUiHandler extends MessageUiHandler { const props: DexAttrProps = this.scene.gameData.getSpeciesDexAttrProps(this.lastSpecies, this.dexAttrCursor); // species has different forms if (pokemonFormLevelMoves.hasOwnProperty(speciesId)) { - // starterMoveData doesn't have base form moves - if (!this.scene.gameData.starterMoveData.hasOwnProperty(speciesId)){ - this.scene.gameData.starterMoveData[speciesId] = this.starterMoveset.slice(0) as StarterMoveset; - } - const starterMoveData = this.scene.gameData.starterMoveData[speciesId] + // starterMoveData doesn't have base form moves or is using the single form format + if (!this.scene.gameData.starterMoveData.hasOwnProperty(speciesId) || Array.isArray(this.scene.gameData.starterMoveData[speciesId])) + this.scene.gameData.starterMoveData[speciesId] = { [props.formIndex]: this.starterMoveset.slice(0) as StarterMoveset }; + const starterMoveData = this.scene.gameData.starterMoveData[speciesId][props.formIndex]; + // starterMoveData doesn't have active form moves - if (!starterMoveData.hasOwnProperty(props.formIndex)) { + if (!starterMoveData.hasOwnProperty(props.formIndex)) this.scene.gameData.starterMoveData[speciesId][props.formIndex] = this.starterMoveset.slice(0) as StarterMoveset; - } + // does the species' starter move data have its form's starter moves and has it been updated - if (starterMoveData.hasOwnProperty(props.formIndex) && Array.isArray(starterMoveData[props.formIndex])) { + if (starterMoveData.hasOwnProperty(props.formIndex)) { // active form move hasn't been updated if (starterMoveData[props.formIndex][existingMoveIndex] !== newMove) this.scene.gameData.starterMoveData[speciesId][props.formIndex] = this.starterMoveset.slice(0) as StarterMoveset; - } + } } else this.scene.gameData.starterMoveData[speciesId] = this.starterMoveset.slice(0) as StarterMoveset; this.setSpeciesDetails(this.lastSpecies, undefined, undefined, undefined, undefined, undefined, false);