Skip to content

Commit

Permalink
Support Pain Split (#585)
Browse files Browse the repository at this point in the history
  • Loading branch information
ForwardFeed authored Jul 1, 2024
1 parent 3ae7983 commit 6115cc0
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 2 deletions.
8 changes: 7 additions & 1 deletion calc/src/desc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ export function getRecovery(
recovery[0] = recovery[1] = Math.round(attacker.maxHP() / 6);
}

if (move.named('Pain Split')) {
const average = Math.floor((attacker.curHP() + defender.curHP()) / 2);
recovery[0] = recovery[1] = average - attacker.curHP();
}

if (move.drain) {
const percentHealed = move.drain[0] / move.drain[1];
const max = Math.round(defender.maxHP() * percentHealed);
Expand All @@ -146,8 +151,9 @@ export function getRecovery(

const minHealthRecovered = toDisplay(notation, recovery[0], attacker.maxHP());
const maxHealthRecovered = toDisplay(notation, recovery[1], attacker.maxHP());
const change = recovery[0] > 0 ? 'recovered' : 'lost';
text = `${minHealthRecovered} - ${maxHealthRecovered}${notation} ${change}`;

text = `${minHealthRecovered} - ${maxHealthRecovered}${notation} recovered`;
return {recovery, text};
}

Expand Down
8 changes: 7 additions & 1 deletion calc/src/mechanics/gen12.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ export function calculateRBYGSC(
return result;
}

if (move.name === 'Pain Split') {
const average = Math.floor((attacker.curHP() + defender.curHP()) / 2);
const damage = Math.max(0, defender.curHP() - average);
result.damage = damage;
return result;
}

// Fixed damage moves (eg. Night Shade) ignore type effectiveness in Gen 1
if (gen.num === 1) {
const fixedDamage = handleFixedDamageMoves(attacker, move);
Expand Down Expand Up @@ -74,7 +81,6 @@ export function calculateRBYGSC(
}
}


const type1Effectiveness =
getMoveEffectiveness(gen, move, firstDefenderType, field.defenderSide.isForesight);
const type2Effectiveness = secondDefenderType
Expand Down
7 changes: 7 additions & 0 deletions calc/src/mechanics/gen3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ export function calculateADV(
return result;
}

if (move.name === 'Pain Split') {
const average = Math.floor((attacker.curHP() + defender.curHP()) / 2);
const damage = Math.max(0, defender.curHP() - average);
result.damage = damage;
return result;
}

if (move.named('Weather Ball')) {
move.type =
field.hasWeather('Sun') ? 'Fire'
Expand Down
7 changes: 7 additions & 0 deletions calc/src/mechanics/gen4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ export function calculateDPP(
return result;
}

if (move.name === 'Pain Split') {
const average = Math.floor((attacker.curHP() + defender.curHP()) / 2);
const damage = Math.max(0, defender.curHP() - average);
result.damage = damage;
return result;
}

if (attacker.hasAbility('Mold Breaker')) {
defender.ability = '' as AbilityName;
desc.attackerAbility = attacker.ability;
Expand Down
7 changes: 7 additions & 0 deletions calc/src/mechanics/gen56.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ export function calculateBWXY(
return result;
}

if (move.name === 'Pain Split') {
const average = Math.floor((attacker.curHP() + defender.curHP()) / 2);
const damage = Math.max(0, defender.curHP() - average);
result.damage = damage;
return result;
}

if (attacker.hasAbility('Mold Breaker', 'Teravolt', 'Turboblaze')) {
defender.ability = '' as AbilityName;
desc.attackerAbility = attacker.ability;
Expand Down
7 changes: 7 additions & 0 deletions calc/src/mechanics/gen789.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ export function calculateSMSSSV(
return result;
}

if (move.name === 'Pain Split') {
const average = Math.floor((attacker.curHP() + defender.curHP()) / 2);
const damage = Math.max(0, defender.curHP() - average);
result.damage = damage;
return result;
}

const defenderIgnoresAbility = defender.hasAbility(
'Full Metal Body',
'Prism Armor',
Expand Down

0 comments on commit 6115cc0

Please sign in to comment.