Skip to content

Commit

Permalink
Increased accuracy of weight modifiers
Browse files Browse the repository at this point in the history
Ability and Item weight modifiers are now handled completely independently of each other
  • Loading branch information
Zrp200 committed Mar 1, 2024
1 parent 88e5537 commit eaccb91
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions calc/src/mechanics/util.ts
Expand Up @@ -553,22 +553,26 @@ export function getShellSideArmCategory(source: Pokemon, target: Pokemon): MoveC
}

export function getWeight(pokemon: Pokemon, desc: RawDesc, role: 'defender' | 'attacker') {
let factor = 1;
let weightHG = pokemon.weightkg * 10;
function modifyWeight(factor: number) {
weightHG = Math.max(Math.trunc(weightHG * factor), 1);
}

let abilityUsed = true;
if (pokemon.hasAbility('Heavy Metal')) factor *= 2;
else if (pokemon.hasAbility('Light Metal')) factor *= 0.5;
else abilityUsed = false;
if (abilityUsed) {
const abilityFactor = pokemon.hasAbility('Heavy Metal') ? 2
: pokemon.hasAbility('Light Metal') ? 0.5
: 1;
if (abilityFactor !== 1) {
modifyWeight(abilityFactor);
desc[`${role}Ability`] = pokemon.ability;
}

if (pokemon.hasItem('Float Stone')) {
factor *= 0.5;
modifyWeight(0.5);
desc[`${role}Item`] = pokemon.item;
}

return Math.max(Math.trunc(factor * pokemon.weightkg * 10), 1) / 10;
// convert back to kg
return weightHG / 10;
}

export function getStabMod(pokemon: Pokemon, move: Move, desc: RawDesc) {
Expand Down

0 comments on commit eaccb91

Please sign in to comment.