Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
003d11b
FRLG AutoStory: segment 17 WIP (17.01-17.04 plans, spin glyph tiles, …
dayfine Nov 13, 2026
9f3ad9c
FRLG AutoStory: segment 17 WIP 2
dayfine Nov 13, 2026
d157785
FRLG AutoStory: Viridian tests, format a message
dayfine Nov 13, 2026
fa5ad13
Merge remote-tracking branch 'origin/frlg/stage14a-blaine' into frlg/…
dayfine Nov 13, 2026
12bc566
Merge frlg/stage14a-blaine into frlg/stage17-viridian (12.01 floor)
dayfine Nov 13, 2026
f6674f5
Merge frlg/stage14a-blaine into frlg/stage17-viridian (Mart item names)
dayfine Nov 13, 2026
4452b42
Merge frlg/stage14a-blaine into frlg/stage17-viridian (12.01 fills 5 …
dayfine Nov 13, 2026
b8f38c2
Merge branch 'm-stage14a-blaine' into m-stage17-viridian
dayfine Nov 13, 2026
bc55072
Merge branch 'm-stage14a-blaine' into m-stage17-viridian
dayfine Nov 13, 2026
08ea194
Merge branch 'm-stage14a-blaine' into m-stage17-viridian
dayfine Nov 13, 2026
928b86f
Merge frlg/stage14a-blaine into frlg/stage17-viridian
dayfine Nov 13, 2026
446026f
Merge branch 'frlg/stage14a-blaine' into frlg/stage17-viridian
dayfine Nov 13, 2026
5e73245
Merge remote-tracking branch 'origin/frlg/stage14a-blaine' into frlg/…
dayfine Nov 13, 2026
21f330c
Merge remote-tracking branch 'origin/frlg/stage14a-blaine' into HEAD
dayfine Nov 13, 2026
c231ca1
Merge frlg/stage14a-blaine into frlg/stage17-viridian
dayfine Nov 13, 2026
ea3739f
Merge frlg/stage14a-blaine (12.02 split) into stage17-viridian
dayfine Nov 13, 2026
f833285
Merge frlg/stage14a-blaine (14.02 split) into frlg/stage17-viridian
dayfine Nov 13, 2026
625c5ca
Merge frlg/stage14a-blaine (14.04 split) into frlg/stage17-viridian
dayfine Nov 13, 2026
4241acb
FRLG AutoStory: the chain test expects 70 checkpoints (the split's me…
dayfine Nov 13, 2026
22764e8
FRLG 17.04: Giovanni alone; the walk out and the heal are 17.04b
dayfine Nov 13, 2026
a287974
Merge remote-tracking branch 'origin/frlg/stage14a-blaine' into HEAD
dayfine Nov 13, 2026
d2bf596
Merge frlg/stage14a-blaine into frlg/stage17-viridian
dayfine Nov 13, 2026
ca40dfa
FRLG AutoStory: 70 checkpoints without 17.01; trim Viridian test incl…
dayfine Nov 13, 2026
1268869
Merge origin/frlg/stage14a-blaine into frlg/stage17-viridian
dayfine Nov 13, 2026
cc2af6a
Merge frlg/stage14a-blaine into frlg/stage17-viridian: upstream #1881…
dayfine Nov 13, 2026
6e1c6ba
Merge remote-tracking branch 'origin/frlg/stage14a-blaine' into HEAD
dayfine Nov 14, 2026
7bf13fe
Merge frlg/stage14a-blaine into frlg/stage17-viridian
dayfine Nov 14, 2026
9528572
Merge frlg/stage14a-blaine into frlg/stage17-viridian
dayfine Nov 14, 2026
ab06c92
Merge frlg/stage14a-blaine into frlg/stage17-viridian
dayfine Nov 14, 2026
995f197
Merge origin/frlg/stage14a-blaine into frlg/stage17-viridian
dayfine Nov 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@
} // namespace

std::optional<Direction> spin_direction(const MapData& map, const TilePos& point){
if (const std::optional<Direction> coded = coded_spin_direction(map.name, point)){

Check warning on line 260 in SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

PokemonAutomation::NintendoSwitch::PokemonFRLG::spin_direction( const MapData & map , const TilePos & point): function_lines=29 (advisory above 25, limit 50)
return coded;
}
static const std::pair<std::string_view, Direction> ARROWS[] = {
Expand All @@ -271,10 +271,24 @@
return direction;
}
}
return std::nullopt;
// A map file's own glyphs (Viridian Gym).
switch (tile_at(map, point)){
case TileKind::SPIN_NORTH:
return Direction::NORTH;
case TileKind::SPIN_SOUTH:
return Direction::SOUTH;
case TileKind::SPIN_WEST:
return Direction::WEST;
case TileKind::SPIN_EAST:
return Direction::EAST;
default:
return std::nullopt;
}
}
bool stops_spinning(const MapData& map, const TilePos& point){
return coded_spin_stop(map.name, point) || in_region(map, SPIN_STOP_REGION, point);
return coded_spin_stop(map.name, point)
|| in_region(map, SPIN_STOP_REGION, point)
|| tile_at(map, point) == TileKind::STOP_SPIN;
}

std::optional<SpinSlide> spin_slide(const MapData& map, const PlayerState& state){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,11 @@ constexpr std::string_view MAP_NAMES[] = {
// Route 21 north of it to Pallet Town (12.03).
"CinnabarIsland",
"CinnabarIsland_Gym",
// Route 21 from Pallet Town south to Cinnabar (12.03), and Viridian Gym with its
// spinner tiles (the map file's glyphs: PokemonFRLG_OverworldSpin.h).
"Route21_North",
"Route21_South",
"ViridianCity_Gym",
// Silph Co.'s floors, 1F to 11F (the lift's map, SilphCo_Elevator, is
// not built in).
"SilphCo_1F",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ namespace PokemonFRLG{

// Spinner tiles (Rocket Hideout B2F and B3F, Viridian Gym): pokefirered's
// MB_SPIN_UP, MB_SPIN_DOWN, MB_SPIN_LEFT, MB_SPIN_RIGHT and
// MB_STOP_SPINNING. The tile glyphs can't say so: the hideout's floors
// have them coded (coded_spin_direction(), PokemonFRLG_CodedRooms.h);
// another map may list them in these regions, as it does WILD_REGION.
// MB_STOP_SPINNING. The hideout's floors have them coded
// (coded_spin_direction(), PokemonFRLG_CodedRooms.h); Viridian Gym's map
// file writes them as glyphs ('u', 'd', 'l', 'r' and the stop 'o'); another
// map may list them in these regions, as it does WILD_REGION.
// "spin_north": MB_SPIN_UP.
// "spin_south": MB_SPIN_DOWN.
// "spin_west": MB_SPIN_LEFT.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#include "Programs/AutoStory/PokemonFRLG_AutoStoryRows15_Tests.h"
#include "Programs/AutoStory/PokemonFRLG_AutoStoryRows13_Tests.h"
#include "Programs/AutoStory/PokemonFRLG_AutoStoryRows16_Tests.h"
#include "Programs/AutoStory/PokemonFRLG_AutoStoryRows17_Tests.h"
#include "Programs/AutoStory/PokemonFRLG_AutoStoryTable.h"
#include "Programs/AutoStory/PokemonFRLG_AutoStoryTrashCans.h"
#include "Programs/AutoStory/Data/Json_Tests.h"
Expand Down Expand Up @@ -118,6 +119,7 @@ static void add_tests_AutoStoryRows(UnitTestDatabase& database){
add_tests_AutoStoryCinnabarGym(database);
add_tests_AutoStorySilph(database);
add_tests_AutoStoryMansion(database);
add_tests_AutoStoryViridian(database);
}

void add_tests(UnitTestDatabase& database){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* AutoStory Fault Sweep Tests

Check warning on line 1 in SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFaultSweep_Tests.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

<file>: file_lines=808 (advisory above 500, limit 1000)
*
* From: https://github.com/PokemonAutomation/
*
Expand Down Expand Up @@ -132,6 +132,8 @@
"fly_pallet: a Fly that doesn't leave Fuchsia City goes unseen, and the row, which walks on from Fuchsia's streets to Pallet's shore, ends on Cinnabar's nurse tile: the same fix as 11.01's, the fly landing on its town's tile (FlyTown::landing) checked before the step ends"},
{"PokemonFRLG::AutoStory - Fault sweep: 14.03, warp no-op",
"fly_celadon: a Fly that doesn't leave Cinnabar Island goes unseen, and the row, which walks on from Celadon's heal spot, ends below Erika: the same fix as 11.01's, the fly landing on its town's tile (FlyTown::landing) checked before the step ends"},
{"PokemonFRLG::AutoStory - Fault sweep: 17.02, warp no-op",
"fly_viridian: a Fly that doesn't leave Saffron City goes unseen, and the row, which walks on from Saffron's streets, ends on Viridian's Gym tile: the same fix as 11.01's, the fly landing on its town's tile (FlyTown::landing) checked before the step ends"},
{"PokemonFRLG::AutoStory - Fault sweep: 08.03, off the Bicycle at a bike leg",
"riding with no fault, route7_underground_exit's warp to UndergroundPath_EastEntrance is not confirmed on the sim (the screen after the fade reads as before the hold): the sim's warp off the Bicycle, before this class can sweep 08.03"},
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/* FRLG AutoStory Plan Golden, Segment 17
*
* From: https://github.com/PokemonAutomation/
*
* The golden's lines for 17.02 to 17.04 (after PokemonFRLG_AutoStoryPlanGolden16.h's),
* in the story's order.
*
*/

#ifndef PokemonAutomation_PokemonFRLG_AutoStoryPlanGolden17_H
#define PokemonAutomation_PokemonFRLG_AutoStoryPlanGolden17_H

#include <string_view>

namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonFRLG{

// The stored plan lines of 17.02 to 17.04, Saffron to Viridian Gym.
inline constexpr std::string_view FRLG_PLAN_GOLDEN_17_GYM[] = {
"17.02 saffron_outside from SaffronCity_PokemonCenter_1F (7, 4) facing north to SaffronCity (24, 39) facing south",
"17.02 walk south 5 (warp) -> SaffronCity (24, 39) [walk only]",
"17.02 below_gym_door from ViridianCity (26, 27) facing south to ViridianCity (36, 11) facing north",
"17.02 walk west 4 -> ViridianCity (22, 27)",
"17.02 walk north 21 -> ViridianCity (22, 6)",
"17.02 walk east 19 (to wall) -> ViridianCity (41, 6)",
"17.02 walk south 5 -> ViridianCity (41, 11)",
"17.02 walk west 5 -> ViridianCity (36, 11)",
"17.02 face north -> ViridianCity (36, 11)",
"17.02 below_warren_line from ViridianCity_Gym (17, 22) facing north to ViridianCity_Gym (15, 8) facing north",
"17.02 walk north 7 (to wall) -> ViridianCity_Gym (17, 15) [walk only]",
"17.02 walk west 3 (to wall) -> ViridianCity_Gym (14, 15) [walk only]",
"17.02 walk north 2 (to wall) -> ViridianCity_Gym (14, 13) [walk only]",
"17.02 walk west 1 -> ViridianCity_Gym (13, 13) [walk only]",
"17.02 walk north 3 (to wall) -> ViridianCity_Gym (13, 10) [walk only]",
"17.02 walk east 3 (to wall) -> ViridianCity_Gym (16, 10) [walk only]",
"17.02 walk north 2 -> ViridianCity_Gym (16, 8) [walk only]",
"17.02 walk west 1 (to wall) -> ViridianCity_Gym (15, 8) [walk only]",
"17.02 face north -> ViridianCity_Gym (15, 8) [walk only]",
"17.03 below_takashi_line from ViridianCity_Gym (15, 7) facing north to ViridianCity_Gym (10, 6) facing north",
"17.03 walk north 1 (to wall) -> ViridianCity_Gym (15, 6) [walk only]",
"17.03 walk west 3 (to wall) -> ViridianCity_Gym (12, 6) [walk only]",
"17.03 walk south 1 (to wall) -> ViridianCity_Gym (12, 7) [walk only]",
"17.03 walk west 2 (to wall) -> ViridianCity_Gym (10, 7) [walk only]",
"17.03 walk north 1 -> ViridianCity_Gym (10, 6) [walk only]",
"17.03 below_giovanni from ViridianCity_Gym (10, 5) facing north to ViridianCity_Gym (2, 3) facing north",
"17.03 walk north 2 -> ViridianCity_Gym (10, 3) [walk only]",
"17.03 walk west 3 -> ViridianCity_Gym (7, 3) [walk only]",
"17.03 walk south 3 (to wall) -> ViridianCity_Gym (7, 6) [walk only]",
"17.03 walk west 5 -> ViridianCity_Gym (2, 6) [walk only]",
"17.03 walk north 3 -> ViridianCity_Gym (2, 3) [walk only]",
"17.04b gym_exit from ViridianCity_Gym (2, 3) facing north to ViridianCity (36, 11) facing south",
"17.04b walk south 4 (to wall) -> ViridianCity_Gym (2, 7) [walk only]",
"17.04b walk east 4 (to wall) -> ViridianCity_Gym (6, 7) [walk only]",
"17.04b walk north 1 (to wall) -> ViridianCity_Gym (6, 6) [walk only]",
"17.04b walk east 1 (to wall) -> ViridianCity_Gym (7, 6) [walk only]",
"17.04b walk north 3 -> ViridianCity_Gym (7, 3) [walk only]",
"17.04b walk east 4 (spins 6) -> ViridianCity_Gym (17, 3) [walk only]",
"17.04b walk east 1 (spins 11) -> ViridianCity_Gym (18, 14) [walk only]",
"17.04b walk south 8 (to wall) -> ViridianCity_Gym (18, 22) [walk only]",
"17.04b walk west 1 -> ViridianCity_Gym (17, 22) [walk only] [tapped]",
"17.04b walk south 1 (warp) -> ViridianCity (36, 11) [walk only]",
"17.04b below_center_door from ViridianCity (36, 11) facing south to ViridianCity (26, 27) facing north",
"17.04b walk east 5 (to wall) -> ViridianCity (41, 11)",
"17.04b walk north 7 (to wall) -> ViridianCity (41, 4)",
"17.04b walk west 13 (to wall) -> ViridianCity (28, 4)",
"17.04b walk south 4 (to wall) -> ViridianCity (28, 8)",
"17.04b walk west 6 -> ViridianCity (22, 8)",
"17.04b walk south 19 -> ViridianCity (22, 27)",
"17.04b walk east 4 -> ViridianCity (26, 27)",
"17.04b face north -> ViridianCity (26, 27)",
};

} // namespace PokemonFRLG
} // namespace NintendoSwitch
} // namespace PokemonAutomation
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* AutoStory Row Tests, Segment 17
*
* From: https://github.com/PokemonAutomation/
*
* Registration of the tests that run segment 17's rows (Saffron to
* Cinnabar by Fly and Surf, and Viridian Gym) on the overworld sim.
*
*/

#ifndef PokemonAutomation_PokemonFRLG_AutoStoryRows17_Tests_H
#define PokemonAutomation_PokemonFRLG_AutoStoryRows17_Tests_H

#include "Common/Cpp/TestRunners/UnitTestDatabase.h"

namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonFRLG{


// Rows 17.02 to 17.04b and Viridian Gym's spinner tiles, on the overworld sim (PokemonFRLG_AutoStoryViridian_Tests.cpp).
void add_tests_AutoStoryViridian(UnitTestDatabase& database);


} // namespace PokemonFRLG
} // namespace NintendoSwitch
} // namespace PokemonAutomation
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* AutoStory Run Plan Tests

