diff --git a/calc/src/mechanics/gen56.ts b/calc/src/mechanics/gen56.ts index 9f27acd6b..bb4fc1f45 100644 --- a/calc/src/mechanics/gen56.ts +++ b/calc/src/mechanics/gen56.ts @@ -169,10 +169,13 @@ 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); + getMoveEffectiveness(gen, move, defender.types[0], isGhostRevealed, field.isGravity, + isRingTarget); const type2Effectiveness = defender.types[1] - ? getMoveEffectiveness(gen, move, defender.types[1], isGhostRevealed, field.isGravity) + ? getMoveEffectiveness(gen, move, defender.types[1], isGhostRevealed, field.isGravity, + isRingTarget) : 1; let typeEffectiveness = type1Effectiveness * type2Effectiveness; @@ -181,13 +184,6 @@ 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 61caf1ad0..64a24ed7f 100644 --- a/calc/src/mechanics/util.ts +++ b/calc/src/mechanics/util.ts @@ -140,19 +140,24 @@ export function getMoveEffectiveness( isGravity?: boolean, isRingTarget?: boolean, ) { - if ((isRingTarget || isGhostRevealed) && type === 'Ghost' && move.hasType('Normal', 'Fighting')) { + if (isGhostRevealed && type === 'Ghost' && move.hasType('Normal', 'Fighting')) { return 1; - } else if ((isRingTarget || isGravity) && type === 'Flying' && move.hasType('Ground')) { + } else if (isGravity && type === 'Flying' && move.hasType('Ground')) { return 1; } else if (move.named('Freeze-Dry') && type === 'Water') { return 2; - } else if (move.named('Flying Press')) { + } else if (!move.named('Flying Press')) { + const effectiveness = gen.types.get(toID(move.type))!.effectiveness[type]!; + if (effectiveness === 0 && isRingTarget) { + return 1; + } + return effectiveness; + } else { + // Flying Press done last so Ghost Reveal and Ring Target take precedence return ( gen.types.get('fighting' as ID)!.effectiveness[type]! * gen.types.get('flying' as ID)!.effectiveness[type]! ); - } else { - return gen.types.get(toID(move.type))!.effectiveness[type]!; } }