diff --git a/src/battle_util.c b/src/battle_util.c index 9cb4da700b..d2f5314742 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -8633,8 +8633,8 @@ bool32 IsBattlerProtected(u32 battlerAtk, u32 battlerDef, u32 move) && IsMoveMakingContact(move, gBattlerAttacker) && GetBattlerAbility(gBattlerAttacker) == ABILITY_UNSEEN_FIST) return FALSE; - else if (gSideStatuses[GetBattlerSide(battlerDef)] & SIDE_STATUS_CRAFTY_SHIELD - && IS_MOVE_STATUS(move)) + else if ((gSideStatuses[GetBattlerSide(battlerDef)] & SIDE_STATUS_CRAFTY_SHIELD) + && IS_MOVE_STATUS(move) && gMovesInfo[move].effect != EFFECT_COACHING) return TRUE; else if (gMovesInfo[move].ignoresProtect) return FALSE; diff --git a/test/battle/ability/flower_gift.c b/test/battle/ability/flower_gift.c index 68712641e0..5ceb26c5c1 100644 --- a/test/battle/ability/flower_gift.c +++ b/test/battle/ability/flower_gift.c @@ -63,7 +63,32 @@ SINGLE_BATTLE_TEST("Flower Gift transforms Cherrim back to normal when its abili } } -TO_DO_BATTLE_TEST("Forecast transforms Castform back to normal under Cloud Nine/Air Lock"); +SINGLE_BATTLE_TEST("Flower Gift transforms Cherrim back to normal under Cloud Nine/Air Lock") +{ + u32 species = 0, ability = 0; + PARAMETRIZE { species = SPECIES_PSYDUCK; ability = ABILITY_CLOUD_NINE; } + PARAMETRIZE { species = SPECIES_RAYQUAZA; ability = ABILITY_AIR_LOCK; } + GIVEN { + PLAYER(SPECIES_CHERRIM_OVERCAST) { Ability(ABILITY_FLOWER_GIFT); } + OPPONENT(SPECIES_WOBBUFFET); + OPPONENT(species) { Ability(ability); } + } WHEN { + TURN { MOVE(player, MOVE_SUNNY_DAY); } + TURN { SWITCH(opponent, 1); } + } SCENE { + // transforms + ABILITY_POPUP(player, ABILITY_FLOWER_GIFT); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FORM_CHANGE, player); + MESSAGE("Cherrim transformed!"); + // back to normal + ABILITY_POPUP(opponent, ability); + ABILITY_POPUP(player, ABILITY_FLOWER_GIFT); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FORM_CHANGE, player); + MESSAGE("Cherrim transformed!"); + } THEN { + EXPECT_EQ(player->species, SPECIES_CHERRIM_OVERCAST); + } +} DOUBLE_BATTLE_TEST("Flower Gift increases the attack of Cherrim and its allies by 1.5x", s16 damageL, s16 damageR) { diff --git a/test/battle/move_effect/coaching.c b/test/battle/move_effect/coaching.c index 2f50aceab5..451ac80495 100644 --- a/test/battle/move_effect/coaching.c +++ b/test/battle/move_effect/coaching.c @@ -1,8 +1,120 @@ #include "global.h" #include "test/battle.h" -TO_DO_BATTLE_TEST("Coaching raises Attack and Defense of ally by 1 stage each"); -TO_DO_BATTLE_TEST("Coaching doesn't raise stats of the user"); -TO_DO_BATTLE_TEST("Coaching bypasses protection of allies"); -TO_DO_BATTLE_TEST("Coaching fails in single battles"); -TO_DO_BATTLE_TEST("Coaching fails if there's no ally"); +ASSUMPTIONS +{ + ASSUME(gMovesInfo[MOVE_COACHING].effect == EFFECT_COACHING); +} + +DOUBLE_BATTLE_TEST("Coaching raises Attack and Defense of ally by 1 stage each") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + PLAYER(SPECIES_WYNAUT); + OPPONENT(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(playerLeft, MOVE_COACHING, target: playerRight); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_COACHING, playerLeft); + MESSAGE("Wynaut's Attack rose!"); + MESSAGE("Wynaut's Defense rose!"); + } +} + +DOUBLE_BATTLE_TEST("Coaching bypasses Protect") +{ + GIVEN { + ASSUME(gMovesInfo[MOVE_PROTECT].effect == EFFECT_PROTECT); + PLAYER(SPECIES_WOBBUFFET); + PLAYER(SPECIES_WYNAUT); + OPPONENT(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(playerRight, MOVE_PROTECT); MOVE(playerLeft, MOVE_COACHING, target: playerRight); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_COACHING, playerLeft); + MESSAGE("Wynaut's Attack rose!"); + MESSAGE("Wynaut's Defense rose!"); + } +} + +DOUBLE_BATTLE_TEST("Coaching bypasses Crafty Shield") +{ + GIVEN { + ASSUME(gMovesInfo[MOVE_CRAFTY_SHIELD].effect == EFFECT_PROTECT); + PLAYER(SPECIES_WOBBUFFET); + PLAYER(SPECIES_WYNAUT); + OPPONENT(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(playerRight, MOVE_CRAFTY_SHIELD); MOVE(playerLeft, MOVE_COACHING, target: playerRight); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_COACHING, playerLeft); + MESSAGE("Wynaut's Attack rose!"); + MESSAGE("Wynaut's Defense rose!"); + } +} + +DOUBLE_BATTLE_TEST("Coaching fails if all allies are is semi-invulnerable") +{ + KNOWN_FAILING; // Coaching succeeds + GIVEN { + ASSUME(gMovesInfo[MOVE_FLY].effect == EFFECT_SEMI_INVULNERABLE); + PLAYER(SPECIES_WOBBUFFET); + PLAYER(SPECIES_HAWLUCHA); + OPPONENT(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(playerRight, MOVE_FLY, target: opponentLeft); MOVE(playerLeft, MOVE_COACHING, target: playerRight); } + } SCENE { + MESSAGE("Hawlucha used Fly!"); + MESSAGE("Wobbuffet used Coaching!"); + NONE_OF { + ANIMATION(ANIM_TYPE_MOVE, MOVE_COACHING, playerLeft); + MESSAGE("Hawlucha's Attack rose!"); + MESSAGE("Hawlucha's Defense rose!"); + } + MESSAGE("But it failed!"); + } +} + +SINGLE_BATTLE_TEST("Coaching fails in single battles") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_COACHING); } + } SCENE { + MESSAGE("But it failed!"); + NONE_OF { + ANIMATION(ANIM_TYPE_MOVE, MOVE_COACHING, player); + MESSAGE("Wynaut's Attack rose!"); + MESSAGE("Wynaut's Defense rose!"); + } + } +} + +DOUBLE_BATTLE_TEST("Coaching fails if there's no ally") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + PLAYER(SPECIES_WYNAUT) { HP(1); }; + OPPONENT(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(playerLeft, MOVE_TACKLE, target: playerRight); } + TURN { MOVE(playerLeft, MOVE_COACHING, target: playerRight); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, playerLeft); + MESSAGE("Wynaut fainted!"); + MESSAGE("Wobbuffet used Coaching!"); + NONE_OF { + ANIMATION(ANIM_TYPE_MOVE, MOVE_COACHING, playerLeft); + MESSAGE("Wynaut's Attack rose!"); + MESSAGE("Wynaut's Defense rose!"); + } + MESSAGE("But it failed!"); + } +} diff --git a/test/battle/move_effect/cosmic_power.c b/test/battle/move_effect/cosmic_power.c index 8680e9f28e..3b52fbe046 100644 --- a/test/battle/move_effect/cosmic_power.c +++ b/test/battle/move_effect/cosmic_power.c @@ -1,4 +1,21 @@ #include "global.h" #include "test/battle.h" -TO_DO_BATTLE_TEST("Cosmic Power increases the user's Defense and Sp. Defense by 1 stage each"); +ASSUMPTIONS +{ + ASSUME(gMovesInfo[MOVE_COSMIC_POWER].effect == EFFECT_COSMIC_POWER); +} + +SINGLE_BATTLE_TEST("Cosmic Power increases the user's Defense and Sp. Defense by 1 stage each") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_COSMIC_POWER); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_COSMIC_POWER, player); + MESSAGE("Wobbuffet's Defense rose!"); + MESSAGE("Wobbuffet's Sp. Def rose!"); + } +} diff --git a/test/test_runner.c b/test/test_runner.c index 1ff37fe8bc..d3196a20e1 100644 --- a/test/test_runner.c +++ b/test/test_runner.c @@ -356,9 +356,14 @@ top: if (gTestRunnerState.result == TEST_RESULT_PASS) { if (gTestRunnerState.result != gTestRunnerState.expectedResult) + { + Test_MgbaPrintf(":L%s:%d", gTestRunnerState.test->filename, SourceLine(0)); Test_MgbaPrintf(":U%s%s\e[0m", color, result); + } else + { Test_MgbaPrintf(":P%s%s\e[0m", color, result); + } } else if (gTestRunnerState.result == TEST_RESULT_ASSUMPTION_FAIL) Test_MgbaPrintf(":A%s%s\e[0m", color, result);