Skip to content

Commit

Permalink
Fix White Herb interaction with Grim Neigh
Browse files Browse the repository at this point in the history
  • Loading branch information
andrebastosdias committed Feb 12, 2025
1 parent a02650e commit b8c8f3f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 20 deletions.
54 changes: 35 additions & 19 deletions data/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3816,16 +3816,16 @@ export const Items: import('../sim/dex-items').ItemDataTable = {
},
onAnySwitchInPriority: -3,
onAnySwitchIn() {
if (!this.effectState.ready || !this.effectState.boosts) return;
if (!this.effectState.ready) return;
(this.effectState.target as Pokemon).useItem();
},
onAnyAfterMove() {
if (!this.effectState.ready || !this.effectState.boosts) return;
if (!this.effectState.ready) return;
(this.effectState.target as Pokemon).useItem();
},
onResidualOrder: 29,
onResidual(pokemon) {
if (!this.effectState.ready || !this.effectState.boosts) return;
if (!this.effectState.ready) return;
(this.effectState.target as Pokemon).useItem();
},
onUse(pokemon) {
Expand Down Expand Up @@ -7191,27 +7191,43 @@ export const Items: import('../sim/dex-items').ItemDataTable = {
}
},
},
onAnySwitchInPriority: -2,
onAnySwitchIn() {
((this.effect as any).onUpdate as (p: Pokemon) => void).call(this, this.effectState.target);
},
onStart(pokemon) {
((this.effect as any).onUpdate as (p: Pokemon) => void).call(this, pokemon);
},
onUpdate(pokemon) {
let activate = false;
const boosts: SparseBoostsTable = {};
onAfterBoost(boost, pokemon) {
delete this.effectState.ready;
this.effectState.boosts = {} as SparseBoostsTable;
let i: BoostID;
for (i in pokemon.boosts) {
if (pokemon.boosts[i] < 0) {
activate = true;
boosts[i] = 0;
this.effectState.ready = true;
this.effectState.boosts[i] = 0;
}
}
if (activate && pokemon.useItem()) {
pokemon.setBoost(boosts);
this.add('-clearnegativeboost', pokemon, '[silent]');
}
},
onStart(pokemon) {
((this.effect as any).onAfterBoost as (b: SparseBoostsTable, p: Pokemon) => void).call(this, pokemon.boosts, pokemon);
if (!this.effectState.ready) return;
(this.effectState.target as Pokemon).useItem();
},
onAnySwitchInPriority: -2,
onAnySwitchIn() {
if (!this.effectState.ready) return;
(this.effectState.target as Pokemon).useItem();
},
onAnyAfterMove() {
if (!this.effectState.ready) return;
(this.effectState.target as Pokemon).useItem();
},
onResidualOrder: 29,
onResidual(pokemon) {
if (!this.effectState.ready) return;
(this.effectState.target as Pokemon).useItem();
},
onUse(pokemon) {
pokemon.setBoost(this.effectState.boosts);
this.add('-clearnegativeboost', pokemon, '[silent]');
},
onEnd() {
delete this.effectState.boosts;
delete this.effectState.ready;
},
num: 214,
gen: 3,
Expand Down
2 changes: 1 addition & 1 deletion test/sim/items/whiteherb.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe("White Herb", function () {
assert.statStage(wynaut, 'spa', 0);
});

it.skip('should activate after Abilities that boost stats on KOs', function () {
it('should activate after Abilities that boost stats on KOs', function () {
battle = common.createBattle([[
{species: 'litten', level: 1, ability: 'noguard', moves: ['sleeptalk']},
{species: 'torracat', moves: ['partingshot']},
Expand Down

0 comments on commit b8c8f3f

Please sign in to comment.