Fix starter moveset logic for starters with forms

pull/69/head
Flashfyre 2024-04-09 11:52:34 -04:00
parent 2623313970
commit 88de47d8d8
1 changed files with 11 additions and 11 deletions

View File

@ -638,7 +638,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
return { return {
label: allMoves[sm].name, label: allMoves[sm].name,
handler: () => { handler: () => {
this.swichMoveHandler(i, sm, m) this.switchMoveHandler(i, sm, m)
showSwapOptions(this.starterMoveset); showSwapOptions(this.starterMoveset);
} }
}; };
@ -787,7 +787,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
return success || error; return success || error;
} }
swichMoveHandler(i: number, newMove: Moves, move: Moves) { switchMoveHandler(i: number, newMove: Moves, move: Moves) {
const speciesId = this.lastSpecies.speciesId; const speciesId = this.lastSpecies.speciesId;
const existingMoveIndex = this.starterMoveset.indexOf(newMove); const existingMoveIndex = this.starterMoveset.indexOf(newMove);
this.starterMoveset[i] = 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); const props: DexAttrProps = this.scene.gameData.getSpeciesDexAttrProps(this.lastSpecies, this.dexAttrCursor);
// species has different forms // species has different forms
if (pokemonFormLevelMoves.hasOwnProperty(speciesId)) { if (pokemonFormLevelMoves.hasOwnProperty(speciesId)) {
// starterMoveData doesn't have base form moves // starterMoveData doesn't have base form moves or is using the single form format
if (!this.scene.gameData.starterMoveData.hasOwnProperty(speciesId)){ if (!this.scene.gameData.starterMoveData.hasOwnProperty(speciesId) || Array.isArray(this.scene.gameData.starterMoveData[speciesId]))
this.scene.gameData.starterMoveData[speciesId] = this.starterMoveset.slice(0) as StarterMoveset; this.scene.gameData.starterMoveData[speciesId] = { [props.formIndex]: this.starterMoveset.slice(0) as StarterMoveset };
} const starterMoveData = this.scene.gameData.starterMoveData[speciesId][props.formIndex];
const starterMoveData = this.scene.gameData.starterMoveData[speciesId]
// starterMoveData doesn't have active form moves // 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; 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 // 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 // active form move hasn't been updated
if (starterMoveData[props.formIndex][existingMoveIndex] !== newMove) if (starterMoveData[props.formIndex][existingMoveIndex] !== newMove)
this.scene.gameData.starterMoveData[speciesId][props.formIndex] = this.starterMoveset.slice(0) as StarterMoveset; this.scene.gameData.starterMoveData[speciesId][props.formIndex] = this.starterMoveset.slice(0) as StarterMoveset;
} }
} else } else
this.scene.gameData.starterMoveData[speciesId] = this.starterMoveset.slice(0) as StarterMoveset; this.scene.gameData.starterMoveData[speciesId] = this.starterMoveset.slice(0) as StarterMoveset;
this.setSpeciesDetails(this.lastSpecies, undefined, undefined, undefined, undefined, undefined, false); this.setSpeciesDetails(this.lastSpecies, undefined, undefined, undefined, undefined, undefined, false);