From 10429ec01f971d30709326fb90b5e43dd381f9e2 Mon Sep 17 00:00:00 2001 From: Shriansh Chari <30420527+shrianshChari@users.noreply.github.com> Date: Thu, 13 Jul 2023 00:34:04 -0700 Subject: [PATCH 1/2] Gen 4: Fix Klutz not dropping Speed from Iron Ball --- calc/src/mechanics/gen4.ts | 5 +++-- calc/src/mechanics/util.ts | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/calc/src/mechanics/gen4.ts b/calc/src/mechanics/gen4.ts index 59c1aac9d..b84a4da30 100644 --- a/calc/src/mechanics/gen4.ts +++ b/calc/src/mechanics/gen4.ts @@ -144,8 +144,9 @@ export function calculateDPP( let typeEffectiveness = type1Effectiveness * type2Effectiveness; - // Iron Ball ignores Klutz in generation 4 - if (typeEffectiveness === 0 && move.hasType('Ground') && defender.hasItem('Iron Ball')) { + // Klutz doesn't let Iron Ball ground in generation 4 + if (typeEffectiveness === 0 && move.hasType('Ground') && + (defender.hasItem('Iron Ball') && defender.ability! !== 'Klutz')) { if (type1Effectiveness === 0) { type1Effectiveness = 1; } else if (defender.types[1] && type2Effectiveness === 0) { diff --git a/calc/src/mechanics/util.ts b/calc/src/mechanics/util.ts index 7ff91b9c7..cad795610 100644 --- a/calc/src/mechanics/util.ts +++ b/calc/src/mechanics/util.ts @@ -190,9 +190,11 @@ export function checkForecast(pokemon: Pokemon, weather?: Weather) { } export function checkItem(pokemon: Pokemon, magicRoomActive?: boolean) { + // Pokemon with Klutz still get their speed dropped in generation 4 + if (pokemon.gen.num === 4 && pokemon.item! === 'Iron Ball') return; if ( pokemon.hasAbility('Klutz') && !EV_ITEMS.includes(pokemon.item!) || - magicRoomActive + magicRoomActive ) { pokemon.item = '' as ItemName; } From 5c594f34d63a8b2176f85cbbce927ab65902a551 Mon Sep 17 00:00:00 2001 From: Shriansh Chari <30420527+shrianshChari@users.noreply.github.com> Date: Sat, 7 Oct 2023 12:15:36 -0400 Subject: [PATCH 2/2] Use methods of Pokemon instead of equality checks --- calc/src/mechanics/gen4.ts | 2 +- calc/src/mechanics/util.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/calc/src/mechanics/gen4.ts b/calc/src/mechanics/gen4.ts index b84a4da30..656ef34b5 100644 --- a/calc/src/mechanics/gen4.ts +++ b/calc/src/mechanics/gen4.ts @@ -146,7 +146,7 @@ export function calculateDPP( // Klutz doesn't let Iron Ball ground in generation 4 if (typeEffectiveness === 0 && move.hasType('Ground') && - (defender.hasItem('Iron Ball') && defender.ability! !== 'Klutz')) { + (defender.hasItem('Iron Ball') && !defender.hasAbility('Klutz'))) { if (type1Effectiveness === 0) { type1Effectiveness = 1; } else if (defender.types[1] && type2Effectiveness === 0) { diff --git a/calc/src/mechanics/util.ts b/calc/src/mechanics/util.ts index cad795610..e707d60b0 100644 --- a/calc/src/mechanics/util.ts +++ b/calc/src/mechanics/util.ts @@ -191,7 +191,7 @@ export function checkForecast(pokemon: Pokemon, weather?: Weather) { export function checkItem(pokemon: Pokemon, magicRoomActive?: boolean) { // Pokemon with Klutz still get their speed dropped in generation 4 - if (pokemon.gen.num === 4 && pokemon.item! === 'Iron Ball') return; + if (pokemon.gen.num === 4 && pokemon.hasItem('Iron Ball')) return; if ( pokemon.hasAbility('Klutz') && !EV_ITEMS.includes(pokemon.item!) || magicRoomActive