Skip to content

Commit

Permalink
Fix called Fly/Bounce + Ally Switch interaction (#8910)
Browse files Browse the repository at this point in the history
  • Loading branch information
pyuk-bot committed Sep 22, 2022
1 parent af9e158 commit 8326578
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion data/conditions.ts
Expand Up @@ -287,7 +287,7 @@ export const Conditions: {[k: string]: ConditionData} = {
// note that this is not updated for moves called by other moves
// i.e. if Dig is called by Metronome, lastMoveTargetLoc will still be the user's location
let moveTargetLoc: number = attacker.lastMoveTargetLoc!;
if (effect.sourceEffect && this.dex.moves.get(effect.id).target === 'normal') {
if (effect.sourceEffect && this.dex.moves.get(effect.id).target !== 'self') {
// this move was called by another move such as Metronome
// and needs a random target to be determined this turn
// it will already have one by now if there is any valid target
Expand Down
1 change: 1 addition & 0 deletions sim/battle-actions.ts
Expand Up @@ -293,6 +293,7 @@ export class BattleActions {
this.battle.add('-zpower', pokemon);
pokemon.side.zMoveUsed = true;
}

const moveDidSomething = this.useMove(baseMove, pokemon, target, sourceEffect, zMove, maxMove);
this.battle.lastSuccessfulMoveThisTurn = moveDidSomething ? this.battle.activeMove && this.battle.activeMove.id : null;
if (this.battle.activeMove) move = this.battle.activeMove;
Expand Down
16 changes: 10 additions & 6 deletions test/sim/misc/target-resolution.js
Expand Up @@ -295,17 +295,21 @@ describe('Target Resolution', function () {

it('should not force charge moves called by another move to target an ally after Ally Switch', function () {
battle = common.createBattle({gameType: 'doubles'}, [[
{species: 'purrloin', ability: 'prankster', moves: ['copycat', 'sleeptalk']},
{species: 'wynaut', moves: ['allyswitch', 'solarbeam']},
{species: 'purrloin', ability: 'no guard', moves: ['copycat', 'sleeptalk']},
{species: 'wynaut', moves: ['allyswitch', 'fly', 'skullbash']},
], [
{species: 'swablu', moves: ['sleeptalk']},
{species: 'swablu', moves: ['sleeptalk']},
{species: 'aron', moves: ['sleeptalk']},
{species: 'lairon', moves: ['sleeptalk']},
]]);

battle.makeChoices('move sleeptalk, move solarbeam 1', 'auto');
battle.makeChoices('move sleeptalk, move fly 1', 'auto');
battle.makeChoices();
battle.makeChoices();
assert.fullHP(battle.p1.active[0]);
battle.makeChoices('move skullbash 1, move sleeptalk', 'auto');
battle.makeChoices();
battle.makeChoices();
// ally switch was used twice, so wynaut will be back where it started
assert.fullHP(battle.p1.active[1]);
});

it(`Ally Switch should cause single-target moves to fail if targeting an ally`, function () {
Expand Down

0 comments on commit 8326578

Please sign in to comment.