Check warning on line 1 in SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRunPlan_Tests.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

<file>: file_lines=662 (advisory above 500, limit 1000)
*
* From: https://github.com/PokemonAutomation/
*
Expand Down Expand Up @@ -145,7 +145,7 @@
const RunPlanScenario m_scenario;
};

const std::string TODAY = "01.01 01.03 01.04 01.05 02.01 02.02 02.03 03.01 03.02 03.03 04.01 04.02 04.04 04.05 04.06 05.01 05.02 05.03 05.04 05.05 05.06 05.07 05.08 05.09 05.10 06.01 06.02 06.03 06.04 07.01 07.02 08.01 08.02 08.03 09.01 09.02 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 12.02b 12.03 13.01 13.02 13.03 13.04 14.01 14.02 14.02b 14.03 14.04 14.04b 15.01 16.01";
const std::string TODAY = "01.01 01.03 01.04 01.05 02.01 02.02 02.03 03.01 03.02 03.03 04.01 04.02 04.04 04.05 04.06 05.01 05.02 05.03 05.04 05.05 05.06 05.07 05.08 05.09 05.10 06.01 06.02 06.03 06.04 07.01 07.02 08.01 08.02 08.03 09.01 09.02 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 12.02b 12.03 13.01 13.02 13.03 13.04 14.01 14.02 14.02b 14.03 14.04 14.04b 15.01 16.01 17.02 17.03 17.04 17.04b";

