Shinylock uncatchable Pokemon in endless mode (#1252)

* Shinylock uncatchable Pokemon

* Fix typos

* Pass the linter vibe check

* Remove 2 shinylock cases

* refactor
This commit is contained in:
Tempoanon 2024-05-30 16:20:27 -04:00 committed by GitHub
parent 329c9619f6
commit 3e932ce2d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 28 additions and 6 deletions

View File

@ -1222,7 +1222,22 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
}
}
/**
* Function that tries to set a Pokemon shiny based on the trainer's trainer ID and secret ID
* Endless Pokemon in the end biome are unable to be set to shiny
*
* The exact mechanic is that it calculates E as the XOR of the player's trainer ID and secret ID
* F is calculated as the XOR of the first 16 bits of the Pokemon's ID with the last 16 bits
* The XOR of E and F are then compared to the thresholdOverride (default case 32) to see whether or not to generate a shiny
* @param thresholdOverride number that is divided by 2^16 (65536) to get the shiny chance
* @returns true if the Pokemon has been set as a shiny, false otherwise
*/
trySetShiny(thresholdOverride?: integer): boolean {
// Shiny Pokemon should not spawn in the end biome in endless
if (this.scene.gameMode.isEndless && this.scene.arena.biomeType === Biome.END) {
return false;
}
const rand1 = Utils.binToDec(Utils.decToBin(this.id).substring(0, 16));
const rand2 = Utils.binToDec(Utils.decToBin(this.id).substring(16, 32));
@ -1250,18 +1265,25 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
return this.shiny;
}
/**
* Generates a variant
* Has a 10% of returning 2 (epic variant)
* And a 20% of returning 1 (rare variant)
* Returns 0 (basic shiny) if there is no variant or 70% of the time otherwise
* @returns the shiny variant
*/
generateVariant(): Variant {
if (!this.shiny || !variantData.hasOwnProperty(this.species.speciesId)) {
return 0;
}
const rand = Utils.randSeedInt(10);
if (rand > 3) {
return 0;
if (rand >= 3) {
return 0; // 7/10
} else if (rand >= 1) {
return 1; // 2/10
} else {
return 2; // 1/10
}
if (rand) {
return 1;
}
return 2;
}
generateFusionSpecies(forStarter?: boolean): void {