From 52c9e4717c9caf418e97c6b5b18334d20020cd6f Mon Sep 17 00:00:00 2001 From: Bertie690 Date: Mon, 18 Nov 2024 22:46:35 -0500 Subject: [PATCH] Fixed embarassing bug thing --- src/field/pokemon.ts | 9 +++++---- src/test/items/multi_lens.test.ts | 22 ++-------------------- 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 7a8f4625fe2..99de1e949ac 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -2624,13 +2624,14 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (fixedDamage.value) { const lensCount = source.getHeldItems().find(i => i instanceof PokemonMultiHitModifier)?.getStackCount() ?? 0; // Apply damage fixing for hp cutting moves on multi lens hits (NOT PARENTAL BOND) - if (move.hasAttr(TargetHalfHpDamageAttr) + if (lensCount > 0 + && move.hasAttr(TargetHalfHpDamageAttr) && (source.turnData.hitCount === source.turnData.hitsLeft || source.turnData.hitCount - source.turnData.hitsLeft !== lensCount + 1)) { // Do some unholy math to make the moves' damage values add up to 50% // Values obtained courtesy of WolframAlpha and Desmos Graphing Calculator // (https://www.desmos.com/calculator/wdngrksdfz) - let damageMulti = 0; + let damageMulti = 1; // NOTE: If multi lens ever gets updated (again) this switch case will NEED to be updated alongside it! switch (lensCount) { case 1: @@ -2639,8 +2640,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { case 2: damageMulti = 0.60875846088; break; - case 3: - damageMulti = 0.636414338985; + default: + damageMulti = 0.5; break; } diff --git a/src/test/items/multi_lens.test.ts b/src/test/items/multi_lens.test.ts index 50a858fc928..5e68d6f2450 100644 --- a/src/test/items/multi_lens.test.ts +++ b/src/test/items/multi_lens.test.ts @@ -170,26 +170,8 @@ describe("Items - Multi Lens", () => { await game.phaseInterceptor.to("MoveEndPhase"); expect(enemyPokemon.getHpRatio()).toBeCloseTo(0.5, 8); // unrealistically high level of precision }); - - it("should result in correct damage for hp% attacks with 3 lenses", async () => { - game.override.startingHeldItems([{ name: "MULTI_LENS", count: 3 }]) - .moveset(Moves.SUPER_FANG) - .ability(Abilities.COMPOUND_EYES) - .enemyMoveset(Moves.SPLASH) - .enemyLevel(100000) - .enemySpecies(Species.BLISSEY); // allows for unrealistically high levels of accuracy - - await game.classicMode.startBattle([ Species.MAGIKARP ]); - - const enemyPokemon = game.scene.getEnemyPokemon()!; - - game.move.select(Moves.SUPER_FANG); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); - await game.phaseInterceptor.to("MoveEndPhase"); - expect(enemyPokemon.getHpRatio()).toBeCloseTo(0.5, 8); - }); - it("should result in correct damage for hp% attacks with 3 lenses + Parental Bond", async () => { - game.override.startingHeldItems([{ name: "MULTI_LENS", count: 3 }, + it("should result in correct damage for hp% attacks with 2 lenses + Parental Bond", async () => { + game.override.startingHeldItems([{ name: "MULTI_LENS", count: 2 }, { name: "WIDE_LENS", count: 2 }]) // ensures move always hits .moveset(Moves.SUPER_FANG) .ability(Abilities.PARENTAL_BOND)