#include "global.h" #include "test/battle.h" ASSUMPTIONS { ASSUME(gBattleMoves[MOVE_ALLY_SWITCH].effect == EFFECT_ALLY_SWITCH); } SINGLE_BATTLE_TEST("Ally Switch fails in a single battle") { GIVEN { PLAYER(SPECIES_WOBBUFFET); OPPONENT(SPECIES_WOBBUFFET); } WHEN { TURN { MOVE(player, MOVE_ALLY_SWITCH); } } SCENE { MESSAGE("Wobbuffet used Ally Switch!"); NOT ANIMATION(ANIM_TYPE_MOVE, MOVE_ALLY_SWITCH, player); MESSAGE("But it failed!"); } } DOUBLE_BATTLE_TEST("Ally Switch fails if there is no partner") { GIVEN { PLAYER(SPECIES_WOBBUFFET); PLAYER(SPECIES_WOBBUFFET) { HP(1); } OPPONENT(SPECIES_WOBBUFFET); OPPONENT(SPECIES_WOBBUFFET); } WHEN { TURN { MOVE(opponentLeft, MOVE_TACKLE, target:playerRight); } TURN { MOVE(playerLeft, MOVE_ALLY_SWITCH); } } SCENE { MESSAGE("Wobbuffet fainted!"); MESSAGE("Wobbuffet used Ally Switch!"); NOT ANIMATION(ANIM_TYPE_MOVE, MOVE_ALLY_SWITCH, playerLeft); MESSAGE("But it failed!"); } } DOUBLE_BATTLE_TEST("Ally Switch changes the position of battlers") { GIVEN { ASSUME(gBattleMoves[MOVE_SCREECH].effect == EFFECT_DEFENSE_DOWN_2); ASSUME(gBattleMoves[MOVE_SCREECH].target == MOVE_TARGET_SELECTED); PLAYER(SPECIES_WOBBUFFET) { Speed(5); } // Wobb is playerLeft, but it'll be Wynaut after Ally Switch PLAYER(SPECIES_WYNAUT) { Speed(4); } OPPONENT(SPECIES_KADABRA) { Speed(3); } OPPONENT(SPECIES_ABRA) { Speed(2); } } WHEN { TURN { MOVE(playerLeft, MOVE_ALLY_SWITCH); MOVE(opponentLeft, MOVE_SCREECH, target:playerLeft); MOVE(opponentRight, MOVE_SCREECH, target:playerLeft); } } SCENE { MESSAGE("Wobbuffet used Ally Switch!"); ANIMATION(ANIM_TYPE_MOVE, MOVE_ALLY_SWITCH, playerLeft); MESSAGE("Wobbuffet and Wynaut switched places!"); MESSAGE("Foe Kadabra used Screech!"); ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, playerLeft); MESSAGE("Wynaut's Defense harshly fell!"); MESSAGE("Foe Abra used Screech!"); ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, playerLeft); MESSAGE("Wynaut's Defense harshly fell!"); } THEN { EXPECT_EQ(playerLeft->speed, 4); EXPECT_EQ(playerLeft->species, SPECIES_WYNAUT); EXPECT_EQ(playerRight->speed, 5); EXPECT_EQ(playerRight->species, SPECIES_WOBBUFFET); } } DOUBLE_BATTLE_TEST("Ally Switch does not redirect the target of Snipe Shot") { GIVEN { ASSUME(gBattleMoves[MOVE_SNIPE_SHOT].effect == EFFECT_SNIPE_SHOT); PLAYER(SPECIES_WOBBUFFET); // Wobb is playerLeft, but it'll be Wynaut after Ally Switch PLAYER(SPECIES_WYNAUT); OPPONENT(SPECIES_KADABRA); OPPONENT(SPECIES_ABRA); } WHEN { TURN { MOVE(playerLeft, MOVE_ALLY_SWITCH); MOVE(opponentLeft, MOVE_SNIPE_SHOT, target:playerLeft); } // Kadabra targets Wobb and Snipe Shot ignores Ally Switch position change. } SCENE { MESSAGE("Wobbuffet used Ally Switch!"); ANIMATION(ANIM_TYPE_MOVE, MOVE_ALLY_SWITCH, playerLeft); MESSAGE("Wobbuffet and Wynaut switched places!"); MESSAGE("Foe Kadabra used Snipe Shot!"); ANIMATION(ANIM_TYPE_MOVE, MOVE_SNIPE_SHOT, opponentLeft); HP_BAR(playerRight); } } DOUBLE_BATTLE_TEST("Ally Switch does not redirect moves done by pokemon with Stalwart and Propeller Tail") { u16 ability; PARAMETRIZE { ability = ABILITY_STALWART; } PARAMETRIZE { ability = ABILITY_PROPELLER_TAIL; } PARAMETRIZE { ability = ABILITY_TELEPATHY; } GIVEN { PLAYER(SPECIES_WOBBUFFET); // Wobb is playerLeft, but it'll be Wynaut after Ally Switch PLAYER(SPECIES_WYNAUT); OPPONENT(SPECIES_KADABRA) { Ability(ability); } OPPONENT(SPECIES_ABRA); } WHEN { TURN { MOVE(playerLeft, MOVE_ALLY_SWITCH); MOVE(opponentLeft, MOVE_TACKLE, target:playerRight); } // Kadabra targets playerRight Wynaut. } SCENE { MESSAGE("Wobbuffet used Ally Switch!"); ANIMATION(ANIM_TYPE_MOVE, MOVE_ALLY_SWITCH, playerLeft); MESSAGE("Wobbuffet and Wynaut switched places!"); MESSAGE("Foe Kadabra used Tackle!"); ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponentLeft); HP_BAR((ability == ABILITY_STALWART || ability == ABILITY_PROPELLER_TAIL) ? playerLeft : playerRight); } } DOUBLE_BATTLE_TEST("Ally Switch has no effect on parnter's chosen move") { u16 chosenMove; struct BattlePokemon *chosenTarget = NULL; PARAMETRIZE { chosenMove = MOVE_TACKLE; chosenTarget = opponentLeft; } PARAMETRIZE { chosenMove = MOVE_TACKLE; chosenTarget = opponentRight; } PARAMETRIZE { chosenMove = MOVE_POUND; chosenTarget = opponentLeft; } PARAMETRIZE { chosenMove = MOVE_POUND; chosenTarget = opponentRight; } GIVEN { PLAYER(SPECIES_WOBBUFFET); PLAYER(SPECIES_WYNAUT) { Moves(MOVE_TACKLE, MOVE_POUND, MOVE_CELEBRATE, MOVE_SCRATCH); } OPPONENT(SPECIES_KADABRA); OPPONENT(SPECIES_ABRA); } WHEN { TURN { MOVE(playerLeft, MOVE_ALLY_SWITCH); MOVE(playerRight, chosenMove, target:chosenTarget); } } SCENE { MESSAGE("Wobbuffet used Ally Switch!"); ANIMATION(ANIM_TYPE_MOVE, MOVE_ALLY_SWITCH, playerLeft); MESSAGE("Wobbuffet and Wynaut switched places!"); ANIMATION(ANIM_TYPE_MOVE, chosenMove, playerLeft); HP_BAR(chosenTarget); } } DOUBLE_BATTLE_TEST("Ally Switch - move fails if the target was ally which changed position") { u32 move = MOVE_NONE; PARAMETRIZE { move = MOVE_COACHING; } PARAMETRIZE { move = MOVE_AROMATIC_MIST; } PARAMETRIZE { move = MOVE_HOLD_HANDS; } GIVEN { PLAYER(SPECIES_WOBBUFFET); PLAYER(SPECIES_WYNAUT); OPPONENT(SPECIES_KADABRA); OPPONENT(SPECIES_ABRA); } WHEN { TURN { MOVE(playerLeft, MOVE_ALLY_SWITCH); MOVE(playerRight, move, target:playerLeft); } } SCENE { MESSAGE("Wobbuffet used Ally Switch!"); ANIMATION(ANIM_TYPE_MOVE, MOVE_ALLY_SWITCH, playerLeft); MESSAGE("Wobbuffet and Wynaut switched places!"); NOT ANIMATION(ANIM_TYPE_MOVE, move, playerLeft); MESSAGE("But it failed!"); } } // Verified on Showdown, even though Bulbapedia says otherwise. DOUBLE_BATTLE_TEST("Acupressure works after ally used Ally Switch") { struct BattlePokemon *battlerTarget = NULL; PARAMETRIZE { battlerTarget = playerLeft; } PARAMETRIZE { battlerTarget = playerRight; } GIVEN { PLAYER(SPECIES_WOBBUFFET); PLAYER(SPECIES_WYNAUT); OPPONENT(SPECIES_KADABRA); OPPONENT(SPECIES_ABRA); } WHEN { TURN { MOVE(playerLeft, MOVE_ALLY_SWITCH); MOVE(playerRight, MOVE_ACUPRESSURE, target:battlerTarget); } } SCENE { MESSAGE("Wobbuffet used Ally Switch!"); ANIMATION(ANIM_TYPE_MOVE, MOVE_ALLY_SWITCH, playerLeft); MESSAGE("Wobbuffet and Wynaut switched places!"); ANIMATION(ANIM_TYPE_MOVE, MOVE_ACUPRESSURE); ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, battlerTarget); NOT MESSAGE("But it failed!"); } } DOUBLE_BATTLE_TEST("Ally Switch increases the Protect-like moves counter") { GIVEN { ASSUME(B_ALLY_SWITCH_FAIL_CHANCE >= GEN_9); PLAYER(SPECIES_WOBBUFFET); PLAYER(SPECIES_WOBBUFFET); OPPONENT(SPECIES_WOBBUFFET); OPPONENT(SPECIES_WOBBUFFET); } WHEN { TURN { MOVE(playerLeft, MOVE_ALLY_SWITCH); } } THEN { EXPECT(gDisableStructs[B_POSITION_PLAYER_RIGHT].protectUses == 1); } } DOUBLE_BATTLE_TEST("Ally Switch works if ally used two-turn move like Dig") { GIVEN { PLAYER(SPECIES_WOBBUFFET); PLAYER(SPECIES_WYNAUT); OPPONENT(SPECIES_WOBBUFFET); OPPONENT(SPECIES_WOBBUFFET); } WHEN { TURN { MOVE(playerRight, MOVE_DIG, target:opponentRight); } TURN { MOVE(playerLeft, MOVE_ALLY_SWITCH); SKIP_TURN(playerRight); } } SCENE { MESSAGE("Wynaut used Dig!"); MESSAGE("Wobbuffet used Ally Switch!"); ANIMATION(ANIM_TYPE_MOVE, MOVE_ALLY_SWITCH, playerLeft); MESSAGE("Wobbuffet and Wynaut switched places!"); NOT MESSAGE("Wynaut used -!"); ANIMATION(ANIM_TYPE_MOVE, MOVE_DIG); HP_BAR(opponentRight); } }