starter select defaults to shiny with highest variant again (#4001)

This commit is contained in:
MokaStitcher 2024-09-04 10:58:39 +02:00 committed by GitHub
parent 200deef0ed
commit 1055386949
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 31 deletions

View File

@ -53,9 +53,6 @@ describe("UI - Starter select", () => {
const handler = game.scene.ui.getHandler() as StarterSelectUiHandler;
handler.processInput(Button.RIGHT);
handler.processInput(Button.LEFT);
handler.processInput(Button.CYCLE_SHINY);
handler.processInput(Button.V);
handler.processInput(Button.V);
handler.processInput(Button.ACTION);
game.phaseInterceptor.unlock();
});
@ -117,9 +114,6 @@ describe("UI - Starter select", () => {
handler.processInput(Button.RIGHT);
handler.processInput(Button.LEFT);
handler.processInput(Button.CYCLE_GENDER);
handler.processInput(Button.CYCLE_SHINY);
handler.processInput(Button.V);
handler.processInput(Button.V);
handler.processInput(Button.ACTION);
game.phaseInterceptor.unlock();
});
@ -184,9 +178,6 @@ describe("UI - Starter select", () => {
handler.processInput(Button.CYCLE_GENDER);
handler.processInput(Button.CYCLE_NATURE);
handler.processInput(Button.CYCLE_ABILITY);
handler.processInput(Button.CYCLE_SHINY);
handler.processInput(Button.V);
handler.processInput(Button.V);
handler.processInput(Button.ACTION);
game.phaseInterceptor.unlock();
});
@ -227,11 +218,12 @@ describe("UI - Starter select", () => {
expect(game.scene.getParty()[0].species.speciesId).toBe(Species.BULBASAUR);
expect(game.scene.getParty()[0].shiny).toBe(true);
expect(game.scene.getParty()[0].variant).toBe(2);
expect(game.scene.getParty()[0].gender).toBe(Gender.FEMALE);
expect(game.scene.getParty()[0].nature).toBe(Nature.LONELY);
expect(game.scene.getParty()[0].getAbility().id).toBe(Abilities.CHLOROPHYLL);
}, 20000);
it("Bulbasaur - shiny - variant 2 female lonely chlorophyl", async() => {
it("Bulbasaur - shiny - variant 2 female", async() => {
await game.importData("src/test/utils/saves/everything.prsv");
const caughtCount = Object.keys(game.scene.gameData.dexData).filter((key) => {
const species = game.scene.gameData.dexData[key];
@ -249,9 +241,6 @@ describe("UI - Starter select", () => {
handler.processInput(Button.RIGHT);
handler.processInput(Button.LEFT);
handler.processInput(Button.CYCLE_GENDER);
handler.processInput(Button.CYCLE_SHINY);
handler.processInput(Button.V);
handler.processInput(Button.V);
handler.processInput(Button.ACTION);
game.phaseInterceptor.unlock();
});
@ -313,6 +302,7 @@ describe("UI - Starter select", () => {
handler.processInput(Button.RIGHT);
handler.processInput(Button.LEFT);
handler.processInput(Button.ACTION);
handler.processInput(Button.CYCLE_SHINY);
game.phaseInterceptor.unlock();
});
await game.phaseInterceptor.run(SelectStarterPhase);
@ -371,7 +361,7 @@ describe("UI - Starter select", () => {
const handler = game.scene.ui.getHandler() as StarterSelectUiHandler;
handler.processInput(Button.RIGHT);
handler.processInput(Button.LEFT);
handler.processInput(Button.CYCLE_SHINY);
handler.processInput(Button.V);
handler.processInput(Button.V);
handler.processInput(Button.ACTION);
game.phaseInterceptor.unlock();
@ -415,7 +405,7 @@ describe("UI - Starter select", () => {
expect(game.scene.getParty()[0].variant).toBe(1);
}, 20000);
it("Bulbasaur - shiny - variant 2", async() => {
it("Bulbasaur - shiny - variant 0", async() => {
await game.importData("src/test/utils/saves/everything.prsv");
const caughtCount = Object.keys(game.scene.gameData.dexData).filter((key) => {
const species = game.scene.gameData.dexData[key];
@ -432,8 +422,6 @@ describe("UI - Starter select", () => {
const handler = game.scene.ui.getHandler() as StarterSelectUiHandler;
handler.processInput(Button.RIGHT);
handler.processInput(Button.LEFT);
handler.processInput(Button.CYCLE_SHINY);
handler.processInput(Button.V);
handler.processInput(Button.V);
handler.processInput(Button.ACTION);
game.phaseInterceptor.unlock();
@ -474,7 +462,7 @@ describe("UI - Starter select", () => {
expect(game.scene.getParty()[0].species.speciesId).toBe(Species.BULBASAUR);
expect(game.scene.getParty()[0].shiny).toBe(true);
expect(game.scene.getParty()[0].variant).toBe(2);
expect(game.scene.getParty()[0].variant).toBe(0);
}, 20000);
it("Check if first pokemon in party is caterpie from gen 1 and 1rd row, 3rd column", async() => {

View File

@ -1853,10 +1853,14 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
switch (button) {
case Button.CYCLE_SHINY:
if (this.canCycleShiny) {
const newVariant = starterAttributes.variant ? starterAttributes.variant as Variant : props.variant;
starterAttributes.shiny = starterAttributes.shiny ? !starterAttributes.shiny : true;
this.setSpeciesDetails(this.lastSpecies, !props.shiny, undefined, undefined, props.shiny ? 0 : newVariant, undefined, undefined);
starterAttributes.shiny = starterAttributes.shiny !== undefined ? !starterAttributes.shiny : false;
if (starterAttributes.shiny) {
// Change to shiny, we need to get the proper default variant
const newProps = this.scene.gameData.getSpeciesDexAttrProps(this.lastSpecies, this.getCurrentDexProps(this.lastSpecies.speciesId));
const newVariant = starterAttributes.variant ? starterAttributes.variant as Variant : newProps.variant;
this.setSpeciesDetails(this.lastSpecies, true, undefined, undefined, newVariant, undefined, undefined);
this.scene.playSound("se/sparkle");
// Set the variant label to the shiny tint
const tint = getVariantTint(newVariant);
@ -1864,6 +1868,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
this.pokemonShinyIcon.setTint(tint);
this.pokemonShinyIcon.setVisible(true);
} else {
this.setSpeciesDetails(this.lastSpecies, false, undefined, undefined, 0, undefined, undefined);
this.pokemonShinyIcon.setVisible(false);
success = true;
}
@ -3487,23 +3492,22 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
props += DexAttr.MALE;
}
/* This part is very similar to above, but instead of for gender, it checks for shiny within starter preferences.
* If they're not there, it checks the caughtAttr for shiny only (i.e. SHINY === true && NON_SHINY === false)
* If they're not there, it enables shiny state by default if any shiny was caught
*/
if (this.starterPreferences[speciesId]?.shiny || ((caughtAttr & DexAttr.SHINY) > 0n && (caughtAttr & DexAttr.NON_SHINY) === 0n)) {
if (this.starterPreferences[speciesId]?.shiny || ((caughtAttr & DexAttr.SHINY) > 0n && this.starterPreferences[speciesId]?.shiny !== false)) {
props += DexAttr.SHINY;
if (this.starterPreferences[speciesId]?.variant) {
if (this.starterPreferences[speciesId]?.variant !== undefined) {
props += BigInt(Math.pow(2, this.starterPreferences[speciesId]?.variant)) * DexAttr.DEFAULT_VARIANT;
} else {
/* This calculates the correct variant if there's no starter preferences for it.
* This gets the lowest tier variant that you've caught (in line with other mechanics) and adds it to the temp props
* This gets the highest tier variant that you've caught and adds it to the temp props
*/
if ((caughtAttr & DexAttr.DEFAULT_VARIANT) > 0) {
props += DexAttr.DEFAULT_VARIANT;
}
if ((caughtAttr & DexAttr.VARIANT_2) > 0) {
props += DexAttr.VARIANT_2;
} else if ((caughtAttr & DexAttr.VARIANT_3) > 0) {
if ((caughtAttr & DexAttr.VARIANT_3) > 0) {
props += DexAttr.VARIANT_3;
} else if ((caughtAttr & DexAttr.VARIANT_2) > 0) {
props += DexAttr.VARIANT_2;
} else {
props += DexAttr.DEFAULT_VARIANT;
}
}
} else {