[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 <bennybroseph@gmail.com>
This commit is contained in:
Lee ByungHoon 2024-06-07 00:12:19 +09:00 committed by GitHub
parent e0401a93aa
commit 081d813540
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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;
}