From c9066b38814f75045b793fff74c134bbc9864e9e Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 5 Nov 2026 23:06:23 -0800 Subject: [PATCH 1/3] Fix Max Lair boss inference and boss-catch reporting --- .../Framework/PokemonSwSh_MaxLair_State.cpp | 23 +++++++++---- .../Framework/PokemonSwSh_MaxLair_State.h | 11 ++++--- .../PokemonSwSh_MaxLair_State_Tests.cpp | 32 +++++++------------ .../Options/PokemonSwSh_MaxLair_Options.h | 1 + .../PokemonSwSh_MaxLair_Run_Battle.cpp | 13 +++----- 5 files changed, 41 insertions(+), 39 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State.cpp b/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State.cpp index b6bd7a8349..5267153517 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State.cpp @@ -24,22 +24,31 @@ bool is_boss_battle(const GlobalState& state){ } // namespace +bool GlobalState::in_boss_battle_with_known_boss() const{ + return is_boss_battle(*this) && is_boss(boss); +} + bool GlobalState::accept_opponent(){ - const std::string opponent_slug = opponent.empty() ? "" : *opponent.begin(); - // A boss before the end means something is out-of-sync. - if (!is_boss_battle(*this) && is_boss(opponent_slug)){ + if (opponent.size() != 1){ + return false; + } + const std::string& opponent_slug = *opponent.begin(); + // Reject the OCR read if the opponent species doesn't match the current stage: + // a legendary boss read during battles 1-3, or a non-boss rental read in battle 4. + if (is_boss(opponent_slug) != is_boss_battle(*this)){ return false; } - // Infer the boss if we don't know it. - if (is_boss_battle(*this) && boss.empty()){ + if (is_boss_battle(*this) && !in_boss_battle_with_known_boss()){ boss = opponent_slug; } return true; } std::string GlobalState::boss_if_caught() const{ - // The identified boss is reported whether or not it was caught. - return boss; + // A failed adventure (e.g. wins == 3, only lost to the boss) can still have + // an identified boss, but no boss catch: catching the boss requires winning + // the fourth battle (wins == 4). + return wins == 4 && is_boss(boss) ? boss : ""; } std::string PlayerState::dump() const{ diff --git a/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State.h b/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State.h index e6aa8e7050..f0c51b8978 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State.h +++ b/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State.h @@ -172,9 +172,13 @@ struct GlobalState{ size_t find_player_index(size_t console_id) const; void clear_battle_state(); - // Returns false when the opponent read doesn't fit this battle stage (a - // boss before the fourth battle), so the caller retries the read. On an - // accepted read at the fourth battle, records the boss if none is known. + // True during the fourth (boss) battle when a boss has already been identified. + bool in_boss_battle_with_known_boss() const; + + // Returns false when the opponent read doesn't fit this battle stage (not + // exactly one opponent, or a boss before the fourth battle / a rental at + // it), so the caller retries the read. On an accepted read at the fourth + // battle, records the boss unless a boss is already known. bool accept_opponent(); // The same boss, but only if the adventure caught it, else empty: for the @@ -182,7 +186,6 @@ struct GlobalState{ // the boss-caught rules after a loss. Decided from the battles won (the // boss is the fourth battle), not from how many Pokemon were caught, so it // stays right if non-boss catches are ever skipped. - // For now this returns boss whatever the battles won. std::string boss_if_caught() const; std::string dump() const; diff --git a/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State_Tests.cpp index b5b27ac65b..ebdd434f3a 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State_Tests.cpp @@ -68,26 +68,22 @@ class Test_MaxLairBossState : public UnitTest{ BossStateTestCase m_scenario; }; -// Cases marked TODO record the current, wrong behaviour. const BossStateTestCase CASES[] = { { .input = {.name = "rental before three wins", .wins = 2, .opponent = {"mimikyu-disguised"}, .boss = "", .final_wins = 3}, .expectation = {.accepted = true, .boss = "", .boss_if_caught = ""}, }, - // TODO: to be fixed: a rental at the boss stage is accepted as the boss and reported caught. { - .input = {.name = "Mimikyu at boss stage", .wins = 3, .opponent = {"mimikyu-disguised"}, .boss = "", .final_wins = 3}, - .expectation = {.accepted = true, .boss = "mimikyu-disguised", .boss_if_caught = "mimikyu-disguised"}, + .input = {.name = "Mimikyu at boss stage must retry", .wins = 3, .opponent = {"mimikyu-disguised"}, .boss = "", .final_wins = 3}, + .expectation = {.accepted = false, .boss = "", .boss_if_caught = ""}, }, - // TODO: to be fixed: a rental misread as the boss is kept after the real boss is read. { .input = {.name = "Kyurem after Mimikyu misidentification", .wins = 3, .opponent = {"kyurem"}, .boss = "mimikyu-disguised", .final_wins = 3}, - .expectation = {.accepted = true, .boss = "mimikyu-disguised", .boss_if_caught = "mimikyu-disguised"}, + .expectation = {.accepted = true, .boss = "kyurem", .boss_if_caught = ""}, }, - // TODO: to be fixed: the boss is reported caught without a fourth win. { .input = {.name = "identified boss lost", .wins = 3, .opponent = {"kyurem"}, .boss = "kyurem", .final_wins = 3}, - .expectation = {.accepted = true, .boss = "kyurem", .boss_if_caught = "kyurem"}, + .expectation = {.accepted = true, .boss = "kyurem", .boss_if_caught = ""}, }, { .input = {.name = "identified boss caught", .wins = 3, .opponent = {"kyurem"}, .boss = "", .final_wins = 4}, @@ -97,25 +93,21 @@ const BossStateTestCase CASES[] = { .input = {.name = "boss before three wins must retry", .wins = 2, .opponent = {"kyurem"}, .boss = "", .final_wins = 2}, .expectation = {.accepted = false, .boss = "", .boss_if_caught = ""}, }, - // TODO: to be fixed: a boss stage with no opponent read is accepted. { - .input = {.name = "empty boss-stage read", .wins = 3, .opponent = {}, .boss = "", .final_wins = 3}, - .expectation = {.accepted = true, .boss = "", .boss_if_caught = ""}, + .input = {.name = "empty boss-stage read must retry", .wins = 3, .opponent = {}, .boss = "", .final_wins = 3}, + .expectation = {.accepted = false, .boss = "", .boss_if_caught = ""}, }, - // TODO: to be fixed: a two-candidate read is accepted and the first is taken as the boss. { - .input = {.name = "ambiguous boss-stage read", .wins = 3, .opponent = {"kyurem", "mimikyu-disguised"}, .boss = "", .final_wins = 3}, - .expectation = {.accepted = true, .boss = "kyurem", .boss_if_caught = "kyurem"}, + .input = {.name = "ambiguous boss-stage read must retry", .wins = 3, .opponent = {"kyurem", "mimikyu-disguised"}, .boss = "", .final_wins = 3}, + .expectation = {.accepted = false, .boss = "", .boss_if_caught = ""}, }, - // TODO: to be fixed: a rental read at the boss stage is accepted, and the boss is reported caught without a fourth win. { - .input = {.name = "rental read after known boss", .wins = 3, .opponent = {"mimikyu-disguised"}, .boss = "kyurem", .final_wins = 3}, - .expectation = {.accepted = true, .boss = "kyurem", .boss_if_caught = "kyurem"}, + .input = {.name = "rejected read preserves known boss", .wins = 3, .opponent = {"mimikyu-disguised"}, .boss = "kyurem", .final_wins = 3}, + .expectation = {.accepted = false, .boss = "kyurem", .boss_if_caught = ""}, }, - // TODO: to be fixed: a rental read at the boss stage is accepted and the rental is reported as the caught boss. { - .input = {.name = "fourth win after rental boss", .wins = 3, .opponent = {"mimikyu-disguised"}, .boss = "mimikyu-disguised", .final_wins = 4}, - .expectation = {.accepted = true, .boss = "mimikyu-disguised", .boss_if_caught = "mimikyu-disguised"}, + .input = {.name = "fourth win cannot legitimize rental boss", .wins = 3, .opponent = {"mimikyu-disguised"}, .boss = "mimikyu-disguised", .final_wins = 4}, + .expectation = {.accepted = false, .boss = "mimikyu-disguised", .boss_if_caught = ""}, }, }; diff --git a/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Options/PokemonSwSh_MaxLair_Options.h b/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Options/PokemonSwSh_MaxLair_Options.h index c6ce85547a..28fc60e5d7 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Options/PokemonSwSh_MaxLair_Options.h +++ b/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Options/PokemonSwSh_MaxLair_Options.h @@ -61,6 +61,7 @@ class EndBattleDecider{ virtual const std::string& boss_ball( size_t console_index, const std::string& boss_slug ) const = 0; + // boss_slug is empty when the adventure ended without catching the boss. virtual CaughtScreenAction end_adventure_action( size_t console_index, const std::string& boss_slug, const PathStats& path_stats, diff --git a/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Program/PokemonSwSh_MaxLair_Run_Battle.cpp b/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Program/PokemonSwSh_MaxLair_Run_Battle.cpp index ba8dcd4059..819f29cd81 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Program/PokemonSwSh_MaxLair_Run_Battle.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Program/PokemonSwSh_MaxLair_Run_Battle.cpp @@ -75,12 +75,9 @@ bool read_battle_menu( std::set mon = reader.read_opponent(stream.logger(), context, stream.video()); bool retry = !process_header_read(stream.logger(), state, std::move(mon)); - std::string opponent = state.opponent.empty() - ? "" - : *state.opponent.begin(); - // If we see a boss before the end. Something is wrong. Retry. - if (state.wins != 3 && is_boss(opponent)){ + // The fourth battle must be a boss; earlier battles must be rentals. + if (!state.accept_opponent()){ retry = true; } @@ -97,7 +94,7 @@ bool read_battle_menu( pbf_mash_button(context, BUTTON_B, 3000ms); state.opponent = std::move(mon); - if (state.wins == 3 && !state.boss.empty()){ + if (state.in_boss_battle_with_known_boss()){ if (!state.opponent.empty() && *state.opponent.begin() != state.boss){ stream.log( "Inconsistent Boss: Expected " + state.boss + ", Read: " + *state.opponent.begin(), @@ -111,8 +108,8 @@ bool read_battle_menu( if (!state.accept_opponent()){ - stream.log("Boss found before 3 wins. Something is seriously out-of-sync.", COLOR_RED); - dump_image(stream.logger(), MODULE_NAME, "BossBeforeEnd", snapshot); + stream.log("Opponent does not match the battle stage after summary read.", COLOR_RED); + dump_image(stream.logger(), MODULE_NAME, "UnexpectedBattleOpponent", snapshot); return false; } From aab6684308df3e2eb1a93405531def64a216be8c Mon Sep 17 00:00:00 2001 From: dayfine Date: Sat, 7 Nov 2026 20:28:08 -0800 Subject: [PATCH 2/3] Max Lair: preserve supported rental-form ambiguity Port the state fix and regressions from e17fba3fc in fork #172. Supported rental forms sharing one OCR species remain candidates before the boss stage; unrelated, unknown and boss-stage ambiguity still reject. Preserve the existing inline opponent-read flow. The 19 native state tests reproduced two failures before the fix and all pass after it. No console actions performed. --- .../Framework/PokemonSwSh_MaxLair_State.cpp | 28 ++++++++++++- .../Framework/PokemonSwSh_MaxLair_State.h | 8 ++-- .../PokemonSwSh_MaxLair_State_Tests.cpp | 40 +++++++++++++++++++ 3 files changed, 71 insertions(+), 5 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State.cpp b/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State.cpp index 5267153517..021cdff794 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State.cpp @@ -22,6 +22,29 @@ bool is_boss_battle(const GlobalState& state){ return state.wins == 3; } +// Some supported rental forms share an OCR species name even after the +// summary read (Lycanroc and Basculin). Preserve that candidate set rather +// than treating it as a stage mismatch. Unrelated/unknown species are not +// interchangeable, and every candidate must have AI data and be a non-boss. +bool compatible_rental_forms(const std::set& candidates){ + if (candidates.empty()){ + return false; + } + const auto& slugs = maxlair_slugs(); + const auto first = slugs.find(*candidates.begin()); + if (first == slugs.end() || first->second.name_slug.empty()){ + return false; + } + for (const std::string& slug : candidates){ + const auto found = slugs.find(slug); + if (found == slugs.end() || found->second.name_slug != first->second.name_slug || + is_boss(slug) || get_maxlair_mon_nothrow(slug) == nullptr){ + return false; + } + } + return true; +} + } // namespace bool GlobalState::in_boss_battle_with_known_boss() const{ @@ -29,9 +52,12 @@ bool GlobalState::in_boss_battle_with_known_boss() const{ } bool GlobalState::accept_opponent(){ - if (opponent.size() != 1){ + if (opponent.empty()){ return false; } + if (opponent.size() > 1){ + return wins < 3 && compatible_rental_forms(opponent); + } const std::string& opponent_slug = *opponent.begin(); // Reject the OCR read if the opponent species doesn't match the current stage: // a legendary boss read during battles 1-3, or a non-boss rental read in battle 4. diff --git a/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State.h b/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State.h index f0c51b8978..7ed8720f35 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State.h +++ b/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State.h @@ -175,10 +175,10 @@ struct GlobalState{ // True during the fourth (boss) battle when a boss has already been identified. bool in_boss_battle_with_known_boss() const; - // Returns false when the opponent read doesn't fit this battle stage (not - // exactly one opponent, or a boss before the fourth battle / a rental at - // it), so the caller retries the read. On an accepted read at the fourth - // battle, records the boss unless a boss is already known. + // Accepts one opponent matching this stage. Before the fourth battle, + // also accepts supported non-boss forms sharing one OCR species name, + // preserving the candidate set. Boss-stage reads still need one boss; + // records it unless a boss is already known. Otherwise retries the read. bool accept_opponent(); // The same boss, but only if the adventure caught it, else empty: for the diff --git a/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State_Tests.cpp index ebdd434f3a..aa38dd4c9e 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State_Tests.cpp @@ -56,6 +56,9 @@ class Test_MaxLairBossState : public UnitTest{ if (state.boss != expected.boss){ return std::format("Expected boss '{}', got '{}'", expected.boss, state.boss); } + if (state.opponent != input.opponent){ + return "Expected opponent candidates to be preserved."; + } state.wins = input.final_wins; const std::string caught = state.boss_if_caught(); if (caught != expected.boss_if_caught){ @@ -69,6 +72,43 @@ class Test_MaxLairBossState : public UnitTest{ }; const BossStateTestCase CASES[] = { + { + .input = {.name = "form ambiguity is only valid during rental battles", .wins = 4, .opponent = {"lycanroc-midday", "lycanroc-midnight"}, .boss = "nihilego", .final_wins = 4}, + .expectation = {.accepted = false, .boss = "nihilego", .boss_if_caught = "nihilego"}, + }, + { + .input = {.name = "Lycanroc forms at battle two", .wins = 1, .opponent = {"lycanroc-midday", "lycanroc-midnight"}, .boss = "nihilego", .final_wins = 1}, + .expectation = {.accepted = true, .boss = "nihilego", .boss_if_caught = ""}, + }, + { + .input = {.name = "Basculin forms at battle three", .wins = 2, .opponent = {"basculin-blue-striped", "basculin-red-striped"}, .boss = "nihilego", .final_wins = 2}, + .expectation = {.accepted = true, .boss = "nihilego", .boss_if_caught = ""}, + }, + { + .input = {.name = "rental forms cannot pass boss stage", .wins = 3, .opponent = {"lycanroc-midday", "lycanroc-midnight"}, .boss = "", .final_wins = 3}, + .expectation = {.accepted = false, .boss = "", .boss_if_caught = ""}, + }, + { + .input = {.name = "different rentals are not form ambiguity", .wins = 1, .opponent = {"lycanroc-midday", "magmar"}, .boss = "nihilego", .final_wins = 1}, + .expectation = {.accepted = false, .boss = "nihilego", .boss_if_caught = ""}, + }, + { + .input = {.name = "mixed boss and rental cannot pass rental stage", .wins = 1, .opponent = {"lycanroc-midday", "nihilego"}, .boss = "nihilego", .final_wins = 1}, + .expectation = {.accepted = false, .boss = "nihilego", .boss_if_caught = ""}, + }, + { + .input = {.name = "unknown form slug cannot pass", .wins = 1, .opponent = {"lycanroc-midday", "lycanroc-unknown"}, .boss = "nihilego", .final_wins = 1}, + .expectation = {.accepted = false, .boss = "nihilego", .boss_if_caught = ""}, + }, + { + .input = {.name = "empty rental read still rejects", .wins = 1, .opponent = {}, .boss = "nihilego", .final_wins = 1}, + .expectation = {.accepted = false, .boss = "nihilego", .boss_if_caught = ""}, + }, + { + .input = {.name = "multiple boss candidates cannot infer a boss", .wins = 3, .opponent = {"kyurem", "nihilego"}, .boss = "", .final_wins = 3}, + .expectation = {.accepted = false, .boss = "", .boss_if_caught = ""}, + }, + { .input = {.name = "rental before three wins", .wins = 2, .opponent = {"mimikyu-disguised"}, .boss = "", .final_wins = 3}, .expectation = {.accepted = true, .boss = "", .boss_if_caught = ""}, From 76266bac8d91436a0e29fdb89617bf18895d264a Mon Sep 17 00:00:00 2001 From: dayfine Date: Sat, 7 Nov 2026 23:43:42 -0800 Subject: [PATCH 3/3] Max Lair: keep going on an opponent misread instead of resetting A read that still doesn't fit the battle stage after the summary retry is almost always an OCR misread, and a wrong opponent only costs move choice. Log it and continue instead of resetting the adventure. The boss stays protected: accept_opponent() still never records a rental as the boss. Drop the rental-form whitelist: an ambiguous read is fine in a rental battle as long as no candidate is a boss, which is all that matters once a mismatch no longer resets. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../Framework/PokemonSwSh_MaxLair_State.cpp | 27 ++++++------------- .../Framework/PokemonSwSh_MaxLair_State.h | 8 +++--- .../PokemonSwSh_MaxLair_State_Tests.cpp | 8 ++---- .../PokemonSwSh_MaxLair_Run_Battle.cpp | 4 +-- 4 files changed, 17 insertions(+), 30 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State.cpp b/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State.cpp index 021cdff794..6ace91caef 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State.cpp @@ -22,27 +22,13 @@ bool is_boss_battle(const GlobalState& state){ return state.wins == 3; } -// Some supported rental forms share an OCR species name even after the -// summary read (Lycanroc and Basculin). Preserve that candidate set rather -// than treating it as a stage mismatch. Unrelated/unknown species are not -// interchangeable, and every candidate must have AI data and be a non-boss. -bool compatible_rental_forms(const std::set& candidates){ - if (candidates.empty()){ - return false; - } - const auto& slugs = maxlair_slugs(); - const auto first = slugs.find(*candidates.begin()); - if (first == slugs.end() || first->second.name_slug.empty()){ - return false; - } +bool has_boss_candidate(const std::set& candidates){ for (const std::string& slug : candidates){ - const auto found = slugs.find(slug); - if (found == slugs.end() || found->second.name_slug != first->second.name_slug || - is_boss(slug) || get_maxlair_mon_nothrow(slug) == nullptr){ - return false; + if (is_boss(slug)){ + return true; } } - return true; + return false; } } // namespace @@ -56,7 +42,10 @@ bool GlobalState::accept_opponent(){ return false; } if (opponent.size() > 1){ - return wins < 3 && compatible_rental_forms(opponent); + // Forms sharing one OCR species name (Lycanroc, Basculin) stay + // ambiguous even after the summary read. That is fine for a rental + // battle as long as no candidate is a boss. It cannot identify the boss. + return wins < 3 && !has_boss_candidate(opponent); } const std::string& opponent_slug = *opponent.begin(); // Reject the OCR read if the opponent species doesn't match the current stage: diff --git a/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State.h b/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State.h index 7ed8720f35..8f28058667 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State.h +++ b/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State.h @@ -176,9 +176,11 @@ struct GlobalState{ bool in_boss_battle_with_known_boss() const; // Accepts one opponent matching this stage. Before the fourth battle, - // also accepts supported non-boss forms sharing one OCR species name, - // preserving the candidate set. Boss-stage reads still need one boss; - // records it unless a boss is already known. Otherwise retries the read. + // also accepts an ambiguous read with no boss candidate, preserving the + // candidate set. Boss-stage reads still need one boss; records it unless + // a boss is already known. Returns false for a read that doesn't fit: + // the caller retries it through the summary, and keeps going if it + // still doesn't fit. A misread is not a reason to reset the adventure. bool accept_opponent(); // The same boss, but only if the adventure caught it, else empty: for the diff --git a/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State_Tests.cpp index aa38dd4c9e..666472b9ac 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State_Tests.cpp @@ -89,17 +89,13 @@ const BossStateTestCase CASES[] = { .expectation = {.accepted = false, .boss = "", .boss_if_caught = ""}, }, { - .input = {.name = "different rentals are not form ambiguity", .wins = 1, .opponent = {"lycanroc-midday", "magmar"}, .boss = "nihilego", .final_wins = 1}, - .expectation = {.accepted = false, .boss = "nihilego", .boss_if_caught = ""}, + .input = {.name = "two different rentals at battle two", .wins = 1, .opponent = {"lycanroc-midday", "magmar"}, .boss = "nihilego", .final_wins = 1}, + .expectation = {.accepted = true, .boss = "nihilego", .boss_if_caught = ""}, }, { .input = {.name = "mixed boss and rental cannot pass rental stage", .wins = 1, .opponent = {"lycanroc-midday", "nihilego"}, .boss = "nihilego", .final_wins = 1}, .expectation = {.accepted = false, .boss = "nihilego", .boss_if_caught = ""}, }, - { - .input = {.name = "unknown form slug cannot pass", .wins = 1, .opponent = {"lycanroc-midday", "lycanroc-unknown"}, .boss = "nihilego", .final_wins = 1}, - .expectation = {.accepted = false, .boss = "nihilego", .boss_if_caught = ""}, - }, { .input = {.name = "empty rental read still rejects", .wins = 1, .opponent = {}, .boss = "nihilego", .final_wins = 1}, .expectation = {.accepted = false, .boss = "nihilego", .boss_if_caught = ""}, diff --git a/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Program/PokemonSwSh_MaxLair_Run_Battle.cpp b/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Program/PokemonSwSh_MaxLair_Run_Battle.cpp index 819f29cd81..7e2993b8d0 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Program/PokemonSwSh_MaxLair_Run_Battle.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Program/PokemonSwSh_MaxLair_Run_Battle.cpp @@ -107,10 +107,10 @@ bool read_battle_menu( context.wait_for_all_requests(); + // Probably a misread. It only costs move choice; a reset would cost the adventure. if (!state.accept_opponent()){ - stream.log("Opponent does not match the battle stage after summary read.", COLOR_RED); + stream.log("Opponent does not match the battle stage after summary read. Continuing.", COLOR_RED); dump_image(stream.logger(), MODULE_NAME, "UnexpectedBattleOpponent", snapshot); - return false; } // Read misc.