Corrects test system Forced Ability handing for multi battles (#8611)

This commit is contained in:
grintoul 2025-12-22 09:11:21 +00:00 committed by GitHub
parent 8cb6791cdc
commit d55d2b6dfc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 42 additions and 22 deletions

View File

@ -750,7 +750,7 @@ struct BattleTestData
u8 gender;
u8 nature;
bool8 isShiny;
enum Ability forcedAbilities[NUM_BATTLE_SIDES][PARTY_SIZE];
enum Ability forcedAbilities[MAX_BATTLERS_COUNT][PARTY_SIZE];
u8 chosenGimmick[NUM_BATTLE_SIDES][PARTY_SIZE];
u8 forcedEnvironment;

View File

@ -31,7 +31,7 @@ void TestRunner_CheckMemory(void);
void TestRunner_Battle_CheckBattleRecordActionType(u32 battlerId, u32 recordIndex, u32 actionType);
u32 TestRunner_Battle_GetForcedAbility(u32 side, u32 partyIndex);
u32 TestRunner_Battle_GetForcedAbility(u32 array, u32 partyIndex);
u32 TestRunner_Battle_GetChosenGimmick(u32 side, u32 partyIndex);
u32 TestRunner_Battle_GetForcedEnvironment(void);

View File

@ -1438,10 +1438,10 @@ static u32 GetBattlerMonData(u32 battler, struct Pokemon *party, u32 monId, u8 *
#if TESTING
if (gTestRunnerEnabled)
{
u32 side = GetBattlerSide(battler);
u32 array = (!IsPartnerMonFromSameTrainer(battler)) ? battler : GetBattlerSide(battler);
u32 partyIndex = gBattlerPartyIndexes[battler];
if (TestRunner_Battle_GetForcedAbility(side, partyIndex))
gBattleMons[battler].ability = TestRunner_Battle_GetForcedAbility(side, partyIndex);
if (TestRunner_Battle_GetForcedAbility(array, partyIndex))
gBattleMons[battler].ability = TestRunner_Battle_GetForcedAbility(array, partyIndex);
}
#endif
break;

View File

@ -3284,10 +3284,10 @@ void SwitchInClearSetData(u32 battler, struct Volatiles *volatilesCopy)
#if TESTING
if (gTestRunnerEnabled)
{
u32 side = GetBattlerSide(battler);
u32 array = (!IsPartnerMonFromSameTrainer(battler)) ? battler : GetBattlerSide(battler);
u32 partyIndex = gBattlerPartyIndexes[battler];
if (TestRunner_Battle_GetForcedAbility(side, partyIndex))
gBattleMons[i].ability = TestRunner_Battle_GetForcedAbility(side, partyIndex);
if (TestRunner_Battle_GetForcedAbility(array, partyIndex))
gBattleMons[i].ability = TestRunner_Battle_GetForcedAbility(array, partyIndex);
}
#endif // TESTING
@ -3495,10 +3495,10 @@ static void DoBattleIntro(void)
#if TESTING
if (gTestRunnerEnabled)
{
u32 side = GetBattlerSide(battler);
u32 array = (!IsPartnerMonFromSameTrainer(battler)) ? battler : GetBattlerSide(battler);
u32 partyIndex = gBattlerPartyIndexes[battler];
if (TestRunner_Battle_GetForcedAbility(side, partyIndex))
gBattleMons[battler].ability = TestRunner_Battle_GetForcedAbility(side, partyIndex);
if (TestRunner_Battle_GetForcedAbility(array, partyIndex))
gBattleMons[battler].ability = TestRunner_Battle_GetForcedAbility(array, partyIndex);
}
#endif
}
@ -3794,10 +3794,10 @@ static void TryDoEventsBeforeFirstTurn(void)
{
for (i = 0; i < gBattlersCount; ++i)
{
u32 side = GetBattlerSide(i);
u32 array = (!IsPartnerMonFromSameTrainer(i)) ? i : GetBattlerSide(i);
u32 partyIndex = gBattlerPartyIndexes[i];
if (TestRunner_Battle_GetForcedAbility(side, partyIndex))
gBattleMons[i].ability = TestRunner_Battle_GetForcedAbility(side, partyIndex);
if (TestRunner_Battle_GetForcedAbility(array, partyIndex))
gBattleMons[i].ability = TestRunner_Battle_GetForcedAbility(array, partyIndex);
}
}
#endif // TESTING

View File

@ -7308,10 +7308,10 @@ static void Cmd_switchindataupdate(void)
#if TESTING
if (gTestRunnerEnabled)
{
u32 side = GetBattlerSide(battler);
u32 array = (!IsPartnerMonFromSameTrainer(battler)) ? battler : GetBattlerSide(battler);
u32 partyIndex = gBattlerPartyIndexes[battler];
if (TestRunner_Battle_GetForcedAbility(side, partyIndex))
gBattleMons[battler].ability = TestRunner_Battle_GetForcedAbility(side, partyIndex);
if (TestRunner_Battle_GetForcedAbility(array, partyIndex))
gBattleMons[battler].ability = TestRunner_Battle_GetForcedAbility(array, partyIndex);
}
#endif
@ -11846,9 +11846,9 @@ static void Cmd_healpartystatus(void)
#if TESTING
if (gTestRunnerEnabled)
{
u32 side = GetBattlerSide(gBattlerAttacker);
if (TestRunner_Battle_GetForcedAbility(side, i))
ability = TestRunner_Battle_GetForcedAbility(side, i);
u32 array = (!IsPartnerMonFromSameTrainer(gBattlerAttacker)) ? gBattlerAttacker : GetBattlerSide(gBattlerAttacker);
if (TestRunner_Battle_GetForcedAbility(array, i))
ability = TestRunner_Battle_GetForcedAbility(array, i);
}
#endif
}

