[Bug] Fix generateVariant to account for forms (#1783)

* Add form check to generateVaraint

* Add index check

* Fix for typedoc
This commit is contained in:
c4vv 2024-06-06 10:55:50 -04:00 committed by GitHub
parent 5ac1b7245f
commit e0401a93aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 1 deletions

View File

@ -1277,7 +1277,16 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
* @returns the shiny variant
*/
generateVariant(): Variant {
if (!this.shiny || !variantData.hasOwnProperty(this.species.speciesId)) {
const formIndex: number = this.formIndex;
let variantDataIndex: string | number = this.species.speciesId;
if (this.species.forms.length > 0) {
const formKey = this.species.forms[formIndex]?.formKey;
if (formKey) {
variantDataIndex = `${variantDataIndex}-${formKey}`;
}
}
// Checks if there is no variant data for both the index or index with form
if (!this.shiny || (!variantData.hasOwnProperty(variantDataIndex) && !variantData.hasOwnProperty(this.species.speciesId))) {
return 0;
}
const rand = Utils.randSeedInt(10);