Skip to content

Commit d44bb6d

Browse files
author
Gin
committed
Update outbreak finder notification
1 parent 30143d4 commit d44bb6d

File tree

2 files changed

+35
-26
lines changed

2 files changed

+35
-26
lines changed

SerialPrograms/Source/PokemonLA/Programs/General/PokemonLA_OutbreakFinder.cpp

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -674,15 +674,7 @@ std::set<std::string> OutbreakFinder::enter_region_and_read_MMO(
674674
}
675675

676676

677-
// Run one iteration of the outbreak finder loop and return true when one desired outbreak is found.
678-
// The iteration includes:
679-
// 1. Starting at Jubilife Village gate, go to check the map for outbreaks.
680-
// 2. If found desired outbreaks, stop.
681-
// 3. If need to check MMOs, save in front of gate, then go to each region with MMO and talk to Mai to
682-
// reveal MMO pokemon. Reset if no desired MMO to conserve Aguav Berries.
683-
// 4. If found desired MMO pokemon, stop.
684-
// 5. No desired outbreak in this iteration, go to an arbitrary region and return to village to refresh outbreaks.
685-
bool OutbreakFinder::run_iteration(
677+
std::vector<std::string> OutbreakFinder::run_iteration(
686678
SingleSwitchProgramEnvironment& env, ProControllerContext& context,
687679
const std::set<std::string>& desired_hisui_map_events,
688680
const std::set<std::string>& desired_outbreaks,
@@ -720,14 +712,14 @@ bool OutbreakFinder::run_iteration(
720712
os << "Found following desired outbreak" << (desired_outbreaks_found.size() > 1 ? "s: " : ": ");
721713
for(const auto& outbreak: desired_outbreaks_found){
722714
os << outbreak << ", ";
723-
env.console.overlay().add_log("Found " + outbreak);
715+
env.console.overlay().add_log("Found " + outbreak, COLOR_GREEN);
724716
}
725-
env.log(os.str());
717+
env.log(os.str(), COLOR_GREEN);
726718

727-
return true;
728-
}else{
729-
env.log("No desired outbreak.");
719+
return desired_outbreaks_found;
730720
}
721+
722+
env.log("No desired outbreak.");
731723
}
732724

733725
// What we found is MMO symbols for MMO pokemon.
@@ -750,10 +742,10 @@ bool OutbreakFinder::run_iteration(
750742
os << "Found desired MMO pokemon (including desired MMO pokemon with star symbols): ";
751743
for (const auto& pokemon : found_pokemon){
752744
os << pokemon << ", ";
753-
env.console.overlay().add_log("Found " + pokemon);
745+
env.console.overlay().add_log("Found " + pokemon, COLOR_GREEN);
754746
}
755-
env.log(os.str());
756-
return true;
747+
env.log(os.str(), COLOR_GREEN);
748+
return std::vector<std::string>(found_pokemon.begin(), found_pokemon.end());
757749
}
758750

759751
env.log("No target MMO sprite found. Reset game...");
@@ -769,7 +761,7 @@ bool OutbreakFinder::run_iteration(
769761
// Go to an arbitrary region and return to refresh outbreaks.
770762
goto_region_and_return(env, context, inside_travel_map);
771763

772-
return false;
764+
return std::vector<std::string>();
773765
}
774766

775767

@@ -849,21 +841,30 @@ void OutbreakFinder::program(SingleSwitchProgramEnvironment& env, ProControllerC
849841
desired_hisui_map_events.insert(p.first);
850842
}
851843

844+
std::vector<std::string> found_outbreaks;
852845
while (true){
853-
if (run_iteration(env, context, desired_hisui_map_events, desired_outbreaks, desired_MMO_pokemon,
854-
desired_star_MMO_pokemon))
846+
found_outbreaks = run_iteration(
847+
env, context, desired_hisui_map_events, desired_outbreaks, desired_MMO_pokemon,
848+
desired_star_MMO_pokemon);
849+
if (found_outbreaks.size() > 0)
855850
{
856851
break;
857852
}
858853
}
859854

860855
env.update_stats();
861856

862-
send_program_notification(
857+
os.str(""); // clear ostringstream
858+
os << "Found ";
859+
for (size_t i = 0; i < found_outbreaks.size(); i++){
860+
os << found_outbreaks[i];
861+
if (i + 1 != found_outbreaks.size()){
862+
os << ", ";
863+
}
864+
}
865+
send_program_finished_notification(
863866
env, NOTIFICATION_MATCHED,
864-
COLOR_GREEN,
865-
"Found Outbreak",
866-
{}, "",
867+
os.str(),
867868
env.console.video().snapshot()
868869
);
869870

SerialPrograms/Source/PokemonLA/Programs/General/PokemonLA_OutbreakFinder.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,15 @@ class OutbreakFinder : public SingleSwitchProgramInstance{
3434

3535

3636
private:
37-
// One iteration in the main program loop
37+
// Run one iteration of the outbreak finder loop and return any found outbreaks.
38+
// The iteration includes:
39+
// 1. Starting at Jubilife Village gate, go to check the map for outbreaks.
40+
// 2. If found desired outbreaks, stop.
41+
// 3. If need to check MMOs, save in front of gate, then go to each region with MMO and talk to Mai to
42+
// reveal MMO pokemon. Reset if no desired MMO to conserve Aguav Berries.
43+
// 4. If found desired MMO pokemon, stop.
44+
// 5. No desired outbreak in this iteration, go to an arbitrary region and return to village to refresh outbreaks.
45+
//
3846
// - desired_hisui_map_events: desired events happening on the travel map of Hisui when leaving Jubilife Village.
3947
// It contains desired pokemon outbreak names and MMO outbreak names (e.g. "fieldlands-mmo"). If there are
4048
// desired MMO pokemon (including those with star symbols), the MMO outbreaks that may spawn them are also
@@ -46,7 +54,7 @@ class OutbreakFinder : public SingleSwitchProgramInstance{
4654
// - desired_MMO_pokemon: user desired MMO pokemon selected by `DESIRED_MMO_SLUGS`.
4755
// User selected MMO pokemon with star symbols, `DESIRED_STAR_MMO_SLUGS` do not affect `desired_MMO_pokemon`.
4856
// - desired_star_MMO_pokemon: user desired MMO pokemon with star symbols.
49-
bool run_iteration(SingleSwitchProgramEnvironment& env, ProControllerContext& context,
57+
std::vector<std::string> run_iteration(SingleSwitchProgramEnvironment& env, ProControllerContext& context,
5058
const std::set<std::string>& desired_hisui_map_events,
5159
const std::set<std::string>& desired_outbreaks,
5260
const std::set<std::string>& desired_MMO_pokemon,

0 commit comments

Comments
 (0)