Improve SEND_OUT error message; require Speed for all battlers (#5631)

This commit is contained in:
ghoulslash 2024-11-02 07:56:54 -04:00 committed by GitHub
commit 69d4eec009
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 20 additions and 5 deletions

View file

@ -682,6 +682,7 @@ struct BattleTestData
struct RecordedBattleSave recordedBattle;
u8 battleRecordTypes[MAX_BATTLERS_COUNT][BATTLER_RECORD_SIZE];
u8 battleRecordTurnNumbers[MAX_BATTLERS_COUNT][BATTLER_RECORD_SIZE];
u8 battleRecordSourceLineOffsets[MAX_BATTLERS_COUNT][BATTLER_RECORD_SIZE];
u16 recordIndexes[MAX_BATTLERS_COUNT];
struct BattlerTurn battleRecordTurns[MAX_TURNS][MAX_BATTLERS_COUNT];

View file

@ -46,7 +46,7 @@ SINGLE_BATTLE_TEST("Sap Sipper does not increase Attack if already maxed")
{
GIVEN {
PLAYER(SPECIES_MARILL) { Ability(ABILITY_SAP_SIPPER); }
OPPONENT(SPECIES_WOBBUFFET) { Speed(1); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(player, MOVE_BELLY_DRUM); MOVE(opponent, MOVE_VINE_WHIP); }
} SCENE {

View file

@ -57,7 +57,7 @@ SINGLE_BATTLE_TEST("Hail fails if Desolate Land or Primordial Sea are active")
DOUBLE_BATTLE_TEST("Hail deals damage based on turn order")
{
GIVEN {
PLAYER(SPECIES_GLALIE);
PLAYER(SPECIES_GLALIE) { Speed(4); }
PLAYER(SPECIES_WYNAUT) { Speed(1); }
OPPONENT(SPECIES_WOBBUFFET) { Speed(2); }
OPPONENT(SPECIES_WYNAUT) { Speed(3); }

View file

@ -69,7 +69,7 @@ SINGLE_BATTLE_TEST("Sandstorm damage does not hurt Ground, Rock, and Steel-type
DOUBLE_BATTLE_TEST("Sandstorm deals damage based on turn order")
{
GIVEN {
PLAYER(SPECIES_PHANPY);
PLAYER(SPECIES_PHANPY) { Speed(4); }
PLAYER(SPECIES_WYNAUT) { Speed(1); }
OPPONENT(SPECIES_WOBBUFFET) { Speed(2); }
OPPONENT(SPECIES_WYNAUT) { Speed(3); }

View file

@ -330,8 +330,10 @@ static void BattleTest_Run(void *data)
if (DATA.hasExplicitSpeeds)
{
// TODO: If a battler is taking the default action maybe it
// should not require an explicit speed?
if (DATA.explicitSpeeds[B_SIDE_PLAYER] != (1 << DATA.playerPartySize) - 1
&& DATA.explicitSpeeds[B_SIDE_OPPONENT] != (1 << DATA.opponentPartySize) - 1)
|| DATA.explicitSpeeds[B_SIDE_OPPONENT] != (1 << DATA.opponentPartySize) - 1)
{
Test_ExitWithResult(TEST_RESULT_INVALID, SourceLine(0), ":LSpeed required for all PLAYERs and OPPONENTs");
}
@ -1863,6 +1865,7 @@ static void PushBattlerAction(u32 sourceLine, s32 battlerId, u32 actionType, u32
if (recordIndex >= BATTLER_RECORD_SIZE)
Test_ExitWithResult(TEST_RESULT_INVALID, SourceLine(0), ":LToo many actions");
DATA.battleRecordTypes[battlerId][recordIndex] = actionType;
DATA.battleRecordTurnNumbers[battlerId][recordIndex] = DATA.turns;
DATA.battleRecordSourceLineOffsets[battlerId][recordIndex] = SourceLineOffset(sourceLine);
DATA.recordedBattle.battleRecord[battlerId][recordIndex] = byte;
}
@ -1911,6 +1914,17 @@ void TestRunner_Battle_CheckBattleRecordActionType(u32 battlerId, u32 recordInde
if (actualMacro)
{
if (gBattleResults.battleTurnCounter != DATA.battleRecordTurnNumbers[battlerId][recordIndex])
{
switch (DATA.battleRecordTypes[battlerId][recordIndex])
{
case RECORDED_PARTY_INDEX:
Test_ExitWithResult(TEST_RESULT_INVALID, line, ":L%s:%d: %s not required (is the send out random?)", filename, line, actualMacro);
default:
Test_ExitWithResult(TEST_RESULT_INVALID, line, ":L%s:%d: %s not required", filename, line, actualMacro);
}
}
switch (actionType)
{
case RECORDED_ACTION_TYPE:
@ -2423,7 +2437,7 @@ void SendOut(u32 sourceLine, struct BattlePokemon *battler, u32 partyIndex)
s32 i;
s32 battlerId = battler - gBattleMons;
INVALID_IF(DATA.turnState == TURN_CLOSED, "SEND_OUT outside TURN");
INVALID_IF(partyIndex >= ((battlerId & BIT_SIDE) == B_SIDE_PLAYER ? DATA.playerPartySize : DATA.opponentPartySize), "SWITCH to invalid party index");
INVALID_IF(partyIndex >= ((battlerId & BIT_SIDE) == B_SIDE_PLAYER ? DATA.playerPartySize : DATA.opponentPartySize), "SEND_OUT of invalid party index");
INVALID_IF(IsAITest() && (battlerId & BIT_SIDE) == B_SIDE_OPPONENT, "SEND_OUT is not allowed for opponent in AI tests. Use EXPECT_SEND_OUT instead");
for (i = 0; i < STATE->battlersCount; i++)
{