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

Fix Sparkling Aria's interaction with Shield Dust #10882

Open
wants to merge 17 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
23 changes: 14 additions & 9 deletions data/abilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2421,16 +2421,21 @@ export const Abilities: import('../sim/dex-abilities').AbilityDataTable = {
},
magician: {
onAfterMoveSecondarySelf(source, target, move) {
if (!move || !target || source.switchFlag === true) return;
if (target !== source && move.category !== 'Status') {
if (source.item || source.volatiles['gem'] || move.id === 'fling') return;
const yourItem = target.takeItem(source);
if (!yourItem) return;
if (!source.setItem(yourItem)) {
target.item = yourItem.id; // bypass setItem so we don't break choicelock or anything
if (!move || source.switchFlag === true || !move.hitTargets || source.item || source.volatiles['gem'] ||
move.id === 'fling') return;
const hitTargets = move.hitTargets;
this.speedSort(hitTargets);
for (const pokemon of hitTargets) {
if (pokemon !== source && move.category !== 'Status') {
const yourItem = pokemon.takeItem(source);
if (!yourItem) continue;
if (!source.setItem(yourItem)) {
pokemon.item = yourItem.id; // bypass setItem so we don't break choicelock or anything
continue;
}
this.add('-item', source, yourItem, '[from] ability: Magician', `[of] ${pokemon}`);
return;
}
this.add('-item', source, yourItem, '[from] ability: Magician', `[of] ${target}`);
}
},
flags: {},
Expand Down Expand Up @@ -4143,7 +4148,7 @@ export const Abilities: import('../sim/dex-abilities').AbilityDataTable = {
shielddust: {
onModifySecondaries(secondaries) {
this.debug('Shield Dust prevent secondary');
return secondaries.filter(effect => !!(effect.self || effect.dustproof));
return secondaries.filter(effect => !!effect.self);
},
flags: { breakable: 1 },
name: "Shield Dust",
Expand Down
2 changes: 1 addition & 1 deletion data/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ export const Items: import('../sim/dex-items').ItemDataTable = {
},
onModifySecondaries(secondaries) {
this.debug('Covert Cloak prevent secondary');
return secondaries.filter(effect => !!(effect.self || effect.dustproof));
return secondaries.filter(effect => !!effect.self);
},
num: 1885,
gen: 9,
Expand Down
2 changes: 1 addition & 1 deletion data/mods/gen9ssb/abilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1867,7 +1867,7 @@ export const Abilities: import('../../../sim/dex-abilities').ModdedAbilityDataTa
},
onModifySecondaries(secondaries) {
this.debug('Fancy Scarf prevent secondary');
return secondaries.filter(effect => !!(effect.self || effect.dustproof));
return secondaries.filter(effect => !!effect.self);
},
flags: {},
},
Expand Down
12 changes: 9 additions & 3 deletions data/moves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18049,13 +18049,19 @@ export const Moves: import('../sim/dex-moves').MoveDataTable = {
priority: 0,
flags: { protect: 1, mirror: 1, sound: 1, bypasssub: 1, metronome: 1 },
secondary: {
dustproof: true,
chance: 100,
volatileStatus: 'sparklingaria',
},
onAfterMove(source, target, move) {
for (const pokemon of this.getAllActive()) {
if (pokemon !== source && pokemon.removeVolatile('sparklingaria') && pokemon.status === 'brn' && !source.fainted) {
if (source.fainted || !move.hitTargets || move.hasSheerForce) {
// make sure the volatiles are cleared
for (const pokemon of this.getAllActive()) delete pokemon.volatiles['sparklingaria'];
return;
}
const numberTargets = move.hitTargets.length;
for (const pokemon of move.hitTargets) {
if (pokemon !== source && pokemon.isActive && (pokemon.removeVolatile('sparklingaria') || numberTargets > 1) &&
pokemon.status === 'brn') {
pokemon.cureStatus();
}
}
Expand Down
1 change: 1 addition & 0 deletions sim/battle-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ export class BattleActions {
}
}

move.hitTargets = targets;
const moveResult = !!targets.length;
if (!moveResult && !atLeastOneFailure) pokemon.moveThisTurnResult = null;
const hitSlot = targets.map(p => p.getSlot());
Expand Down
6 changes: 1 addition & 5 deletions sim/dex-moves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,6 @@ export interface SecondaryEffect extends HitEffect {
chance?: number;
/** Used to flag a secondary effect as added by Poison Touch */
ability?: Ability;
/**
* Applies to Sparkling Aria's secondary effect: Affected by
* Sheer Force but not Shield Dust.
*/
dustproof?: boolean;
/**
* Gen 2 specific mechanics: Bypasses Substitute only on Twineedle,
* and allows it to flinch sleeping/frozen targets
Expand Down Expand Up @@ -317,6 +312,7 @@ export interface ActiveMove extends MutableMove {
status?: ID;
hit: number;
moveHitData?: MoveHitData;
hitTargets?: Pokemon[];
ability?: Ability;
allies?: Pokemon[];
auraBooster?: Pokemon;
Expand Down
14 changes: 14 additions & 0 deletions test/sim/abilities/magician.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,18 @@ describe('Magician', () => {
battle.makeChoices();
assert.false.holdsItem(battle.p1.active[0], 'Klefki should not have stolen Weakness Policy.');
});

it(`should steal the item from the faster opponent hit`, () => {
battle = common.createBattle({ gameType: 'doubles' }, [[
{ species: "Hoopa", ability: 'magician', moves: ['expandingforce'] },
{ species: "Tapu Lele", ability: 'psychicsurge', moves: ['sleeptalk'] },
], [
{ species: "Shuckle", item: 'tr68', moves: ['sleeptalk'] },
{ species: "Zapdos", item: 'tr69', moves: ['sleeptalk'] }],
]);
battle.makeChoices();
assert.equal(battle.p1.active[0].item, 'tr69');
assert.equal(battle.p2.active[0].item, 'tr68');
assert.equal(battle.p2.active[1].item, '');
});
});
20 changes: 6 additions & 14 deletions test/sim/abilities/shielddust.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,27 +72,19 @@ describe('Shield Dust', () => {
assert.statStage(battle.p2.active[0], 'spa', -1);
});

it.skip(`should only prevent Sparkling Aria from curing burn if there is only one target`, () => {
battle = common.createBattle([[
{ species: 'wynaut', ability: 'noguard', moves: ['willowisp', 'sparklingaria'] },
], [
{ species: 'dustox', ability: 'shielddust', moves: ['sleeptalk'] },
]]);
battle.makeChoices('move willowisp', 'auto');
battle.makeChoices('move sparklingaria', 'auto');

assert.equal(battle.p2.active[0].status, 'brn', `Shield Dust should prevent cured burn if it's the only target`);

it(`should only prevent Sparkling Aria from curing burn if there is only one target`, () => {
battle = common.createBattle({ gameType: 'doubles' }, [[
{ species: 'wynaut', ability: 'noguard', moves: ['willowisp', 'sparklingaria'] },
{ species: 'diglett', moves: ['sleeptalk'] },
{ species: 'diglett', moves: ['sleeptalk', 'protect'] },
], [
{ species: 'dustox', ability: 'shielddust', moves: ['sleeptalk'] },
{ species: 'magikarp', moves: ['sleeptalk'] },
{ species: 'magikarp', moves: ['sleeptalk', 'protect'] },
]]);
battle.makeChoices('move willowisp 1, move sleeptalk', 'auto');
battle.makeChoices('move sparklingaria, move sleeptalk', 'auto');
battle.makeChoices('move sparklingaria, move protect', 'move sleeptalk, move protect');
assert.equal(battle.p2.active[0].status, 'brn', `Shield Dust should prevent cured burn if it's the only target`);

battle.makeChoices('move sparklingaria, move sleeptalk', 'auto');
assert.equal(battle.p2.active[0].status, '', `Shield Dust should not prevent cured burn if it's one of many targets`);
});
});
2 changes: 1 addition & 1 deletion test/sim/moves/roost.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('Roost', () => {
assert.equal(battle.p2.active[0].hp, battle.p2.active[0].maxhp);
});

it('should suppress user\'s current Flying type if succesful', () => {
it('should suppress user\'s current Flying type if successful', () => {
battle = common.createBattle();
battle.setPlayer('p1', { team: [{ species: "Aggron", item: 'leftovers', ability: 'sturdy', moves: ['mudslap', 'hiddenpowergrass'] }] });
battle.setPlayer('p2', { team: [{ species: "Aerodactyl", item: 'focussash', ability: 'wonderguard', moves: ['roost', 'doubleedge'] }] });
Expand Down