From 081d8135404918f96ae117531e531b926b4266bb Mon Sep 17 00:00:00 2001 From: Lee ByungHoon Date: Fri, 7 Jun 2024 00:12:19 +0900 Subject: [PATCH] [Feature] Move to start button when you can't add party anymore (#1673) * [Feature] Move to start button when you can't add party anymore * Add comment about #1673 * Update starter-select-ui-handler.ts --------- Co-authored-by: Benjamin Odom --- src/ui/starter-select-ui-handler.ts | 45 ++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index f799efe96b5..1dbb60915ca 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -224,6 +224,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { private canCycleNature: boolean; private canCycleVariant: boolean; private value: integer = 0; + private canAddParty: boolean; private assetLoadCancelled: Utils.BooleanHolder; private cursorObj: Phaser.GameObjects.Image; @@ -1047,6 +1048,16 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.tryStart(); } this.updateInstructions(); + + /** + * If the user can't select a pokemon anymore, + * go to start button. + */ + if (!this.canAddParty) { + this.startCursorObj.setVisible(true); + this.setGenMode(true); + } + ui.playSelect(); } else { ui.playError(); @@ -2131,11 +2142,43 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.scene.time.delayedCall(Utils.fixedInt(500), () => this.tryUpdateValue()); return false; } + + /** + * this loop is used to set the Sprite's alpha value and check if the user can select other pokemon more. + */ + this.canAddParty = false; + const remainValue = valueLimit - newValue; for (let g = 0; g < this.genSpecies.length; g++) { for (let s = 0; s < this.genSpecies[g].length; s++) { - (this.starterSelectGenIconContainers[g].getAt(s) as Phaser.GameObjects.Sprite).setAlpha((newValue + this.scene.gameData.getSpeciesStarterValue(this.genSpecies[g][s].speciesId)) > valueLimit ? 0.375 : 1); + /** Cost of pokemon species */ + const speciesStarterValue = this.scene.gameData.getSpeciesStarterValue(this.genSpecies[g][s].speciesId); + /** Used to detect if this pokemon is registered in starter */ + const speciesStarterDexEntry = this.scene.gameData.dexData[this.genSpecies[g][s].speciesId]; + /** {@linkcode Phaser.GameObjects.Sprite} object of Pokémon for setting the alpha value */ + const speciesSprite = this.starterSelectGenIconContainers[g].getAt(s) as Phaser.GameObjects.Sprite; + + /** + * If remainValue greater than or equal pokemon species, the user can select. + * so that the alpha value of pokemon sprite set 1. + * + * If speciesStarterDexEntry?.caughtAttr is true, this species registered in stater. + * we change to can AddParty value to true since the user has enough cost to choose this pokemon and this pokemon registered too. + */ + if (remainValue >= speciesStarterValue) { + speciesSprite.setAlpha(1); + if (speciesStarterDexEntry?.caughtAttr) { + this.canAddParty = true; + } + } else { + /** + * If remainValue less than pokemon, the use can't select. + * so that the alpha value of pokemon sprite set 0.375. + */ + speciesSprite.setAlpha(0.375); + } } } + this.value = newValue; return true; }