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

Add AfterMoveSecondaryLast event #10899

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion data/abilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3156,7 +3156,7 @@ export const Abilities: import('../sim/dex-abilities').AbilityDataTable = {
num: 253,
},
pickpocket: {
onAfterMoveSecondary(target, source, move) {
onAfterMoveSecondaryLast(target, source, move) {
if (source && source !== target && move?.flags['contact']) {
if (target.item || target.switchFlag || target.forceSwitchFlag || source.switchFlag === true) {
return;
Expand Down
7 changes: 1 addition & 6 deletions data/moves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9759,12 +9759,7 @@ export const Moves: import('../sim/dex-moves').MoveDataTable = {
pp: 15,
priority: 0,
flags: {contact: 1, protect: 1, mirror: 1, metronome: 1},
onAfterHit(target, source) {
if (source.hp) {
this.field.clearTerrain();
}
},
onAfterSubDamage(damage, target, source) {
onAfterMoveSecondaryLast(target, source) {
if (source.hp) {
this.field.clearTerrain();
}
Expand Down
4 changes: 4 additions & 0 deletions sim/battle-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,10 @@ export class BattleActions {
this.battle.runEvent('EmergencyExit', pokemon, pokemon);
}
}
for (const i of targets.keys()) {
this.battle.singleEvent('AfterMoveSecondaryLast', move, null, targets[i], pokemon, move);
this.battle.runEvent('AfterMoveSecondaryLast', targets[i], pokemon, move);
}
}

return true;
Expand Down
1 change: 1 addition & 0 deletions sim/dex-conditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface EventMethods {
onAfterTakeItem?: (this: Battle, item: Item, pokemon: Pokemon) => void;
onAfterBoost?: (this: Battle, boost: SparseBoostsTable, target: Pokemon, source: Pokemon, effect: Effect) => void;
onAfterFaint?: (this: Battle, length: number, target: Pokemon, source: Pokemon, effect: Effect) => void;
onAfterMoveSecondaryLast?: MoveEventMethods['onAfterMoveSecondaryLast'];
onAfterMoveSecondarySelf?: MoveEventMethods['onAfterMoveSecondarySelf'];
onAfterMoveSecondary?: MoveEventMethods['onAfterMoveSecondary'];
onAfterMove?: MoveEventMethods['onAfterMove'];
Expand Down
1 change: 1 addition & 0 deletions sim/dex-moves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export interface MoveEventMethods {

onAfterHit?: CommonHandlers['VoidSourceMove'];
onAfterSubDamage?: (this: Battle, damage: number, target: Pokemon, source: Pokemon, move: ActiveMove) => void;
onAfterMoveSecondaryLast?: CommonHandlers['VoidMove'];
onAfterMoveSecondarySelf?: CommonHandlers['VoidSourceMove'];
onAfterMoveSecondary?: CommonHandlers['VoidMove'];
onAfterMove?: CommonHandlers['VoidSourceMove'];
Expand Down
2 changes: 1 addition & 1 deletion test/sim/abilities/pickpocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('Pickpocket', function () {
assert.holdsItem(battle.p2.active[0]);
});

it.skip(`should steal items back and forth when hit by a Magician user`, function () {
it(`should steal items back and forth when hit by a Magician user`, function () {
battle = common.createBattle([[
{species: 'Weavile', ability: 'pickpocket', item: 'cheriberry', moves: ['agility']},
], [
Expand Down
14 changes: 13 additions & 1 deletion test/sim/moves/icespinner.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,19 @@ describe(`Ice Spinner`, function () {
assert.false(battle.field.isTerrain('psychicterrain'));
});

it.skip(`should not remove Terrains if the user faints from Life Orb`, function () {
it(`should remove Terrains if behind a substitute`, function () {
battle = common.createBattle([[
{species: 'wynaut', moves: ['substitute', 'icespinner']},
], [
{species: 'registeel', ability: 'psychicsurge', moves: ['sleeptalk']},
]]);

battle.makeChoices();
battle.makeChoices('move ice spinner', 'auto');
assert.false(battle.field.isTerrain('psychicterrain'));
});

it(`should not remove Terrains if the user faints from Life Orb`, function () {
battle = common.createBattle([[
{species: 'shedinja', item: 'lifeorb', moves: ['icespinner']},
{species: 'wynaut', moves: ['sleeptalk']},
Expand Down