Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -99,6 +99,15 @@ const char* const MAP_NAMES[] = {
"RocketHideout_B2F",
"RocketHideout_B3F",
"RocketHideout_B4F",
// Back in Lavender: the Pokemon Tower and Mr. Fuji's house.
"LavenderTown_VolunteerPokemonHouse",
"PokemonTower_1F",
"PokemonTower_2F",
"PokemonTower_3F",
"PokemonTower_4F",
"PokemonTower_5F",
"PokemonTower_6F",
"PokemonTower_7F",
"CeruleanCave_1F",
"CeruleanCave_2F",
"CeruleanCave_B1F",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,17 @@ constexpr StoryTrainer STORY_TRAINERS[] = {
{.map = "RocketHideout_B4F", .battle = "left_guard", .trainer = "TRAINER_TEAM_ROCKET_GRUNT_16"},
{.map = "RocketHideout_B4F", .battle = "right_guard", .trainer = "TRAINER_TEAM_ROCKET_GRUNT_17"},
{.map = "RocketHideout_B4F", .battle = "giovanni", .trainer = "TRAINER_BOSS_GIOVANNI"},
// The Pokemon Tower (10.02, 10.03; pret PokemonTower_*F scripts.inc):
// the rival on 2F, the Channelers in the only ways up on 5F and 6F,
// and 7F's three Grunts.
{.map = "PokemonTower_2F", .battle = "rival_pokemon_tower", .trainer = "TRAINER_RIVAL_POKEMON_TOWER_BULBASAUR"},
{.map = "PokemonTower_5F", .battle = "channeler_ruth", .trainer = "TRAINER_CHANNELER_RUTH"},
{.map = "PokemonTower_5F", .battle = "channeler_tammy", .trainer = "TRAINER_CHANNELER_TAMMY"},
{.map = "PokemonTower_6F", .battle = "channeler_jennifer", .trainer = "TRAINER_CHANNELER_JENNIFER"},
{.map = "PokemonTower_6F", .battle = "channeler_emilia", .trainer = "TRAINER_CHANNELER_EMILIA"},
{.map = "PokemonTower_7F", .battle = "tower_grunt1", .trainer = "TRAINER_TEAM_ROCKET_GRUNT_19"},
{.map = "PokemonTower_7F", .battle = "tower_grunt2", .trainer = "TRAINER_TEAM_ROCKET_GRUNT_20"},
{.map = "PokemonTower_7F", .battle = "tower_grunt3", .trainer = "TRAINER_TEAM_ROCKET_GRUNT_21"},
};

using JsonTable = std::map<std::string, JsonValue, std::less<>>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <format>
#include <functional>
#include <optional>
#include <string_view>
#include <string>
#include <vector>
#include "Common/Cpp/Exceptions.h"
Expand Down Expand Up @@ -107,9 +108,31 @@
return true;
}

// The story's scripted wild battles, which no trainer fights: the battle
// step's map and name, and the species (pret setwildbattle). The battle
// step fights them as any battle with no trainer.
struct StoryWildBattle{
std::string_view map;
std::string_view battle;
std::string_view species;
};
constexpr StoryWildBattle STORY_WILD_BATTLES[] = {
// PokemonTower_6F_EventScript_MarowakGhost: the Silph Scope shows it.
{.map = "PokemonTower_6F", .battle = "marowak_ghost", .species = "marowak"},
};

std::optional<std::string_view> story_wild_battle(std::string_view map, std::string_view battle){
for (const StoryWildBattle& entry : STORY_WILD_BATTLES){
if (entry.map == map && entry.battle == battle){
return entry.species;
}
}
return std::nullopt;
}

