From c79daed18ec16efb5dc0033cd9d57a975480ff67 Mon Sep 17 00:00:00 2001 From: frutescens Date: Thu, 26 Sep 2024 21:42:14 -0700 Subject: [PATCH] Initial Commit --- src/data/move.ts | 20 ++++++++++++++++---- src/test/moves/forests_curse.test.ts | 0 src/test/moves/trick_or_treat.test.ts | 0 3 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 src/test/moves/forests_curse.test.ts create mode 100644 src/test/moves/trick_or_treat.test.ts diff --git a/src/data/move.ts b/src/data/move.ts index 089af9bb7c1..1e9cd295489 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -5449,11 +5449,23 @@ export class AddTypeAttr extends MoveEffectAttr { } apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { - const types = target.getTypes().slice(0, 2).filter(t => t !== Type.UNKNOWN); // TODO: Figure out some way to actually check if another version of this effect is already applied - if (this.type !== Type.UNKNOWN) { - types.push(this.type); + const targetSpecies = target.getSpeciesForm(); + const originalTypes : Type[] = [targetSpecies.type1]; + if (targetSpecies.type2) { + originalTypes.push(targetSpecies.type2); } - target.summonData.types = types; + // the way we know that the types have been changed is if the original types conflicts with the current types + const currentTypes = target.getTypes(); // TODO: Figure out some way to actually check if another version of this effect is already applied + const addedTypeIndex = currentTypes.findIndex((t, i) => t !== originalTypes[i] && i >= 0); + if (this.type !== Type.UNKNOWN) { + if (originalTypes.length === currentTypes.length && addedTypeIndex <= 0) { + currentTypes.push(this.type); + } else { + const addedTypeIndex = currentTypes.findIndex((t, i) => t !== originalTypes[i]); + currentTypes[addedTypeIndex] = this.type; + } + } + target.summonData.types = currentTypes; target.updateInfo(); user.scene.queueMessage(i18next.t("moveTriggers:addType", {typeName: i18next.t(`pokemonInfo:Type.${Type[this.type]}`), pokemonName: getPokemonNameWithAffix(target)})); diff --git a/src/test/moves/forests_curse.test.ts b/src/test/moves/forests_curse.test.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/test/moves/trick_or_treat.test.ts b/src/test/moves/trick_or_treat.test.ts new file mode 100644 index 00000000000..e69de29bb2d