Skip to content

Commit

Permalink
Added missing tests + Fix Coaching/Crafty Shield interaction (#5796)
Browse files Browse the repository at this point in the history
Co-authored-by: hedara90 <[email protected]>
  • Loading branch information
AsparagusEduardo and hedara90 authored Dec 11, 2024
1 parent 5477033 commit 7eee3b3
Show file tree
Hide file tree
Showing 5 changed files with 168 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
27 changes: 26 additions & 1 deletion test/battle/ability/flower_gift.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
122 changes: 117 additions & 5 deletions test/battle/move_effect/coaching.c
Original file line number Diff line number Diff line change
@@ -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!");
}
}
19 changes: 18 additions & 1 deletion test/battle/move_effect/cosmic_power.c
Original file line number Diff line number Diff line change
@@ -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!");
}
}
5 changes: 5 additions & 0 deletions test/test_runner.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,14 @@ void CB2_TestRunner(void)
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);
Expand Down

0 comments on commit 7eee3b3

Please sign in to comment.