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

Mold Breaker shouldn't remove abilities that don't affect direct damage #647

Merged
merged 1 commit into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 10 additions & 0 deletions calc/src/mechanics/gen4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ export function calculateDPP(
return result;
}

const tempAbility = defender.ability;

if (attacker.hasAbility('Mold Breaker')) {
defender.ability = '' as AbilityName;
desc.attackerAbility = attacker.ability;
Expand Down Expand Up @@ -196,6 +198,14 @@ export function calculateDPP(
const attack = calculateAttackDPP(gen, attacker, defender, move, field, desc, isCritical);

// #endregion

// Restores the defender's ability after disabling it for Mold Breaker purposes.
// This will make abilities like Rain Dish and Dry Skin work
// even when the attacker has Mold Breaker.
if (attacker.hasAbility('Mold Breaker')) {
defender.ability = tempAbility;
}

// #region (Special) Defense
const defense = calculateDefenseDPP(gen, attacker, defender, move, field, desc, isCritical);

Expand Down
10 changes: 10 additions & 0 deletions calc/src/mechanics/gen56.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ export function calculateBWXY(
return result;
}

const tempAbility = defender.ability;

if (attacker.hasAbility('Mold Breaker', 'Teravolt', 'Turboblaze')) {
defender.ability = '' as AbilityName;
desc.attackerAbility = attacker.ability;
Expand Down Expand Up @@ -285,6 +287,14 @@ export function calculateBWXY(
const attackStat = move.category === 'Special' ? 'spa' : 'atk';

// #endregion

// Restores the defender's ability after disabling it for Mold Breaker purposes.
// This will make abilities like Rain Dish and Dry Skin work
// even when the attacker has Mold Breaker.
if (attacker.hasAbility('Mold Breaker', 'Teravolt', 'Turboblaze')) {
defender.ability = tempAbility;
}

// #region (Special) Defense

const defense = calculateDefenseBWXY(gen, attacker, defender, move, field, desc, isCritical);
Expand Down
15 changes: 13 additions & 2 deletions calc/src/mechanics/gen789.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,10 @@ export function calculateSMSSSV(
'Searing Sunraze Smash',
'Sunsteel Strike'
);
if (!defenderIgnoresAbility && !defender.hasAbility('Poison Heal') &&
(attackerIgnoresAbility || moveIgnoresAbility)) {

const tempAbility = defender.ability;

if (!defenderIgnoresAbility && (attackerIgnoresAbility || moveIgnoresAbility)) {
if (attackerIgnoresAbility) desc.attackerAbility = attacker.ability;
if (defender.hasItem('Ability Shield')) {
desc.defenderItem = defender.item;
Expand Down Expand Up @@ -555,6 +557,15 @@ export function calculateSMSSSV(
? 'spa'
: 'atk';
// #endregion

// Restores the defender's ability after disabling it for the purposes of
// Mold Breaker and other moves that ignore abilities.
// This will make abilities like Rain Dish and Quark Drive work
// even when the attacker has Mold Breaker.
if (attackerIgnoresAbility || moveIgnoresAbility) {
defender.ability = tempAbility;
}

// #region (Special) Defense

const defense = calculateDefenseSMSSSV(gen, attacker, defender, move, field, desc, isCritical);
Expand Down
26 changes: 26 additions & 0 deletions calc/src/test/calc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,32 @@ describe('calc', () => {
'Lvl 90 Chansey Seismic Toss vs. Lvl 30 0 HP 0 IVs Mew: 90-90 (90 - 90%) -- guaranteed OHKO after sandstorm damage and burn damage'
);
});

inGens(4, 9, ({gen, calculate, Pokemon, Move, Field}) => {
test(`Mold Breaker does not disable abilities that don't affect direct damage (gen ${gen})`, () => {
const attacker = Pokemon('Rampardos', {
ability: 'Mold Breaker',
});

const defender = Pokemon('Blastoise', {
ability: 'Rain Dish',
});

const field = Field({
weather: 'Rain',
});

const move = Move('Stone Edge');

const result = calculate(attacker, defender, move, field);

expect(result.defender.ability).toBe('Rain Dish');

expect(result.desc()).toBe(
'0 Atk Mold Breaker Rampardos Stone Edge vs. 0 HP / 0 Def Blastoise: 168-198 (56.1 - 66.2%) -- guaranteed 2HKO after Rain Dish recovery'
);
});
});
});
});

Expand Down
Loading