pokemon.getType() properly recognizes Normal secondary type

This commit is contained in:
Wlowscha 2025-02-02 17:26:53 +01:00
parent 1fb2796d9e
commit 60ad302298
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04
2 changed files with 13 additions and 13 deletions

View File

@ -1269,7 +1269,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
types.push(firstType); types.push(firstType);
// Second type // Second type
let secondType: Type | null = null; let secondType: Type = Type.UNKNOWN;
if (fusionSpeciesForm) { if (fusionSpeciesForm) {
// Check if the fusion Pokemon also had permanently changes when determining the fusion types // Check if the fusion Pokemon also had permanently changes when determining the fusion types
@ -1287,10 +1287,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
} else { } else {
// If not a fusion, just get the second type from the species, checking for permanent changes from ME // 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) 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); types.push(secondType);
} }
} }

View File

@ -98,15 +98,15 @@ describe("Spec - Pokemon", () => {
expect(types[1]).toBe(Type.FIRE); expect(types[1]).toBe(Type.FIRE);
// Abra Psychic/Grass // Abra Psychic/Grass
pokemon.customPokemonData.types = [ Type.UNKNOWN, Type.GRASS ]; pokemon.customPokemonData.types = [ Type.UNKNOWN, Type.NORMAL ];
types = pokemon.getTypes(); types = pokemon.getTypes();
expect(types[0]).toBe(Type.PSYCHIC); expect(types[0]).toBe(Type.PSYCHIC);
expect(types[1]).toBe(Type.FIRE); expect(types[1]).toBe(Type.FIRE);
// Abra Grass // Abra Grass
pokemon.customPokemonData.types = [ Type.GRASS, Type.UNKNOWN ]; pokemon.customPokemonData.types = [ Type.NORMAL, Type.UNKNOWN ];
types = pokemon.getTypes(); types = pokemon.getTypes();
expect(types[0]).toBe(Type.GRASS); expect(types[0]).toBe(Type.NORMAL);
expect(types[1]).toBe(Type.FIRE); expect(types[1]).toBe(Type.FIRE);
if (!pokemon.fusionCustomPokemonData) { if (!pokemon.fusionCustomPokemonData) {
@ -115,23 +115,23 @@ describe("Spec - Pokemon", () => {
pokemon.customPokemonData.types = []; pokemon.customPokemonData.types = [];
// Charmander Fire/Grass // Charmander Fire/Grass
pokemon.fusionCustomPokemonData.types = [ Type.UNKNOWN, Type.GRASS ]; pokemon.fusionCustomPokemonData.types = [ Type.UNKNOWN, Type.NORMAL ];
types = pokemon.getTypes(); types = pokemon.getTypes();
expect(types[0]).toBe(Type.PSYCHIC); expect(types[0]).toBe(Type.PSYCHIC);
expect(types[1]).toBe(Type.GRASS); expect(types[1]).toBe(Type.NORMAL);
// Charmander Grass // Charmander Grass
pokemon.fusionCustomPokemonData.types = [ Type.GRASS, Type.UNKNOWN ]; pokemon.fusionCustomPokemonData.types = [ Type.NORMAL, Type.UNKNOWN ];
types = pokemon.getTypes(); types = pokemon.getTypes();
expect(types[0]).toBe(Type.PSYCHIC); expect(types[0]).toBe(Type.PSYCHIC);
expect(types[1]).toBe(Type.GRASS); expect(types[1]).toBe(Type.NORMAL);
// Abra Grass // Abra Grass
// Charmander Fire/Grass // Charmander Fire/Grass
pokemon.customPokemonData.types = [ Type.GRASS, Type.UNKNOWN ]; pokemon.customPokemonData.types = [ Type.NORMAL, Type.UNKNOWN ];
pokemon.fusionCustomPokemonData.types = [ Type.UNKNOWN, Type.GRASS ]; pokemon.fusionCustomPokemonData.types = [ Type.UNKNOWN, Type.NORMAL ];
types = pokemon.getTypes(); types = pokemon.getTypes();
expect(types[0]).toBe(Type.GRASS); expect(types[0]).toBe(Type.NORMAL);
expect(types[1]).toBe(Type.FIRE); expect(types[1]).toBe(Type.FIRE);
}); });