Skip to content

Commit

Permalink
Hardcode Mold Breaker ignore list (#656)
Browse files Browse the repository at this point in the history
  • Loading branch information
shrianshChari authored Oct 23, 2024
1 parent f0ebaff commit c6a5b83
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 37 deletions.
23 changes: 14 additions & 9 deletions calc/src/mechanics/gen4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,21 @@ export function calculateDPP(
return result;
}

const tempAbility = defender.ability;
const defenderAbilityIgnored = defender.hasAbility(
'Battle Armor', 'Clear Body', 'Damp', 'Dry Skin',
'Filter', 'Flash Fire', 'Flower Gift', 'Heatproof',
'Hyper Cutter', 'Immunity', 'Inner Focus', 'Insomnia',
'Keen Eye', 'Leaf Guard', 'Levitate', 'Lightning Rod',
'Limber', 'Magma Armor', 'Marvel Scale', 'Motor Drive',
'Oblivious', 'Own Tempo', 'Sand Veil', 'Shell Armor',
'Shield Dust', 'Simple', 'Snow Cloak', 'Solid Rock',
'Soundproof', 'Sticky Hold', 'Storm Drain', 'Sturdy',
'Suction Cups', 'Tangled Feet', 'Thick Fat', 'Unaware',
'Vital Spirit', 'Volt Absorb', 'Water Absorb', 'Water Veil',
'White Smoke', 'Wonder Guard'
);

if (attacker.hasAbility('Mold Breaker')) {
if (attacker.hasAbility('Mold Breaker') && defenderAbilityIgnored) {
defender.ability = '' as AbilityName;
desc.attackerAbility = attacker.ability;
}
Expand Down Expand Up @@ -202,13 +214,6 @@ export function calculateDPP(

// #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
28 changes: 19 additions & 9 deletions calc/src/mechanics/gen56.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,26 @@ export function calculateBWXY(
return result;
}

const tempAbility = defender.ability;
const defenderAbilityIgnored = defender.hasAbility(
'Aroma Veil', 'Aura Break', 'Battle Armor', 'Big Pecks',
'Bulletproof', 'Clear Body', 'Contrary', 'Damp',
'Dark Aura', 'Dry Skin', 'Fairy Aura', 'Filter',
'Flash Fire', 'Flower Gift', 'Flower Veil', 'Friend Guard',
'Fur Coat', 'Grass Pelt', 'Heatproof', 'Heavy Metal',
'Hyper Cutter', 'Immunity', 'Inner Focus', 'Insomnia',
'Keen Eye', 'Leaf Guard', 'Levitate', 'Light Metal',
'Lightning Rod', 'Limber', 'Magic Bounce', 'Magma Armor',
'Marvel Scale', 'Motor Drive', 'Multiscale', 'Oblivious',
'Overcoat', 'Own Tempo', 'Sand Veil', 'Sap Sipper',
'Shell Armor', 'Shield Dust', 'Simple', 'Snow Cloak',
'Solid Rock', 'Soundproof', 'Sticky Hold', 'Storm Drain',
'Sturdy', 'Suction Cups', 'Sweet Veil', 'Tangled Feet',
'Telepathy', 'Thick Fat', 'Unaware', 'Vital Spirit',
'Volt Absorb', 'Water Absorb', 'Water Veil', 'White Smoke',
'Wonder Guard', 'Wonder Skin'
);

if (attacker.hasAbility('Mold Breaker', 'Teravolt', 'Turboblaze')) {
if (attacker.hasAbility('Mold Breaker', 'Teravolt', 'Turboblaze') && defenderAbilityIgnored) {
defender.ability = '' as AbilityName;
desc.attackerAbility = attacker.ability;
}
Expand Down Expand Up @@ -291,13 +308,6 @@ export function calculateBWXY(

// #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
40 changes: 23 additions & 17 deletions calc/src/mechanics/gen789.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,28 @@ export function calculateSMSSSV(
return result;
}

const defenderIgnoresAbility = defender.hasAbility(
'Full Metal Body',
'Prism Armor',
'Shadow Shield',
'Tablets of Ruin',
'Vessel of Ruin'
const defenderAbilityIgnored = defender.hasAbility(
'Armor Tail', 'Aroma Veil', 'Aura Break', 'Battle Armor',
'Big Pecks', 'Bulletproof', 'Clear Body', 'Contrary',
'Damp', 'Dazzling', 'Disguise', 'Dry Skin',
'Earth Eater', 'Filter', 'Flash Fire', 'Flower Gift',
'Flower Veil', 'Fluffy', 'Friend Guard', 'Fur Coat',
'Good as Gold', 'Grass Pelt', 'Guard Dog', 'Heatproof',
'Heavy Metal', 'Hyper Cutter', 'Ice Face', 'Ice Scales',
'Illuminate', 'Immunity', 'Inner Focus', 'Insomnia',
'Keen Eye', 'Leaf Guard', 'Levitate', 'Light Metal',
'Lightning Rod', 'Limber', 'Magic Bounce', 'Magma Armor',
'Marvel Scale', "Mind's Eye", 'Mirror Armor', 'Motor Drive',
'Multiscale', 'Oblivious', 'Overcoat', 'Own Tempo',
'Pastel Veil', 'Punk Rock', 'Purifying Salt', 'Queenly Majesty',
'Sand Veil', 'Sap Sipper', 'Shell Armor', 'Shield Dust',
'Simple', 'Snow Cloak', 'Solid Rock', 'Soundproof',
'Sticky Hold', 'Storm Drain', 'Sturdy', 'Suction Cups',
'Sweet Veil', 'Tangled Feet', 'Telepathy', 'Tera Shell',
'Thermal Exchange', 'Thick Fat', 'Unaware', 'Vital Spirit',
'Volt Absorb', 'Water Absorb', 'Water Bubble', 'Water Veil',
'Well-Baked Body', 'White Smoke', 'Wind Rider', 'Wonder Guard',
'Wonder Skin'
);

const attackerIgnoresAbility = attacker.hasAbility('Mold Breaker', 'Teravolt', 'Turboblaze');
Expand All @@ -170,9 +186,7 @@ export function calculateSMSSSV(
'Sunsteel Strike'
);

const tempAbility = defender.ability;

if (!defenderIgnoresAbility && (attackerIgnoresAbility || moveIgnoresAbility)) {
if (defenderAbilityIgnored && (attackerIgnoresAbility || moveIgnoresAbility)) {
if (attackerIgnoresAbility) desc.attackerAbility = attacker.ability;
if (defender.hasItem('Ability Shield')) {
desc.defenderItem = defender.item;
Expand Down Expand Up @@ -574,14 +588,6 @@ export function calculateSMSSSV(
: '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
4 changes: 2 additions & 2 deletions calc/src/test/calc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ describe('calc', () => {
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'
'0 Atk Rampardos Stone Edge vs. 0 HP / 0 Def Blastoise: 168-198 (56.1 - 66.2%) -- guaranteed 2HKO after Rain Dish recovery'
);
});
});
Expand Down Expand Up @@ -1251,7 +1251,7 @@ describe('calc', () => {
const knockoff = Move('Knock Off');
const result = calculate(sawk, silvally, knockoff);
expect(result.desc()).toBe(
'252 Atk Mold Breaker Sawk Knock Off vs. 0 HP / 0 Def Silvally-Dark: 36-43 (10.8 - 12.9%) -- possible 8HKO'
'252 Atk Sawk Knock Off vs. 0 HP / 0 Def Silvally-Dark: 36-43 (10.8 - 12.9%) -- possible 8HKO'
);
});

Expand Down

0 comments on commit c6a5b83

Please sign in to comment.