-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathPokemonFRLG_ReadEncounter.cpp
More file actions
107 lines (93 loc) · 3.46 KB
/
PokemonFRLG_ReadEncounter.cpp
File metadata and controls
107 lines (93 loc) · 3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/* Read Encounter
*
* From: https://github.com/PokemonAutomation/
*
*/
#include <chrono>
#include <string>
#include <optional>
#include "Common/Cpp/Color.h"
#include "CommonFramework/VideoPipeline/VideoFeed.h"
#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h"
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
#include "Pokemon/Pokemon_Strings.h"
#include "Pokemon/Inference/Pokemon_NameReader.h"
#include "PokemonFRLG/Inference/PokemonFRLG_WildEncounterReader.h"
#include "PokemonFRLG_ReadEncounter.h"
namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonFRLG{
using namespace std::chrono_literals;
ReadEncounter_Descriptor::ReadEncounter_Descriptor()
: SingleSwitchProgramDescriptor(
"PokemonFRLG:ReadEncounter",
Pokemon::STRING_POKEMON + " FRLG",
"Read Wild Encounter", "",
"Read name and level of a wild encounter.",
ProgramControllerClass::StandardController_NoRestrictions,
FeedbackType::REQUIRED,
AllowCommandsWhenRunning::DISABLE_COMMANDS
){}
ReadEncounter::ReadEncounter()
: LANGUAGE(
"<b>Game Language:</b>",
Pokemon::PokemonNameReader::instance().languages(),
LockMode::LOCK_WHILE_RUNNING, true
)
, SUBSET(
"<b>Possible Encounters:</b>",
{
{Subset::route1, "route1", "Route 1 (Pidgey / Rattata)"},
{Subset::route22, "route22", "Route 22 (Rattata / Spearow / Mankey"},
{Subset::viridianforest, "viridianforest", "Viridian Forest (Caterpie / Metapod / Weedle / Kakuna / Pikachu)"},
{Subset::rocktunnel, "rocktunnel", "Rock Tunnel (Geodude / Machop / Mankey / Onix / Zubat)"},
{Subset::pokemontower, "pokemontower", "Pokemon Tower (Gastly, Haunter, Cubone)"},
},
LockMode::LOCK_WHILE_RUNNING,
Subset::route1
)
{
PA_ADD_OPTION(LANGUAGE);
PA_ADD_OPTION(SUBSET);
}
void ReadEncounter::program(
SingleSwitchProgramEnvironment& env,
ProControllerContext& context
){
env.log(
"Starting Read Encounter program..."
);
std::set<std::string> subset;
switch (SUBSET){
case Subset::route1:
subset = std::set<std::string>{"pidgey","rattata"};
break;
case Subset::route22:
subset = std::set<std::string>{"rattata", "spearow", "mankey"};
break;
case Subset::viridianforest:
subset = std::set<std::string>{"caterpie", "metapod", "weedle", "kakuna", "pikachu"};
break;
case Subset::rocktunnel:
subset = std::set<std::string>{"geodude", "zubat", "mankey", "machop", "onix"};
break;
case Subset::pokemontower:
subset = std::set<std::string>{"gastly", "haunter", "cubone"};
break;
default:
subset = std::set<std::string>{};
}
WildEncounterReader reader(COLOR_RED);
VideoOverlaySet overlays(env.console.overlay());
reader.make_overlays(overlays);
env.log("Reading name and level...");
VideoSnapshot screen = env.console.video().snapshot();
PokemonFRLG_WildEncounter encounter = reader.read_encounter(env.logger(), LANGUAGE, screen, subset);
env.log("Name: " + encounter.name);
env.log("Finished reading encounter.", COLOR_BLUE);
pbf_wait(context, 10s);
context.wait_for_all_requests();
}
} // namespace PokemonFRLG
} // namespace NintendoSwitch
} // namespace PokemonAutomation