From c87dd20386fcdf199146665cb5009b337ac2d883 Mon Sep 17 00:00:00 2001 From: ViZarSmogon Date: Mon, 16 Dec 2024 12:36:42 +0100 Subject: [PATCH] Revert "Ring Target works on all immunities (#646)" This reverts commit 8158a0abe05959d16651d85107b4b96a01c920c6. --- calc/src/mechanics/gen56.ts | 14 ++++++---- calc/src/mechanics/util.ts | 19 ++++++------- calc/src/test/calc.test.ts | 54 ------------------------------------- 3 files changed, 17 insertions(+), 70 deletions(-) diff --git a/calc/src/mechanics/gen56.ts b/calc/src/mechanics/gen56.ts index 8000d4823..622ed034e 100644 --- a/calc/src/mechanics/gen56.ts +++ b/calc/src/mechanics/gen56.ts @@ -191,13 +191,10 @@ export function calculateBWXY( } const isGhostRevealed = attacker.hasAbility('Scrappy') || field.defenderSide.isForesight; - const isRingTarget = defender.hasItem('Ring Target') && !defender.hasAbility('Klutz'); const type1Effectiveness = - getMoveEffectiveness(gen, move, defender.types[0], isGhostRevealed, field.isGravity, - isRingTarget); + getMoveEffectiveness(gen, move, defender.types[0], isGhostRevealed, field.isGravity); const type2Effectiveness = defender.types[1] - ? getMoveEffectiveness(gen, move, defender.types[1], isGhostRevealed, field.isGravity, - isRingTarget) + ? getMoveEffectiveness(gen, move, defender.types[1], isGhostRevealed, field.isGravity) : 1; let typeEffectiveness = type1Effectiveness * type2Effectiveness; @@ -206,6 +203,13 @@ export function calculateBWXY( } else if (typeEffectiveness === 0 && move.hasType('Ground') && defender.hasItem('Iron Ball') && !defender.hasAbility('Klutz')) { typeEffectiveness = 1; + } else if (typeEffectiveness === 0 && defender.hasItem('Ring Target')) { + const effectiveness = gen.types.get(toID(move.type))!.effectiveness; + if (effectiveness[defender.types[0]]! === 0) { + typeEffectiveness = type2Effectiveness; + } else if (defender.types[1] && effectiveness[defender.types[1]]! === 0) { + typeEffectiveness = type1Effectiveness; + } } if (typeEffectiveness === 0) { diff --git a/calc/src/mechanics/util.ts b/calc/src/mechanics/util.ts index d8fe1bc78..14e4b2600 100644 --- a/calc/src/mechanics/util.ts +++ b/calc/src/mechanics/util.ts @@ -140,22 +140,19 @@ export function getMoveEffectiveness( isGravity?: boolean, isRingTarget?: boolean, ) { - if (isGhostRevealed && type === 'Ghost' && move.hasType('Normal', 'Fighting')) { + if ((isRingTarget || isGhostRevealed) && type === 'Ghost' && move.hasType('Normal', 'Fighting')) { return 1; - } else if (isGravity && type === 'Flying' && move.hasType('Ground')) { + } else if ((isRingTarget || isGravity) && type === 'Flying' && move.hasType('Ground')) { return 1; } else if (move.named('Freeze-Dry') && type === 'Water') { return 2; + } else if (move.named('Flying Press')) { + return ( + gen.types.get('fighting' as ID)!.effectiveness[type]! * + gen.types.get('flying' as ID)!.effectiveness[type]! + ); } else { - let effectiveness = gen.types.get(toID(move.type))!.effectiveness[type]!; - if (effectiveness === 0 && isRingTarget) { - effectiveness = 1; - } - if (move.named('Flying Press')) { - // Can only do this because flying has no other interactions - effectiveness *= gen.types.get('flying' as ID)!.effectiveness[type]!; - } - return effectiveness; + return gen.types.get(toID(move.type))!.effectiveness[type]!; } } diff --git a/calc/src/test/calc.test.ts b/calc/src/test/calc.test.ts index 16efa7235..8524d47ae 100644 --- a/calc/src/test/calc.test.ts +++ b/calc/src/test/calc.test.ts @@ -198,43 +198,6 @@ describe('calc', () => { }); }); - inGens(6, 9, ({gen, calculate, Pokemon, Move}) => { - test(`Flying Press (gen ${gen})`, () => { - const attacker = Pokemon('Hawlucha'); - const flyingPress = Move('Flying Press'); - // Test it is 4x dmg if weak to flying and fighting - const result = calculate(attacker, Pokemon('Cacturne'), flyingPress); - if (gen === 6) { - expect(result.range()).toEqual([484, 576]); - expect(result.desc()).toBe( - '0 Atk Hawlucha Flying Press vs. 0 HP / 0 Def Cacturne: 484-576 (172.2 - 204.9%) -- guaranteed OHKO' - ); - } else { - expect(result.range()).toEqual([612, 720]); - expect(result.desc()).toBe( - '0 Atk Hawlucha Flying Press vs. 0 HP / 0 Def Cacturne: 612-720 (217.7 - 256.2%) -- guaranteed OHKO' - ); - } - - // Test still maintains fighting immunities - const result2 = calculate(attacker, Pokemon('Spiritomb'), flyingPress); - expect(result2.range()).toEqual([0, 0]); - - // Test fighting immunities can be overridden - const scrappyAttacker = Pokemon('Hawlucha', {'ability': 'Scrappy'}); - const ringTargetSpiritomb = Pokemon('Spiritomb', {'item': 'Ring Target'}); - const result3 = calculate(attacker, ringTargetSpiritomb, flyingPress); - const result4 = calculate(scrappyAttacker, Pokemon('Spiritomb'), flyingPress); - if (gen === 6) { - expect(result3.range()).toEqual([152, 180]); - expect(result4.range()).toEqual([152, 180]); - } else { - expect(result3.range()).toEqual([188, 224]); - expect(result4.range()).toEqual([188, 224]); - } - }); - }); - inGens(6, 9, ({gen, calculate, Pokemon, Move}) => { test(`Thousand Arrows and Ring Target Should negate damage nullfiers (gen ${gen})`, () => { const result = calculate(Pokemon('Zygarde'), Pokemon('Swellow'), Move('Thousand Arrows')); @@ -245,23 +208,6 @@ describe('calc', () => { }); }); - inGens(5, 9, ({gen, calculate, Pokemon, Move}) => { - test(`Ring Target should negate type nullfiers (gen ${gen})`, () => { - const attacker = Pokemon('Mew'); - const defender = Pokemon('Skarmory', {'item': 'Ring Target'}); - const result = calculate(attacker, defender, Move('Sludge Bomb')); - expect(result.range()).toEqual([87, 103]); - expect(result.desc()).toBe( - '0 SpA Mew Sludge Bomb vs. 0 HP / 0 SpD Skarmory: 87-103 (32.1 - 38%) -- 94.6% chance to 3HKO' - ); - const result2 = calculate(attacker, defender, Move('Earth Power')); - expect(result2.range()).toEqual([174, 206]); - expect(result2.desc()).toBe( - '0 SpA Mew Earth Power vs. 0 HP / 0 SpD Skarmory: 174-206 (64.2 - 76%) -- guaranteed 2HKO' - ); - }); - }); - describe('IVs are shown if applicable', () => { inGens(3, 9, ({gen, calculate, Pokemon, Move}) => { test(`Gen ${gen}`, () => {