Skip to content

Commit

Permalink
Fixed Unnerve message and wrote tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Hedara committed Feb 5, 2025
1 parent 5238665 commit 8ff76fd
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/battle_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -3095,6 +3095,7 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst, u32 dstSize)
toCpy = sText_Opposing2;
break;
case B_TXT_DEF_TEAM1:
MgbaPrintf(MGBA_LOG_WARN, "Stuff %u", gBattlerTarget);
if (GetBattlerSide(gBattlerTarget) == B_SIDE_PLAYER)
toCpy = sText_Your1;
else
Expand Down
1 change: 1 addition & 0 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -4629,6 +4629,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
case ABILITY_UNNERVE:
if (!gSpecialStatuses[battler].switchInAbilityDone)
{
gBattlerTarget = GetBattlerAtPosition(BATTLE_OPPOSITE(GetBattlerAtPosition(battler)));
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_UNNERVE;
gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
Expand Down
73 changes: 71 additions & 2 deletions test/battle/ability/unnerve.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,74 @@
#include "test/battle.h"

// Remember to add a PARAMETRIZE for As One in the following tests:
TO_DO_BATTLE_TEST("Unnerve prevents opposing Pokémon from eating their own berries");
TO_DO_BATTLE_TEST("Unnerve doesn't prevent opposing Pokémon from using Natural Gift");
SINGLE_BATTLE_TEST("Unnerve prevents opposing Pokémon from eating their own berries")
{
u16 mon;
u16 ability;
PARAMETRIZE { mon = SPECIES_JOLTIK, ability = ABILITY_UNNERVE; }
PARAMETRIZE { mon = SPECIES_CALYREX_ICE, ability = ABILITY_AS_ONE_ICE_RIDER; }
GIVEN {
ASSUME(gItemsInfo[ITEM_RAWST_BERRY].holdEffect == HOLD_EFFECT_CURE_BRN);
PLAYER(mon) { Ability(ability); }
OPPONENT(SPECIES_WOBBUFFET) { Item(ITEM_RAWST_BERRY); Status1(STATUS1_BURN); }
} WHEN {
TURN { }
} SCENE {
ABILITY_POPUP(player, ability);
NOT ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, opponent);
HP_BAR(opponent);
}
}

SINGLE_BATTLE_TEST("Unnerve doesn't prevent opposing Pokémon from using Natural Gift")
{
u16 mon;
u16 ability;
PARAMETRIZE { mon = SPECIES_JOLTIK, ability = ABILITY_UNNERVE; }
PARAMETRIZE { mon = SPECIES_CALYREX_ICE, ability = ABILITY_AS_ONE_ICE_RIDER; }
GIVEN {
ASSUME(gMovesInfo[MOVE_NATURAL_GIFT].effect == EFFECT_NATURAL_GIFT);
PLAYER(mon) { Ability(ability); }
OPPONENT(SPECIES_WOBBUFFET) { Item(ITEM_ORAN_BERRY); }
} WHEN {
TURN { MOVE(opponent, MOVE_NATURAL_GIFT); }
} SCENE {
ABILITY_POPUP(player, ability);
HP_BAR(player);
}
}

SINGLE_BATTLE_TEST("Unnerve prints the correct string (player)")
{
u16 mon;
u16 ability;
PARAMETRIZE { mon = SPECIES_JOLTIK, ability = ABILITY_UNNERVE; }
PARAMETRIZE { mon = SPECIES_CALYREX_ICE, ability = ABILITY_AS_ONE_ICE_RIDER; }
GIVEN {
PLAYER(mon) { Ability(ability); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN {}
} SCENE {
ABILITY_POPUP(player, ability);
MESSAGE("The opposing team is too nervous to eat Berries!");
}
}

SINGLE_BATTLE_TEST("Unnerve prints the correct string (opponent)")
{
KNOWN_FAILING;
u16 mon;
u16 ability;
PARAMETRIZE { mon = SPECIES_JOLTIK, ability = ABILITY_UNNERVE; }
PARAMETRIZE { mon = SPECIES_CALYREX_ICE, ability = ABILITY_AS_ONE_ICE_RIDER; }
GIVEN {
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(mon) { Ability(ability); }
} WHEN {
TURN {}
} SCENE {
ABILITY_POPUP(opponent, ability);
MESSAGE("Your team is too nervous to eat Berries!");
}
}

0 comments on commit 8ff76fd

Please sign in to comment.