Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have Ring Target work on all immunities #646

Merged
merged 3 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ring Target still applies to Flying Press. eg. Flying Press Hawlucha vs Blacephalon does damage.

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
Loading