Tests do not allow to use SEND_OUT if the chosen mon is fainted (#3752)
* Tests dont allow to send out pokemon with 0 hp * remove test test * handle in-game 0 hp sent out --------- Co-authored-by: Bassoonian <iasperbassoonian@gmail.com>
This commit is contained in:
parent
fb28ce50ae
commit
1a7166c2bb
3 changed files with 37 additions and 0 deletions
|
@ -19,6 +19,7 @@ void TestRunner_Battle_CheckSwitch(u32 battlerId, u32 partyIndex);
|
|||
void TestRunner_Battle_CheckAiMoveScores(u32 battlerId);
|
||||
void TestRunner_Battle_AISetScore(const char *file, u32 line, u32 battlerId, u32 moveIndex, s32 score);
|
||||
void TestRunner_Battle_AIAdjustScore(const char *file, u32 line, u32 battlerId, u32 moveIndex, s32 score);
|
||||
void TestRunner_Battle_InvalidNoHPMon(u32 battlerId, u32 partyIndex);
|
||||
|
||||
void TestRunner_Battle_CheckBattleRecordActionType(u32 battlerId, u32 recordIndex, u32 actionType);
|
||||
|
||||
|
@ -38,6 +39,7 @@ u32 TestRunner_Battle_GetForcedAbility(u32 side, u32 partyIndex);
|
|||
#define TestRunner_Battle_CheckAiMoveScores(...) (void)0
|
||||
#define TestRunner_Battle_AISetScore(...) (void)0
|
||||
#define TestRunner_Battle_AIAdjustScore(...) (void)0
|
||||
#define TestRunner_Battle_InvalidNoHPMon(...) (void)0
|
||||
|
||||
#define TestRunner_Battle_CheckBattleRecordActionType(...) (void)0
|
||||
|
||||
|
|
|
@ -6166,6 +6166,35 @@ static void Cmd_switchindataupdate(void)
|
|||
for (i = 0; i < sizeof(struct BattlePokemon); i++)
|
||||
monData[i] = gBattleResources->bufferB[battler][4 + i];
|
||||
|
||||
// Edge case: the sent out pokemon has 0 HP. This should never happen.
|
||||
if (gBattleMons[battler].hp == 0)
|
||||
{
|
||||
// If it's a test, mark it as invalid.
|
||||
if (gTestRunnerEnabled)
|
||||
{
|
||||
TestRunner_Battle_InvalidNoHPMon(battler, gBattlerPartyIndexes[battler]);
|
||||
}
|
||||
// Handle in-game scenario.
|
||||
else
|
||||
{
|
||||
struct Pokemon *party = GetBattlerParty(battler);
|
||||
// Find the first possible replacement for the not valid pokemon.
|
||||
for (i = 0; i < PARTY_SIZE; i++)
|
||||
{
|
||||
if (IsValidForBattle(&party[i]))
|
||||
break;
|
||||
}
|
||||
// There is valid replacement.
|
||||
if (i != PARTY_SIZE)
|
||||
{
|
||||
gBattlerPartyIndexes[battler] = gBattleStruct->monToSwitchIntoId[battler] = i;
|
||||
BtlController_EmitGetMonData(battler, BUFFER_A, REQUEST_ALL_BATTLE, gBitTable[gBattlerPartyIndexes[battler]]);
|
||||
MarkBattlerForControllerExec(battler);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gBattleMons[battler].type1 = gSpeciesInfo[gBattleMons[battler].species].types[0];
|
||||
gBattleMons[battler].type2 = gSpeciesInfo[gBattleMons[battler].species].types[1];
|
||||
gBattleMons[battler].type3 = TYPE_MYSTERY;
|
||||
|
|
|
@ -881,6 +881,12 @@ void TestRunner_Battle_CheckSwitch(u32 battlerId, u32 partyIndex)
|
|||
DATA.aiActionsPlayed[battlerId]++;
|
||||
}
|
||||
|
||||
void TestRunner_Battle_InvalidNoHPMon(u32 battlerId, u32 partyIndex)
|
||||
{
|
||||
Test_ExitWithResult(TEST_RESULT_INVALID, "%s: INVALID: %s trying to send out a mon(id: %d) with 0 HP.",
|
||||
gTestRunnerState.test->filename, BattlerIdentifier(battlerId), gBattlerPartyIndexes[battlerId]);
|
||||
}
|
||||
|
||||
static bool32 CheckComparision(s32 val1, s32 val2, u32 cmp)
|
||||
{
|
||||
switch (cmp)
|
||||
|
|
Loading…
Reference in a new issue