Skip to content

Commit

Permalink
Implement Psychic Noise's secondary effect (smogon#679)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zrp200 authored Jan 16, 2025
1 parent 8338028 commit 5c410b8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
32 changes: 23 additions & 9 deletions calc/src/desc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -574,13 +574,23 @@ function getEndOfTurn(
}

const loseItem = move.named('Knock Off') && !defender.hasAbility('Sticky Hold');
if (defender.hasItem('Leftovers') && !loseItem) {
// psychic noise should suppress all recovery effects
const healBlock = move.named('Psychic Noise') &&
!(
// suppression conditions
attacker.hasAbility('Sheer Force') ||
defender.hasItem('Covert Cloak') ||
defender.hasAbility('Shield Dust', 'Aroma Veil')
);
if (defender.hasItem('Leftovers') && !loseItem && !healBlock) {
damage += Math.floor(defender.maxHP() / 16);
texts.push('Leftovers recovery');
} else if (defender.hasItem('Black Sludge') && !loseItem) {
if (defender.hasType('Poison')) {
damage += Math.floor(defender.maxHP() / 16);
texts.push('Black Sludge recovery');
if (!healBlock) {
damage += Math.floor(defender.maxHP() / 16);
texts.push('Black Sludge recovery');
}
} else if (!defender.hasAbility('Magic Guard', 'Klutz')) {
damage -= Math.floor(defender.maxHP() / 8);
texts.push('Black Sludge damage');
Expand All @@ -604,31 +614,35 @@ function getEndOfTurn(
if (attacker.hasAbility('Liquid Ooze')) {
damage -= recovery;
texts.push('Liquid Ooze damage');
} else {
} else if (!healBlock) {
damage += recovery;
texts.push('Leech Seed recovery');
}
}

if (field.hasTerrain('Grassy')) {
if (isGrounded(defender, field)) {
if (isGrounded(defender, field) && !healBlock) {
damage += Math.floor(defender.maxHP() / 16);
texts.push('Grassy Terrain recovery');
}
}

if (defender.hasStatus('psn')) {
if (defender.hasAbility('Poison Heal')) {
damage += Math.floor(defender.maxHP() / 8);
texts.push('Poison Heal');
if (!healBlock) {
damage += Math.floor(defender.maxHP() / 8);
texts.push('Poison Heal');
}
} else if (!defender.hasAbility('Magic Guard')) {
damage -= Math.floor(defender.maxHP() / (gen.num === 1 ? 16 : 8));
texts.push('poison damage');
}
} else if (defender.hasStatus('tox')) {
if (defender.hasAbility('Poison Heal')) {
damage += Math.floor(defender.maxHP() / 8);
texts.push('Poison Heal');
if (!healBlock) {
damage += Math.floor(defender.maxHP() / 8);
texts.push('Poison Heal');
}
} else if (!defender.hasAbility('Magic Guard')) {
texts.push('toxic damage');
}
Expand Down
6 changes: 6 additions & 0 deletions calc/src/test/calc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1434,6 +1434,12 @@ describe('calc', () => {
result = calculate(attacker, defender, Move('Revelation Dance'));
expect(result.move.type).toBe('Water');
});
test('Psychic Noise should disable healing effects', () => {
const attacker = Pokemon('Mewtwo');
const defender = Pokemon('Regigigas', {ability: 'Poison Heal', item: 'Leftovers', status: 'tox'});
const result = calculate(attacker, defender, Move('Psychic Noise'), Field({terrain: 'Grassy', attackerSide: {isSeeded: true}}));
expect(result.desc()).toBe('0 SpA Mewtwo Psychic Noise vs. 0 HP / 0 SpD Regigigas: 109-129 (30.1 - 35.7%) -- 31.2% chance to 3HKO');
});

test('Flower Gift, Power Spot, Battery, and switching boosts shouldn\'t have double spaces', () => {
const attacker = Pokemon('Weavile');
Expand Down

0 comments on commit 5c410b8

Please sign in to comment.