const RunPlanScenario RUN_PLAN_CASES[] = {
{
Expand Down Expand Up @@ -236,11 +236,11 @@
},
{
.input = {.name = "Gift RNG off: 04.03 is passed over", .first = "04.01"},
.expectation = {.expected_ids = "04.01 04.02 04.04 04.05 04.06 05.01 05.02 05.03 05.04 05.05 05.06 05.07 05.08 05.09 05.10 06.01 06.02 06.03 06.04 07.01 07.02 08.01 08.02 08.03 09.01 09.02 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 12.02b 12.03 13.01 13.02 13.03 13.04 14.01 14.02 14.02b 14.03 14.04 14.04b 15.01 16.01"},
.expectation = {.expected_ids = "04.01 04.02 04.04 04.05 04.06 05.01 05.02 05.03 05.04 05.05 05.06 05.07 05.08 05.09 05.10 06.01 06.02 06.03 06.04 07.01 07.02 08.01 08.02 08.03 09.01 09.02 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 12.02b 12.03 13.01 13.02 13.03 13.04 14.01 14.02 14.02b 14.03 14.04 14.04b 15.01 16.01 17.02 17.03 17.04 17.04b"},
},
{
.input = {.name = "Gift RNG off: 04.03 runs when started at", .first = "04.03"},
.expectation = {.expected_ids = "04.03 04.04 04.05 04.06 05.01 05.02 05.03 05.04 05.05 05.06 05.07 05.08 05.09 05.10 06.01 06.02 06.03 06.04 07.01 07.02 08.01 08.02 08.03 09.01 09.02 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 12.02b 12.03 13.01 13.02 13.03 13.04 14.01 14.02 14.02b 14.03 14.04 14.04b 15.01 16.01"},
.expectation = {.expected_ids = "04.03 04.04 04.05 04.06 05.01 05.02 05.03 05.04 05.05 05.06 05.07 05.08 05.09 05.10 06.01 06.02 06.03 06.04 07.01 07.02 08.01 08.02 08.03 09.01 09.02 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 12.02b 12.03 13.01 13.02 13.03 13.04 14.01 14.02 14.02b 14.03 14.04 14.04b 15.01 16.01 17.02 17.03 17.04 17.04b"},
},
{
.input = { .name = "Gift RNG: started at 04.03, from the save beside the salesman",
Expand Down Expand Up @@ -279,7 +279,7 @@
},
{
.input = {.name = "Starter RNG alone: 04.03 runs when started at", .first = "04.03", .handoffs = {.starter_rng = true}},
.expectation = {.expected_ids = "04.03 04.04 04.05 04.06 05.01 05.02 05.03 05.04 05.05 05.06 05.07 05.08 05.09 05.10 06.01 06.02 06.03 06.04 07.01 07.02 08.01 08.02 08.03 09.01 09.02 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 12.02b 12.03 13.01 13.02 13.03 13.04 14.01 14.02 14.02b 14.03 14.04 14.04b 15.01 16.01"},
.expectation = {.expected_ids = "04.03 04.04 04.05 04.06 05.01 05.02 05.03 05.04 05.05 05.06 05.07 05.08 05.09 05.10 06.01 06.02 06.03 06.04 07.01 07.02 08.01 08.02 08.03 09.01 09.02 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 12.02b 12.03 13.01 13.02 13.03 13.04 14.01 14.02 14.02b 14.03 14.04 14.04b 15.01 16.01 17.02 17.03 17.04 17.04b"},
},
{
.input = { .name = "Starter RNG first, with both on",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ constexpr std::string_view STORY_ORDER[] = {
"12.01", "12.02", "12.02b", "12.03",
"13.01", "13.02", "13.03", "13.04", "14.01", "14.02", "14.02b",
"14.03", "14.04", "14.04b", "15.01", "16.01",
"17.02", "17.03", "17.04", "17.04b",
};

// `checkpoints` in STORY_ORDER's order. Throws ParseException for a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ namespace PokemonFRLG{
// Whether checkpoint `id` was authored before the rows that lead up to it:
// it starts from its own declared pose, not where the row before it in
// the story's order (STORY_ORDER in PokemonFRLG_AutoStoryTable.cpp) ends.
// 14.01 starts outside the Pokemon Mansion, after its Escape Rope (13.04),
// which is not authored. An id leaves this list once the rows before it are
// in.
// 17.02 starts at Saffron's Center nurse, where no row before it in the
// order ends (Silph Co.'s 16.01 ends on a pad on 5F; the rest of Silph Co.
// and Sabrina are not authored). 14.01 starts outside the Pokemon Mansion,
// after its Escape Rope (13.04), which is not authored. An id leaves this
// list once the rows before it are in.
inline bool starts_after_unauthored_rows(std::string_view id){
return id == "14.01";
return id == "17.02" || id == "14.01";
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/* AutoStory Viridian Tests
*
* From: https://github.com/PokemonAutomation/
*
* Viridian Gym's spinner tiles (rows 17.02 to 17.04b,
* StoryData/frlg-17.0N.plan.json) on the overworld sim.
*
*/

#include <format>
#include <functional>
#include <optional>
#include <string>
#include <string_view>
#include <vector>
#include "Common/Cpp/Exceptions.h"
#include "Common/Cpp/TestRunners/UnitTest.h"
#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h"
#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h"
#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSpin.h"
#include "PokemonFRLG_AutoStoryRowSim.h"
#include "PokemonFRLG_AutoStoryRows_Tests.h"
#include "PokemonFRLG_AutoStoryRows17_Tests.h"
#include "PokemonFRLG_AutoStoryTable.h"

namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonFRLG{


namespace{

struct AutoStoryViridianInput{
std::string name;
std::function<UnitTestResult()> body;
};

struct AutoStoryViridianExpectation{
std::string_view description;
};

struct AutoStoryViridianCase{
AutoStoryViridianInput input;
AutoStoryViridianExpectation expectation;
};

class Test_AutoStoryViridian : public UnitTest{

Check failure on line 47 in SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryViridian_Tests.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health

test-case: construct each UnitTest from one case struct with name, input and expectation fields (input and expectation structs, the name outside the input); register a named table of designated cases in a range-for
public:
explicit Test_AutoStoryViridian(AutoStoryViridianCase test_case)
: UnitTest(std::format("PokemonFRLG::AutoStory - Simulation: {}", test_case.input.name))
, m_case(std::move(test_case))
{}
virtual UnitTestResult run(Logger&, CancellableScope&) const override{
try{
return m_case.input.body();
}catch (Exception& e){
return std::format("{}: {}", e.name(), e.message());
}
}

private:
AutoStoryViridianCase m_case;
};

// Viridian Gym's arrow tiles (the map file's glyphs): stepped onto, the
// player slides until a stop tile or a wall, turned by each arrow met.
UnitTestResult check_gym_slide(const TilePos& from, const TilePos& end, Direction facing, int tiles){
const MapData* gym = nullptr;
for (const MapData& map : story_maps()){
if (map.name == "ViridianCity_Gym"){
gym = &map;
}
}
if (gym == nullptr){
return "No ViridianCity_Gym map.";
}
const std::optional<SpinSlide> slide = spin_slide(*gym, PlayerState{from, ELEVATION_GROUND, false});
if (!slide){
return std::format("No slide from {}.", to_string(from));
}
if (!(slide->end.position == end) || slide->facing != facing || slide->tiles != tiles){
return std::format(
"From {}: slid {} tile(s) to {} facing {}; expected {} to {} facing {}.",
to_string(from), slide->tiles, to_string(slide->end.position), direction_name(slide->facing),
tiles, to_string(end), direction_name(facing)
);
}
return true;
}

UnitTestResult test_gym_east_arrow(){
return check_gym_slide({11, 3}, {17, 3}, Direction::EAST, 6);
}
UnitTestResult test_gym_south_arrow_chain(){
return check_gym_slide({18, 3}, {18, 14}, Direction::SOUTH, 11);
}
UnitTestResult test_gym_north_arrow(){
return check_gym_slide({0, 20}, {0, 11}, Direction::NORTH, 9);
}

const AutoStoryViridianCase AUTO_STORY_VIRIDIAN_CASES[] = {
{
.input = {.name = "Viridian Gym: the east arrow at (11, 3) slides to its stop", .body = test_gym_east_arrow},
.expectation = {.description = "6 tiles east to (17, 3)"},
},
{
.input = {.name = "Viridian Gym: the south arrows at (18, 3) slide to the stop below", .body = test_gym_south_arrow_chain},
.expectation = {.description = "11 tiles south to (18, 14)"},
},
{
.input = {.name = "Viridian Gym: the north arrow at (0, 20) slides to its stop", .body = test_gym_north_arrow},
.expectation = {.description = "9 tiles north to (0, 11)"},
},
};

} // namespace


void add_tests_AutoStoryViridian(UnitTestDatabase& database){
for (const auto& item : AUTO_STORY_VIRIDIAN_CASES){
database.add<Test_AutoStoryViridian>(item);
}
}



} // namespace PokemonFRLG
} // namespace NintendoSwitch
} // namespace PokemonAutomation
Loading
Loading