diff --git a/calc/src/mechanics/gen56.ts b/calc/src/mechanics/gen56.ts index ca24008d8..1a3ec0360 100644 --- a/calc/src/mechanics/gen56.ts +++ b/calc/src/mechanics/gen56.ts @@ -461,7 +461,7 @@ export function calculateBasePowerBWXY( break; case 'Low Kick': case 'Grass Knot': - const w = getWeight(defender, desc, true); + const w = getWeight(defender, desc, 'defender'); basePower = w >= 200 ? 120 : w >= 100 ? 100 : w >= 50 ? 80 : w >= 25 ? 60 : w >= 10 ? 40 : 20; desc.moveBP = basePower; break; @@ -472,8 +472,8 @@ export function calculateBasePowerBWXY( case 'Heavy Slam': case 'Heat Crash': const wr = - getWeight(attacker, desc, false) / - getWeight(defender, desc, true); + getWeight(attacker, desc, 'attacker') / + getWeight(defender, desc, 'defender'); basePower = wr >= 5 ? 120 : wr >= 4 ? 100 : wr >= 3 ? 80 : wr >= 2 ? 60 : 40; desc.moveBP = basePower; break; diff --git a/calc/src/mechanics/gen789.ts b/calc/src/mechanics/gen789.ts index 24f7c7fb9..958cbe983 100644 --- a/calc/src/mechanics/gen789.ts +++ b/calc/src/mechanics/gen789.ts @@ -716,7 +716,7 @@ export function calculateBasePowerSMSSSV( break; case 'Low Kick': case 'Grass Knot': - const w = getWeight(defender, desc, true); + const w = getWeight(defender, desc, 'defender'); basePower = w >= 200 ? 120 : w >= 100 ? 100 : w >= 50 ? 80 : w >= 25 ? 60 : w >= 10 ? 40 : 20; desc.moveBP = basePower; break; @@ -733,8 +733,8 @@ export function calculateBasePowerSMSSSV( case 'Heavy Slam': case 'Heat Crash': const wr = - getWeight(attacker, desc, false) / - getWeight(defender, desc, true); + getWeight(attacker, desc, 'attacker') / + getWeight(defender, desc, 'defender'); basePower = wr >= 5 ? 120 : wr >= 4 ? 100 : wr >= 3 ? 80 : wr >= 2 ? 60 : 40; desc.moveBP = basePower; break; diff --git a/calc/src/mechanics/util.ts b/calc/src/mechanics/util.ts index bce2190ea..42ad42953 100644 --- a/calc/src/mechanics/util.ts +++ b/calc/src/mechanics/util.ts @@ -552,7 +552,7 @@ export function getShellSideArmCategory(source: Pokemon, target: Pokemon): MoveC return physicalDamage > specialDamage ? 'Physical' : 'Special'; } -export function getWeight(pokemon: Pokemon, desc: RawDesc, isDefender: boolean) { +export function getWeight(pokemon: Pokemon, desc: RawDesc, role: 'defender' | 'attacker') { let factor = 1; let abilityUsed = true; @@ -560,14 +560,12 @@ export function getWeight(pokemon: Pokemon, desc: RawDesc, isDefender: boolean) else if (pokemon.hasAbility('Light Metal')) factor *= 0.5; else abilityUsed = false; if (abilityUsed) { - if (isDefender) desc.defenderAbility = pokemon.ability; - else desc.attackerAbility = pokemon.ability; + desc[`${role}Ability`] = pokemon.ability; } if (pokemon.hasItem('Float Stone')) { factor *= 0.5; - if (isDefender) desc.defenderItem = pokemon.item; - else desc.attackerItem = pokemon.item; + desc[`${role}Item`] = pokemon.item; } return Math.max(Math.trunc(factor * pokemon.weightkg * 10), 1) / 10;