From e0401a93aa06399095fc231b6c78da8a45a60906 Mon Sep 17 00:00:00 2001 From: c4vv <132619649+c4vv@users.noreply.github.com> Date: Thu, 6 Jun 2024 10:55:50 -0400 Subject: [PATCH] [Bug] Fix generateVariant to account for forms (#1783) * Add form check to generateVaraint * Add index check * Fix for typedoc --- src/field/pokemon.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 7d8f8d8dc91..86909f056aa 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -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);