Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement White Herb and Eject Pack like Mirror Herb #10890

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 67 additions & 32 deletions data/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1571,25 +1571,44 @@ export const Items: import('../sim/dex-items').ItemDataTable = {
fling: {
basePower: 50,
},
onAfterBoost(boost, target, source, effect) {
if (this.activeMove?.id === 'partingshot') return;
let eject = false;
onAfterBoost(boost, pokemon) {
if (this.effectState.eject || this.activeMove?.id === 'partingshot') return;
let i: BoostID;
for (i in boost) {
if (boost[i]! < 0) {
eject = true;
this.effectState.eject = true;
break;
}
}
if (eject) {
if (target.hp) {
if (!this.canSwitch(target.side)) return;
if (target.volatiles['commanding'] || target.volatiles['commanded']) return;
for (const pokemon of this.getAllActive()) {
if (pokemon.switchFlag === true) return;
}
if (target.useItem()) target.switchFlag = true;
}
},
onAnySwitchInPriority: -4,
onAnySwitchIn() {
if (!this.effectState.eject) return;
(this.effectState.target as Pokemon).useItem();
},
onAnyAfterMove() {
if (!this.effectState.eject) return;
(this.effectState.target as Pokemon).useItem();
},
onResidualOrder: 29,
onResidual(pokemon) {
if (!this.effectState.eject) return;
(this.effectState.target as Pokemon).useItem();
},
onUseItem(item, pokemon) {
if (!this.canSwitch(pokemon.side)) return false;
if (pokemon.volatiles['commanding'] || pokemon.volatiles['commanded']) return false;
for (const active of this.getAllActive()) {
if (active.switchFlag === true) return false;
}
return true;
},
onUse(pokemon) {
pokemon.switchFlag = true;
},
onEnd() {
delete this.effectState.boosts;
delete this.effectState.ready;
},
num: 1119,
gen: 8,
Expand Down Expand Up @@ -3816,16 +3835,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 +7210,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/abilities/commander.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ describe('Commander', () => {
assert.equal(battle.requestState, 'move', 'It should not have switched out on standard phazing moves');
});

it.skip(`should prevent Eject Pack switchouts`, () => {
it(`should prevent Eject Pack switchouts`, () => {
battle = common.createBattle({ gameType: 'doubles' }, [[
{ species: 'wynaut', item: 'redcard', ability: 'noguard', moves: ['sleeptalk', 'tackle', 'dragontail'] },
{ species: 'gyarados', item: 'ejectbutton', ability: 'intimidate', moves: ['sleeptalk', 'trick', 'roar'] },
Expand Down
6 changes: 3 additions & 3 deletions test/sim/items/ejectpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe(`Eject Pack`, () => {
assert.false.equal(battle.requestState, 'switch');
});

it.skip(`should wait until after all other end-turn effects have resolved before switching out the holder`, () => {
it(`should wait until after all other end-turn effects have resolved before switching out the holder`, () => {
battle = common.createBattle([[
{ species: 'Glalie', item: 'ejectpack', ability: 'moody', moves: ['icebeam'] },
{ species: 'Wynaut', moves: ['sleeptalk'] },
Expand All @@ -96,7 +96,7 @@ describe(`Eject Pack`, () => {
assert(powerConstructIndex < ejectPackIndex, 'Eject Pack should not activate before Power Construct');
});

it.skip(`should not activate when another switching effect was triggered as part of the move`, () => {
it(`should not activate when another switching effect was triggered as part of the move`, () => {
battle = common.createBattle({ gameType: 'doubles' }, [[
{ species: 'Hydreigon', moves: ['breakingswipe'] },
{ species: 'Horsea', moves: ['sleeptalk'] },
Expand All @@ -112,7 +112,7 @@ describe(`Eject Pack`, () => {
assert.species(battle.p2.active[1], 'Wynaut', `Mew should have switched out with its Eject Button.`);
});

it.skip(`should only trigger the fastest Eject Pack when multiple targets with Eject Pack have stats lowered`, () => {
it(`should only trigger the fastest Eject Pack when multiple targets with Eject Pack have stats lowered`, () => {
battle = common.createBattle({ gameType: 'doubles' }, [[
{ species: 'Hydreigon', moves: ['leer'] },
{ species: 'Horsea', moves: ['sleeptalk'] },
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", () => {
assert.statStage(wynaut, 'spa', 0);
});

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