From 68b956cbe6d0ce3da0d55c7a6a86cdb8dca045b3 Mon Sep 17 00:00:00 2001 From: innerthunder <168692175+innerthunder@users.noreply.github.com> Date: Sun, 8 Sep 2024 20:48:09 -0700 Subject: [PATCH 1/2] [Bug] Fix incorrect defensive properties on Terastallized Pokemon (#4070) * Fix incorrect defensive properties on Terastallized Pokemon * Add tests to `effectiveness.test.ts` * Suppress errors from Tera achievement validation --- src/field/pokemon.ts | 5 +++- src/test/moves/effectiveness.test.ts | 39 +++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 863b0f41d2c..6d29e30254a 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -1049,6 +1049,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const teraType = this.getTeraType(); if (teraType !== Type.UNKNOWN) { types.push(teraType); + if (forDefend) { + return types; + } } } @@ -1368,7 +1371,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { : 1); applyMoveAttrs(VariableMoveTypeMultiplierAttr, source, this, move, typeMultiplier); - if (this.getTypes().find(t => move.isTypeImmune(source, this, t))) { + if (this.getTypes(true, true).find(t => move.isTypeImmune(source, this, t))) { typeMultiplier.value = 0; } diff --git a/src/test/moves/effectiveness.test.ts b/src/test/moves/effectiveness.test.ts index af44586b69d..d1903c79844 100644 --- a/src/test/moves/effectiveness.test.ts +++ b/src/test/moves/effectiveness.test.ts @@ -1,23 +1,32 @@ import { allMoves } from "#app/data/move"; import { getPokemonSpecies } from "#app/data/pokemon-species"; import { TrainerSlot } from "#app/data/trainer-config"; +import { Type } from "#app/data/type"; import { Abilities } from "#app/enums/abilities"; import { Moves } from "#app/enums/moves"; import { Species } from "#app/enums/species"; import * as Messages from "#app/messages"; +import { TerastallizeModifier } from "#app/modifier/modifier"; import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, describe, expect, it, vi } from "vitest"; function testMoveEffectiveness(game: GameManager, move: Moves, targetSpecies: Species, - expected: number, targetAbility: Abilities = Abilities.BALL_FETCH): void { + expected: number, targetAbility: Abilities = Abilities.BALL_FETCH, teraType?: Type): void { // Suppress getPokemonNameWithAffix because it calls on a null battle spec vi.spyOn(Messages, "getPokemonNameWithAffix").mockReturnValue(""); game.override.enemyAbility(targetAbility); + + if (teraType !== undefined) { + game.override.enemyHeldItems([{ name:"TERA_SHARD", type: teraType }]); + } + const user = game.scene.addPlayerPokemon(getPokemonSpecies(Species.SNORLAX), 5); const target = game.scene.addEnemyPokemon(getPokemonSpecies(targetSpecies), 5, TrainerSlot.NONE); expect(target.getMoveEffectiveness(user, allMoves[move])).toBe(expected); + user.destroy(); + target.destroy(); } describe("Moves - Type Effectiveness", () => { @@ -29,6 +38,8 @@ describe("Moves - Type Effectiveness", () => { type: Phaser.HEADLESS, }); game = new GameManager(phaserGame); + TerastallizeModifier.prototype.apply = (args) => true; + game.override.ability(Abilities.BALL_FETCH); }); @@ -67,4 +78,30 @@ describe("Moves - Type Effectiveness", () => { it("Electric-type attacks are negated by Volt Absorb", () => testMoveEffectiveness(game, Moves.THUNDERBOLT, Species.GYARADOS, 0, Abilities.VOLT_ABSORB) ); + + it("Electric-type attacks are super-effective against Tera-Water Pokemon", + () => testMoveEffectiveness(game, Moves.THUNDERBOLT, Species.EXCADRILL, 2, Abilities.BALL_FETCH, Type.WATER) + ); + + it("Powder moves have no effect on Grass-type Pokemon", + () => testMoveEffectiveness(game, Moves.SLEEP_POWDER, Species.AMOONGUSS, 0) + ); + + it("Powder moves have no effect on Tera-Grass Pokemon", + () => testMoveEffectiveness(game, Moves.SLEEP_POWDER, Species.SNORLAX, 0, Abilities.BALL_FETCH, Type.GRASS) + ); + + it("Prankster-boosted status moves have no effect on Dark-type Pokemon", + () => { + game.override.ability(Abilities.PRANKSTER); + testMoveEffectiveness(game, Moves.BABY_DOLL_EYES, Species.MIGHTYENA, 0); + } + ); + + it("Prankster-boosted status moves have no effect on Tera-Dark Pokemon", + () => { + game.override.ability(Abilities.PRANKSTER); + testMoveEffectiveness(game, Moves.BABY_DOLL_EYES, Species.SNORLAX, 0, Abilities.BALL_FETCH, Type.DARK); + } + ); }); From 06f98f6737ba959f2894c1dc48fbdac7e3ecf5ed Mon Sep 17 00:00:00 2001 From: "Adrian T." <68144167+torranx@users.noreply.github.com> Date: Mon, 9 Sep 2024 11:50:47 +0800 Subject: [PATCH 2/2] [Bug] Fix console error from undefined stockpilingTag (#4118) --- src/data/move.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/data/move.ts b/src/data/move.ts index 19014c0eb30..e6e7f574671 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -3472,7 +3472,7 @@ export class SpitUpPowerAttr extends VariablePowerAttr { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { const stockpilingTag = user.getTag(StockpilingTag); - if (stockpilingTag !== null && stockpilingTag.stockpiledCount > 0) { + if (stockpilingTag && stockpilingTag.stockpiledCount > 0) { const power = args[0] as Utils.IntegerHolder; power.value = this.multiplier * stockpilingTag.stockpiledCount; return true; @@ -3490,7 +3490,7 @@ export class SwallowHealAttr extends HealAttr { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { const stockpilingTag = user.getTag(StockpilingTag); - if (stockpilingTag !== null && stockpilingTag?.stockpiledCount > 0) { + if (stockpilingTag && stockpilingTag.stockpiledCount > 0) { const stockpiled = stockpilingTag.stockpiledCount; let healRatio: number;