Skip to content

Commit

Permalink
Have Ring Target work on all immunities
Browse files Browse the repository at this point in the history
  • Loading branch information
ShivaD173 committed Sep 24, 2024
1 parent 0ff0d34 commit 1acaf80
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
14 changes: 5 additions & 9 deletions calc/src/mechanics/gen56.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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) {
Expand Down
15 changes: 10 additions & 5 deletions calc/src/mechanics/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]!;
}
}

Expand Down

0 comments on commit 1acaf80

Please sign in to comment.