diff --git a/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Program/PokemonSwSh_MaxLair_Run_EnterLobby.cpp b/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Program/PokemonSwSh_MaxLair_Run_EnterLobby.cpp index ffebd58916..1ab99b6abb 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Program/PokemonSwSh_MaxLair_Run_EnterLobby.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Program/PokemonSwSh_MaxLair_Run_EnterLobby.cpp @@ -8,11 +8,13 @@ #include "CommonFramework/ImageTypes/ImageRGB32.h" #include "CommonFramework/ImageTools/ImageStats.h" #include "CommonFramework/VideoPipeline/VideoFeed.h" +#include "Common/Cpp/TestRunners/UnitTestDatabase.h" #include "CommonTools/Images/ImageManip.h" #include "CommonTools/Images/ImageFilter.h" #include "CommonTools/Images/SolidColorTest.h" #include "CommonTools/Async/InferenceRoutines.h" #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" +#include "Tests/ImageUnitTest.h" #include "VideoGames/PokemonSwSh/Inference/PokemonSwSh_SelectionArrowFinder.h" #include "VideoGames/PokemonSwSh/Inference/PokemonSwSh_DialogBoxDetector.h" #include "VideoGames/PokemonSwSh/Inference/PokemonSwSh_YCommDetector.h" @@ -88,7 +90,11 @@ std::shared_ptr enter_lobby( // dialog_detector.make_overlays(boxes); // OverlayBoxScope ore_box(stream.overlay(), {0.900, 0.015, 0.020, 0.040}); - OverlayBoxScope ore_box(stream.overlay(), {0.930, 0.050, 0.065, 0.010}); + // The top of the ore bar sits just below the "xNNN" ore counter. Start the box 2 px below the + // counter: on some capture cards the block-compression ringing of the digits bleeds into the + // first two rows, pushing the stddev sum right up against the is_solid limit so the prompt + // is missed (and then "Boss Slot" silently falls back to Slot 1, see issue #1925). + OverlayBoxScope ore_box(stream.overlay(), {0.930, 0.052, 0.065, 0.008}); OverlayBoxScope ore_quantity(stream.overlay(), {0.945, 0.010, 0.0525, 0.050}); size_t arrow_count = 0; @@ -222,6 +228,42 @@ std::shared_ptr enter_lobby( + +// The ore-payment prompt check of enter_lobby(): the bar behind the "pay N ore?" dialog is a +// solid warm color. Regression test for #1925: on captures where the "xNNN" ore counter above +// the bar causes block-compression ringing, the check used to sit right at the is_solid stddev +// limit, so the prompt was missed and "Boss Slot" silently fell back to Slot 1. +class Test_MaxLairEnterLobbyOrePrompt : public ImageUnitTest{ +public: + Test_MaxLairEnterLobbyOrePrompt(const std::string& image) + : ImageUnitTest("PokemonSwSh::MaxLairEnterLobbyOrePrompt - " + image, {image}) + , m_check(0.930, 0.052, 0.065, 0.008, 0.594724, 0.405276, 0.) + {} + + virtual UnitTestResult run_on_images( + Logger& logger, CancellableScope& scope, + const std::vector& images + ) const override{ + const ImageRGB32& image = images[0]; + bool detected = m_check.check(image); + if (detected){ + return UnitTestResult(true); + } + return UnitTestResult(UnitTestResult::FAILED, m_check.debug_string(image)); + } + +private: + ImageSolidCheck m_check; +}; + + + + +void add_tests_MaxLairEnterLobbyOrePrompt(UnitTestDatabase& database){ + database.add( + "PokemonSwSh/MaxLair_EnterLobbyOrePrompt/MiraBox_macOS_Japanese_OrePaymentPrompt.png" + ); +} } } } diff --git a/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Program/PokemonSwSh_MaxLair_Run_EnterLobby.h b/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Program/PokemonSwSh_MaxLair_Run_EnterLobby.h index c8ce84bf0d..f1152f95ee 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Program/PokemonSwSh_MaxLair_Run_EnterLobby.h +++ b/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Program/PokemonSwSh_MaxLair_Run_EnterLobby.h @@ -12,6 +12,7 @@ #include "CommonFramework/Tools/VideoStream.h" #include "NintendoSwitch/Controllers/Procon/NintendoSwitch_ProController.h" #include "VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_StateMachine.h" +#include "Common/Cpp/TestRunners/UnitTest.h" namespace PokemonAutomation{ namespace NintendoSwitch{ @@ -28,6 +29,10 @@ std::shared_ptr enter_lobby( +void add_tests_MaxLairEnterLobbyOrePrompt(UnitTestDatabase& database); + + + } } } diff --git a/SerialPrograms/Source/VideoGames/PokemonSwSh/PokemonSwSh_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonSwSh/PokemonSwSh_Tests.cpp index a6190002a1..2d7794491f 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSwSh/PokemonSwSh_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSwSh/PokemonSwSh_Tests.cpp @@ -14,6 +14,7 @@ #include "VideoGames/PokemonSwSh/Inference/PokemonSwSh_SelectionArrowFinder.h" #include "VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State_Tests.h" #include "VideoGames/PokemonSwSh/MaxLair/Inference/PokemonSwSh_MaxLair_Detect_BattleMenu.h" +#include "VideoGames/PokemonSwSh/MaxLair/Program/PokemonSwSh_MaxLair_Run_EnterLobby.h" #include "PokemonSwSh_Tests.h" namespace PokemonAutomation{ @@ -31,6 +32,7 @@ void add_tests(UnitTestDatabase& database){ NintendoSwitch::PokemonSwSh::add_tests_YCommDetector(database); NintendoSwitch::PokemonSwSh::add_tests_SelectionArrowFinder(database); NintendoSwitch::PokemonSwSh::MaxLairInternal::add_tests_MaxLairBattleMenuDetector(database); + NintendoSwitch::PokemonSwSh::MaxLairInternal::add_tests_MaxLairEnterLobbyOrePrompt(database); NintendoSwitch::PokemonSwSh::MaxLairInternal::add_tests_MaxLairBossState(database); }