// Every battle step in the table fights a trainer its map battles in
// pret's scripts, with a party.
UnitTestResult test_story_trainers(){

Check warning on line 135 in SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleData_Tests.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

PokemonAutomation::NintendoSwitch::PokemonFRLG::test_story_trainers(): function_lines=39 (advisory above 25, limit 50)
size_t battles = 0;
for (const StoryCheckpoint& checkpoint : story_checkpoints()){
for (const StoryStep& step : checkpoint.steps){
Expand All @@ -119,6 +142,12 @@
battles++;
const std::string map = step.pose_after ? step.pose_after->map : "";
const std::optional<std::string_view> trainer = story_trainer(map, step.name);
if (!trainer && story_wild_battle(map, step.name)){
if (!species_data(*story_wild_battle(map, step.name))){
return std::format("{}, {} on {}: no such species.", checkpoint.id, step.name, map);
}
continue;
}
if (!trainer){
return std::format("{}, {} on {}: no trainer.", checkpoint.id, step.name, map);
}
Expand All @@ -137,6 +166,9 @@
if (trainer_party(*story_trainer("CeruleanCity_Gym", "misty")) != std::vector<std::string>{"staryu", "starmie"}){
return "Expected Misty's Staryu and Starmie.";
}
if (story_wild_battle("PokemonTower_6F", "marowak_ghost") != "marowak" || story_trainer("PokemonTower_6F", "marowak_ghost")){
return "Expected the Tower's Marowak as a wild battle, no trainer's.";
}
return true;
}

Expand Down
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=612 (advisory above 500, limit 1000)
*
* From: https://github.com/PokemonAutomation/
*
Expand Down Expand Up @@ -138,7 +138,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";
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 10.01 10.02";

const RunPlanScenario RUN_PLAN_CASES[] = {
{
Expand Down Expand Up @@ -229,11 +229,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"},
.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 10.01 10.02"},
},
{
.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"},
.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 10.01 10.02"},
},
{
.input = { .name = "Gift RNG: started at 04.03, from the save beside the salesman",
Expand All @@ -258,7 +258,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"},
.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 10.01 10.02"},
},
{
.input = { .name = "Starter RNG first, with both on",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* AutoStory Tests

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

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

<file>: file_lines=1000 (advisory above 500, limit 1000)
*
* From: https://github.com/PokemonAutomation/
*
Expand Down Expand Up @@ -231,8 +231,8 @@

UnitTestResult test_routes_and_chain(){
const std::vector<StoryCheckpoint>& checkpoints = story_checkpoints();
if (checkpoints.size() != 39 || checkpoints[0].start){
return "Expected 39 checkpoints, the first from a new game.";
if (checkpoints.size() != 41 || checkpoints[0].start){
return "Expected 41 checkpoints, the first from a new game.";
}
StoryPose pose;
for (size_t c = 0; c < checkpoints.size(); c++){
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
{
"format": "pokesim-authored-checkpoint/1",
"game": "frlg",
"checkpoint": {
"id": "10.01",
"title": "Back east from Celadon: Route 7, the Underground Path and Route 8 to Lavender Town's Pokemon Center",
"notes": [
"Bulbapedia's FireRed/LeafGreen walkthrough part 10 (Pokemon Tower). PokeGuy flies to Lavender with HM02 (1:03:59); the story has no Fly yet, so it walks back the way 08.03 came. Route 8's tiles and trainers: pret data/maps/Route8/map.json."
],
"start": {
"certainty": "tile",
"map": "CeladonCity",
"where": {
"facing": "south",
"kind": "tiles",
"tiles": [
[
34,
22
]
]
}
},
"events": [
{
"id": "underground_route8_exit",
"kind": "route",
"variant": "run",
"target": {
"certainty": "tile",
"map": "Route8",
"where": {
"facing": "south",
"kind": "tiles",
"tiles": [
[
13,
5
]
]
}
},
"why": "east over Celadon onto Route 7, in at the Underground Path's west door, through the east-west tunnel and out of the east entrance onto Route 8, a step below its door (13, 4)"
},
{
"id": "route8_row14",
"kind": "legs",
"variant": "run",
"legs": [
{
"direction": "east",
"tiles": 1
},
{
"direction": "south",
"tiles": 9
},
{
"direction": "east",
"tiles": 12
}
],
"why": "east to (14, 5), down column 14 east of Aidan's line (10..13, 6) to (14, 14), a tile above Ricardo's sight (14, 15), and east along row 14 above Jaren (24, 17) to (26, 14)"
},
{
"id": "route8_row7",
"kind": "legs",
"variant": "run",
"legs": [
{
"direction": "north",
"tiles": 7
},
{
"direction": "east",
"tiles": 22
}
],
"why": "up column 26 to (26, 7), a row below Andrea's line (26..28, 5), and east along row 7 below Megan's (30..35, 6) to (48, 7), west of Glenn's south line (51, 7..10)"
},
{
"id": "route8_row18",
"kind": "legs",
"variant": "run",
"legs": [
{
"direction": "south",
"tiles": 11
},
{
"direction": "east",
"tiles": 19
},
{
"direction": "north",
"tiles": 8
}
],
"why": "down column 48 to the wall (48, 19), east along row 18 past Rich (beaten in 08.03) to the wall (68, 18), and up column 67 to row 10, the way onto Lavender Town (rows 9..11)"
},
{
"id": "lavender_nurse",
"kind": "route",
"variant": "run",
"target": {
"certainty": "tile",
"map": "LavenderTown_PokemonCenter_1F",
"where": {
"facing": "north",
"kind": "tiles",
"tiles": [
[
7,
4
]
]
}
},
"why": "east over the connection into Lavender Town and in at the Center's door (6, 5), to the nurse"
},
{
"id": "heal_lavender",
"kind": "heal",
"why": "full HP before the Pokemon Tower"
}
]
},
"execution": {
"menu": "full"
}
}
Loading
Loading