From 3f71f79d7bbaaf37016cb64e4ca6be439ac4b2ba Mon Sep 17 00:00:00 2001 From: Wlowscha <54003515+Wlowscha@users.noreply.github.com> Date: Mon, 3 Feb 2025 03:17:08 +0100 Subject: [PATCH] [Bug] Ensuring proper .getTypes() behavior with secondary Normal type (#5241) * customPokemonData.types now accepts Type.UNKNOWN, ignores when determining type * Changed test for clowning around encounter to look at getTypes() instead of directly accessing customData * Simplifying logic for fusions when overrides are involved, introducing new tests in pokemon.test.ts * Renamed overrideTypes to customTypes to avoid confusion with override * pokemon.getType() properly recognizes Normal secondary type * Added effectiveness test for ghost on normal --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> --- src/field/pokemon.ts | 6 +++--- src/test/field/pokemon.test.ts | 26 ++++++++++---------------- src/test/moves/effectiveness.test.ts | 4 ++++ 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 112665e1723..0458c5471d2 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -1269,7 +1269,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { types.push(firstType); // Second type - let secondType: Type | null = null; + let secondType: Type = Type.UNKNOWN; if (fusionSpeciesForm) { // Check if the fusion Pokemon also has permanent changes from ME when determining the fusion types @@ -1287,10 +1287,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } else { // If not a fusion, just get the second type from the species, checking for permanent changes from ME secondType = (customTypes && this.customPokemonData.types.length > 1 && this.customPokemonData.types[1] !== Type.UNKNOWN) - ? this.customPokemonData.types[1] : speciesForm.type2; + ? this.customPokemonData.types[1] : (speciesForm.type2 ?? Type.UNKNOWN); } - if (secondType) { + if (secondType !== Type.UNKNOWN) { types.push(secondType); } } diff --git a/src/test/field/pokemon.test.ts b/src/test/field/pokemon.test.ts index b8b7349c1f8..0a1ddac9e90 100644 --- a/src/test/field/pokemon.test.ts +++ b/src/test/field/pokemon.test.ts @@ -97,16 +97,14 @@ describe("Spec - Pokemon", () => { expect(types[0]).toBe(Type.PSYCHIC); expect(types[1]).toBe(Type.FIRE); - // Abra Psychic/Grass - pokemon.customPokemonData.types = [ Type.UNKNOWN, Type.GRASS ]; + pokemon.customPokemonData.types = [ Type.UNKNOWN, Type.NORMAL ]; types = pokemon.getTypes(); expect(types[0]).toBe(Type.PSYCHIC); expect(types[1]).toBe(Type.FIRE); - // Abra Grass - pokemon.customPokemonData.types = [ Type.GRASS, Type.UNKNOWN ]; + pokemon.customPokemonData.types = [ Type.NORMAL, Type.UNKNOWN ]; types = pokemon.getTypes(); - expect(types[0]).toBe(Type.GRASS); + expect(types[0]).toBe(Type.NORMAL); expect(types[1]).toBe(Type.FIRE); if (!pokemon.fusionCustomPokemonData) { @@ -114,24 +112,20 @@ describe("Spec - Pokemon", () => { } pokemon.customPokemonData.types = []; - // Charmander Fire/Grass - pokemon.fusionCustomPokemonData.types = [ Type.UNKNOWN, Type.GRASS ]; + pokemon.fusionCustomPokemonData.types = [ Type.UNKNOWN, Type.NORMAL ]; types = pokemon.getTypes(); expect(types[0]).toBe(Type.PSYCHIC); - expect(types[1]).toBe(Type.GRASS); + expect(types[1]).toBe(Type.NORMAL); - // Charmander Grass - pokemon.fusionCustomPokemonData.types = [ Type.GRASS, Type.UNKNOWN ]; + pokemon.fusionCustomPokemonData.types = [ Type.NORMAL, Type.UNKNOWN ]; types = pokemon.getTypes(); expect(types[0]).toBe(Type.PSYCHIC); - expect(types[1]).toBe(Type.GRASS); + expect(types[1]).toBe(Type.NORMAL); - // Abra Grass - // Charmander Fire/Grass - pokemon.customPokemonData.types = [ Type.GRASS, Type.UNKNOWN ]; - pokemon.fusionCustomPokemonData.types = [ Type.UNKNOWN, Type.GRASS ]; + pokemon.customPokemonData.types = [ Type.NORMAL, Type.UNKNOWN ]; + pokemon.fusionCustomPokemonData.types = [ Type.UNKNOWN, Type.NORMAL ]; types = pokemon.getTypes(); - expect(types[0]).toBe(Type.GRASS); + expect(types[0]).toBe(Type.NORMAL); expect(types[1]).toBe(Type.FIRE); }); diff --git a/src/test/moves/effectiveness.test.ts b/src/test/moves/effectiveness.test.ts index 7742178f595..c78416b1237 100644 --- a/src/test/moves/effectiveness.test.ts +++ b/src/test/moves/effectiveness.test.ts @@ -73,6 +73,10 @@ describe("Moves - Type Effectiveness", () => { () => testMoveEffectiveness(game, Moves.THUNDERBOLT, Species.BLASTOISE, 2) ); + it("Ghost-type attacks have no effect on Normal-type Pokemon", + () => testMoveEffectiveness(game, Moves.SHADOW_BALL, Species.URSALUNA, 0) + ); + it("Electric-type attacks are doubly super-effective against Water/Flying-type Pokemon", () => testMoveEffectiveness(game, Moves.THUNDERBOLT, Species.GYARADOS, 4) );