View File

@ -3219,9 +3219,9 @@ void ValidateFinally(u32 sourceLine)
INVALID_IF(STATE->parametersCount == 0, "FINALLY without PARAMETRIZE");
}
u32 TestRunner_Battle_GetForcedAbility(u32 side, u32 partyIndex)
u32 TestRunner_Battle_GetForcedAbility(u32 array, u32 partyIndex)
{
return DATA.forcedAbilities[side][partyIndex];
return DATA.forcedAbilities[array][partyIndex];
}
u32 TestRunner_Battle_GetForcedEnvironment(void)

View File

@ -1,5 +1,6 @@
#include "global.h"
#include "test/test.h"
#include "test/battle.h"
TEST("Tests resume after CRASH")
{
@ -7,3 +8,22 @@ TEST("Tests resume after CRASH")
void (*f)(void) = NULL;
f();
}
MULTI_BATTLE_TEST("Forced Abilities are set correctly in multi battle tests")
{
GIVEN {
MULTI_PLAYER(SPECIES_WOBBUFFET);
MULTI_PARTNER(SPECIES_WOBBUFFET);
MULTI_PARTNER(SPECIES_NINETALES_ALOLA) { Ability(ABILITY_DRIZZLE); }
MULTI_OPPONENT_A(SPECIES_WOBBUFFET);
MULTI_OPPONENT_A(SPECIES_NINETALES_ALOLA) { Ability(ABILITY_SAND_STREAM); }
MULTI_OPPONENT_B(SPECIES_WYNAUT);
MULTI_OPPONENT_B(SPECIES_NINETALES_ALOLA) { Ability(ABILITY_DROUGHT); }
} WHEN {
TURN { SWITCH(opponentLeft, 1); SWITCH(playerRight, 4); SWITCH(opponentRight, 4); }
} SCENE {
ABILITY_POPUP(opponentLeft, ABILITY_SAND_STREAM);
ABILITY_POPUP(playerRight, ABILITY_DRIZZLE);
ABILITY_POPUP(opponentRight, ABILITY_DROUGHT);
}
}