From 39f5596d0940c7fe7f4cb036cccdd313e98c581c Mon Sep 17 00:00:00 2001 From: Martin Griffin Date: Fri, 1 Nov 2024 16:55:41 +0000 Subject: [PATCH 1/3] Improve unneeded SEND_OUT error --- include/test/battle.h | 1 + test/test_runner_battle.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/test/battle.h b/include/test/battle.h index 819d05cbff..d1861e0c7f 100644 --- a/include/test/battle.h +++ b/include/test/battle.h @@ -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]; diff --git a/test/test_runner_battle.c b/test/test_runner_battle.c index ae86f87ab4..3e0250ffd0 100644 --- a/test/test_runner_battle.c +++ b/test/test_runner_battle.c @@ -1863,6 +1863,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 +1912,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: From daebe7eba853c670e98f4263f10c54fe082ebb71 Mon Sep 17 00:00:00 2001 From: Martin Griffin Date: Fri, 1 Nov 2024 16:55:57 +0000 Subject: [PATCH 2/3] Improve invalid index SEND_OUT error --- test/test_runner_battle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_runner_battle.c b/test/test_runner_battle.c index 3e0250ffd0..b95fe49774 100644 --- a/test/test_runner_battle.c +++ b/test/test_runner_battle.c @@ -2435,7 +2435,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++) { From ca2fffc5d0a5c97e31d7f84cfdf0259353738f7a Mon Sep 17 00:00:00 2001 From: Martin Griffin Date: Fri, 1 Nov 2024 16:57:57 +0000 Subject: [PATCH 3/3] Fix explicitSpeed check Add 'Speed(...)' calls where required. --- test/battle/ability/sap_sipper.c | 2 +- test/battle/weather/hail.c | 2 +- test/battle/weather/sandstorm.c | 2 +- test/test_runner_battle.c | 4 +++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/test/battle/ability/sap_sipper.c b/test/battle/ability/sap_sipper.c index b253bfaa84..9d0ee7eaca 100644 --- a/test/battle/ability/sap_sipper.c +++ b/test/battle/ability/sap_sipper.c @@ -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 { diff --git a/test/battle/weather/hail.c b/test/battle/weather/hail.c index 4210a22d9e..f5ccf3cc99 100644 --- a/test/battle/weather/hail.c +++ b/test/battle/weather/hail.c @@ -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); } diff --git a/test/battle/weather/sandstorm.c b/test/battle/weather/sandstorm.c index 1673c26f99..6059d2c224 100644 --- a/test/battle/weather/sandstorm.c +++ b/test/battle/weather/sandstorm.c @@ -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); } diff --git a/test/test_runner_battle.c b/test/test_runner_battle.c index b95fe49774..b74e8e6d2e 100644 --- a/test/test_runner_battle.c +++ b/test/test_runner_battle.c @@ -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"); }