Skip to content

Commit 6d62312

Browse files
Implement correctly for all gens
1 parent 81a9759 commit 6d62312

File tree

4 files changed

+58
-28
lines changed

4 files changed

+58
-28
lines changed

Diff for: data/abilities.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -837,11 +837,7 @@ export const Abilities: import('../sim/dex-abilities').AbilityDataTable = {
837837
const dancersTarget = !targetOf1stDance.isAlly(dancer) && source.isAlly(dancer) ?
838838
targetOf1stDance : source;
839839
const dancersTargetLoc = dancer.getLocOf(dancersTarget);
840-
// Dancer activates in order of lowest speed stat to highest
841-
// Note that the speed stat used is after any volatile replacements like Speed Swap,
842-
// but before any multipliers like Agility or Choice Scarf
843-
// Ties go to whichever Pokemon has had the ability for the least amount of time
844-
this.queue.insertChoice({
840+
const action = this.queue.resolveAction({
845841
choice: 'move',
846842
order: 198,
847843
effectOrder: dancer.abilityState.effectOrder,
@@ -850,7 +846,13 @@ export const Abilities: import('../sim/dex-abilities').AbilityDataTable = {
850846
targetLoc: dancersTargetLoc,
851847
sourceEffect: this.dex.abilities.get('dancer'),
852848
externalMove: true,
853-
});
849+
})[0];
850+
// Gen 7: Dancer activates in order of lowest speed stat to highest
851+
// Note that the speed stat used is after any volatile replacements like Speed Swap,
852+
// but before any multipliers like Agility or Choice Scarf
853+
// Ties go to whichever Pokemon has had the ability for the least amount of time
854+
action.speed = -dancer.getStat('spe', true, true);
855+
this.queue.insertAction(action);
854856
},
855857
condition: {
856858
noCopy: true, // doesn't get copied by Baton Pass

Diff for: sim/battle-queue.ts

+8
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,14 @@ export class BattleQueue {
376376
}
377377
const actions = this.resolveAction(choice, midTurn);
378378

379+
this.insertAction(actions);
380+
}
381+
382+
insertAction(actions: Action | Action[]) {
383+
if (!Array.isArray(actions)) {
384+
actions = [actions];
385+
}
386+
379387
let firstIndex = null;
380388
let lastIndex = null;
381389
for (const [i, curAction] of this.list.entries()) {

Diff for: sim/battle.ts

-2
Original file line numberDiff line numberDiff line change
@@ -2599,8 +2599,6 @@ export class Battle {
25992599

26002600
if (!action.pokemon) {
26012601
action.speed = 1;
2602-
} else if (action.sourceEffect?.id === 'dancer') {
2603-
action.speed = -action.pokemon.getStat('spe', true, true);
26042602
} else {
26052603
action.speed = action.pokemon.getActionSpeed();
26062604
}

Diff for: test/sim/abilities/dancer.js

+42-20
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,17 @@ describe('Dancer', () => {
2121
assert.statStage(battle.p2.active[0], 'atk', 3);
2222
});
2323

24-
it('should activate in order of lowest to highest raw speed', () => {
24+
it('should activate in order of fastest to slowest', () => {
2525
battle = common.createBattle({ gameType: 'doubles' }, [[
26-
{ species: 'Shedinja', level: 98, ability: 'dancer', item: 'focussash', moves: ['sleeptalk'] },
26+
{ species: 'Shedinja', ability: 'dancer', item: 'focussash', moves: ['sleeptalk'] },
2727
{ species: 'Shedinja', level: 99, ability: 'dancer', moves: ['sleeptalk'] },
2828
], [
2929
{ species: 'Shedinja', ability: 'wonderguard', moves: ['fierydance'] },
30-
{ species: 'Shedinja', ability: 'dancer', moves: ['sleeptalk'] },
31-
]]);
32-
const [, fastDancer] = battle.p1.active;
33-
const [wwDanceSource, foeDancer] = battle.p2.active;
34-
fastDancer.boostBy({ spe: 6 });
35-
battle.makeChoices('move sleeptalk, move sleeptalk', 'move fierydance 1, move sleeptalk');
36-
assert.fainted(wwDanceSource);
37-
assert.fainted(foeDancer);
38-
});
39-
40-
it('should activate in order of lowest to highest raw speed inside Trick Room', () => {
41-
battle = common.createBattle({ gameType: 'doubles' }, [[
42-
{ species: 'Shedinja', level: 98, ability: 'dancer', item: 'focussash', moves: ['sleeptalk'] },
43-
{ species: 'Shedinja', level: 99, ability: 'dancer', moves: ['sleeptalk'] },
44-
], [
45-
{ species: 'Shedinja', ability: 'wonderguard', moves: ['fierydance', 'trickroom'] },
46-
{ species: 'Shedinja', ability: 'dancer', moves: ['sleeptalk'] },
30+
{ species: 'Shedinja', level: 98, ability: 'dancer', moves: ['sleeptalk'] },
4731
]]);
4832
const [, fastDancer] = battle.p1.active;
4933
const [wwDanceSource, foeDancer] = battle.p2.active;
5034
fastDancer.boostBy({ spe: 6 });
51-
battle.makeChoices('move sleeptalk, move sleeptalk', 'move trickroom, move sleeptalk');
5235
battle.makeChoices('move sleeptalk, move sleeptalk', 'move fierydance 1, move sleeptalk');
5336
assert.fainted(wwDanceSource);
5437
assert.fainted(foeDancer);
@@ -199,3 +182,42 @@ describe('Dancer', () => {
199182
assert.notEqual(suicune.hp, suicune.fullHP);
200183
});
201184
});
185+
186+
describe('[Gen 7] Dancer', () => {
187+
afterEach(() => {
188+
battle.destroy();
189+
});
190+
191+
it('should activate in order of lowest to highest raw speed', () => {
192+
battle = common.gen(7).createBattle({ gameType: 'doubles' }, [[
193+
{ species: 'Shedinja', level: 98, ability: 'dancer', item: 'focussash', moves: ['sleeptalk'] },
194+
{ species: 'Shedinja', level: 99, ability: 'dancer', moves: ['sleeptalk'] },
195+
], [
196+
{ species: 'Shedinja', ability: 'wonderguard', moves: ['fierydance'] },
197+
{ species: 'Shedinja', ability: 'dancer', moves: ['sleeptalk'] },
198+
]]);
199+
const [, fastDancer] = battle.p1.active;
200+
const [wwDanceSource, foeDancer] = battle.p2.active;
201+
fastDancer.boostBy({ spe: 6 });
202+
battle.makeChoices('move sleeptalk, move sleeptalk', 'move fierydance 1, move sleeptalk');
203+
assert.fainted(wwDanceSource);
204+
assert.fainted(foeDancer);
205+
});
206+
207+
it('should activate in order of lowest to highest raw speed inside Trick Room', () => {
208+
battle = common.gen(7).createBattle({ gameType: 'doubles' }, [[
209+
{ species: 'Shedinja', level: 98, ability: 'dancer', item: 'focussash', moves: ['sleeptalk'] },
210+
{ species: 'Shedinja', level: 99, ability: 'dancer', moves: ['sleeptalk'] },
211+
], [
212+
{ species: 'Shedinja', ability: 'wonderguard', moves: ['fierydance', 'trickroom'] },
213+
{ species: 'Shedinja', ability: 'dancer', moves: ['sleeptalk'] },
214+
]]);
215+
const [, fastDancer] = battle.p1.active;
216+
const [wwDanceSource, foeDancer] = battle.p2.active;
217+
fastDancer.boostBy({ spe: 6 });
218+
battle.makeChoices('move sleeptalk, move sleeptalk', 'move trickroom, move sleeptalk');
219+
battle.makeChoices('move sleeptalk, move sleeptalk', 'move fierydance 1, move sleeptalk');
220+
assert.fainted(wwDanceSource);
221+
assert.fainted(foeDancer);
222+
});
223+
});

0 commit comments

Comments
 (0)