Skip to content

Commit 65f2518

Browse files
committed
exclusion action column, handle new logic
1 parent 8935547 commit 65f2518

File tree

3 files changed

+113
-14
lines changed

3 files changed

+113
-14
lines changed

SerialPrograms/Source/PokemonSV/Options/PokemonSV_BBQOption.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const EnumDropdownDatabase<BBQuests>& BBQuests_database(){
1717
static EnumDropdownDatabase<BBQuests> database{
1818
{BBQuests::auto_10, "auto-10", "Defeat 10 wild Pokemon using Auto Battle!"},
1919
{BBQuests::make_tm, "make-tm", "Make yourself a TM!"},
20-
{BBQuests::pickup_10, "pickup-10", "Pick up items on the ground 10 times!"},
20+
//{BBQuests::pickup_10, "pickup-10", "Pick up items on the ground 10 times!"},
2121
{BBQuests::sneak_up, "sneak-up", "Successfully sneak up on 1 Pokemon and surprise them with a battle!"},
2222
{BBQuests::photo_fly, "photo-fly", "Take a photo of a wild Pokemon in flight!"},
2323
{BBQuests::photo_swim, "photo-swim", "Take a photo of a wild Pokemon that is swimming!"},
@@ -79,24 +79,38 @@ const EnumDropdownDatabase<BBQuests>& BBQuests_database(){
7979
return database;
8080
}
8181

82+
const EnumDropdownDatabase<BBQAction>& BBQAction_database(){
83+
static EnumDropdownDatabase<BBQAction> database{
84+
{BBQAction::run, "run", "Run Quest"},
85+
{BBQAction::skip, "skip", "Skip"},
86+
{BBQAction::reroll, "reroll", "Reroll"},
87+
};
88+
return database;
89+
}
90+
8291
BBQuestTableRow::BBQuestTableRow(EditableTableOption& parent_table)
8392
: EditableTableRow(parent_table)
8493
, quest(BBQuests_database(), LockMode::UNLOCK_WHILE_RUNNING, BBQuests::auto_10)
94+
, action(BBQAction_database(), LockMode::UNLOCK_WHILE_RUNNING, BBQAction::skip)
8595
{
8696
PA_ADD_OPTION(quest);
97+
PA_ADD_OPTION(action);
8798
}
8899
std::unique_ptr<EditableTableRow> BBQuestTableRow::clone() const{
89100
std::unique_ptr<BBQuestTableRow> ret(new BBQuestTableRow(parent()));
90101
ret->quest.set(quest);
102+
ret->action.set(action);
91103
return ret;
92104
}
93105

94106
BBQuestTable::BBQuestTable()
95107
: EditableTableOption_t<BBQuestTableRow>(
96108
"<b>Quest Exclusions:</b><br>"
97-
"Exclude the quests in the table. "
98-
"If you are experiencing an issue or want to skip a quest, select it below. "
99-
"Does not include egg hatching quest, as that is handled in another option. ",
109+
"Exclude the quests in the table. If you are experiencing an issue or want to skip a quest, select it below. "
110+
"Do not exclude too many quests, as rerolling will cost BP. "
111+
"The program will automatically reroll all quests if none are possible, but will not handle being out of BP. "
112+
"Does not include egg hatching quest, as that is handled in the other options. "
113+
"<b>Warning: Skipping Bonus quests will block the bonus slot.</b>",
100114
LockMode::LOCK_WHILE_RUNNING,
101115
make_defaults()
102116
)
@@ -105,6 +119,7 @@ BBQuestTable::BBQuestTable()
105119
std::vector<std::string> BBQuestTable::make_header() const{
106120
return {
107121
"Quest",
122+
"Action",
108123
};
109124
}
110125
std::vector<std::unique_ptr<EditableTableRow>> BBQuestTable::make_defaults(){

SerialPrograms/Source/PokemonSV/Options/PokemonSV_BBQOption.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ enum class BBQuests{
3333
UnableToDetect
3434
};
3535

36+
enum class BBQAction{
37+
run,
38+
skip,
39+
reroll
40+
};
41+
3642
//Quest exclusion table
3743
const EnumDropdownDatabase<BBQuests>& BBQuests_database();
3844

@@ -43,6 +49,7 @@ class BBQuestTableRow : public EditableTableRow{
4349

4450
public:
4551
EnumDropdownCell<BBQuests> quest;
52+
EnumDropdownCell<BBQAction> action;
4653
};
4754

4855
class BBQuestTable : public EditableTableOption_t<BBQuestTableRow>{

SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp

Lines changed: 87 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,9 @@ std::vector<BBQuests> process_quest_list(
228228
uint8_t& eggs_hatched
229229
){
230230
std::vector<BBQuests> quests_to_do;
231+
bool rerolled = false;
232+
std::vector<std::unique_ptr<BBQuestTableRow>> exclusions_table = BBQ_OPTIONS.QUEST_EXCLUSIONS.copy_snapshot();
233+
int questpos = 0;
231234

232235
stream.log("Processing quests.");
233236
//Put all do-able quests into a different list
@@ -267,6 +270,7 @@ std::vector<BBQuests> process_quest_list(
267270
pbf_wait(context, 100);
268271
context.wait_for_all_requests();
269272

273+
rerolled = true;
270274
press_Bs_to_back_to_overworld(info, stream, context);
271275

272276
break;
@@ -284,24 +288,96 @@ std::vector<BBQuests> process_quest_list(
284288
);
285289
break;
286290
}
287-
}else{
288-
//TODO
291+
}
292+
else{
293+
bool quest_in_table = false;
294+
for(const std::unique_ptr<BBQuestTableRow>& row : exclusions_table){
295+
if(n == row->quest) {
296+
stream.log("Quest found in exclusions table.");
297+
quest_in_table = true;
298+
299+
WhiteButtonWatcher rp2(COLOR_BLUE, WhiteButton::ButtonB, {0.484, 0.117, 0.022, 0.037});
300+
int result2;
301+
switch (row->action) {
302+
case BBQAction::run:
303+
stream.log("Run selected. Adding quest to list.");
304+
quests_to_do.push_back(n);
305+
break;
306+
case BBQAction::reroll:
307+
stream.log("Reroll selected. Rerolling quest. New quest will be run in the next batch of quests.");
308+
result2 = run_until<ProControllerContext>(
309+
stream, context,
310+
[&](ProControllerContext& context){
311+
for (int i = 0; i < 6; i++){
312+
pbf_press_dpad(context, DPAD_RIGHT, 50, 20);
313+
pbf_wait(context, 200);
314+
context.wait_for_all_requests();
315+
}
316+
},
317+
{{ rp2 }}
318+
);
319+
if (result2 == 0){
320+
stream.log("Found quest panel.");
321+
}
322+
context.wait_for_all_requests();
323+
324+
//Move cursor down to quest
325+
for (int i = 0; i < questpos; i++) {
326+
pbf_press_dpad(context, DPAD_DOWN, 20, 20);
327+
pbf_wait(context, 100);
328+
context.wait_for_all_requests();
329+
}
330+
331+
//Reroll
332+
pbf_press_button(context, BUTTON_A, 20, 50);
333+
pbf_press_button(context, BUTTON_A, 20, 50);
334+
pbf_wait(context, 100);
335+
context.wait_for_all_requests();
289336

337+
//Prevent error and allows program to reread the rerolled quests
338+
rerolled = true;
290339

291-
stream.log("Quest possible");
292-
quests_to_do.push_back(n);
340+
press_Bs_to_back_to_overworld(info, stream, context);
341+
break;
342+
case BBQAction::skip:
343+
stream.log("Skip selected. Skipping quest.");
344+
break;
345+
}
346+
}
347+
}
348+
if(!quest_in_table){
349+
stream.log("Quest not in exclusions table. Adding to list.");
350+
quests_to_do.push_back(n);
351+
}
293352
}
294353
}
354+
questpos++;
295355
}
296356

297357
//Check that quests_to_do is not empty (after completing all quests on the list, be sure to erase it.
298358
//Lag might be a problem in multi - look into making slots like menu-left navigation
299-
if (quests_to_do.size() == 0){
359+
if (!rerolled && quests_to_do.size() == 0){
300360
stream.log("No possible quests! Rerolling all quests.");
301361

302-
//Open quest panel - see above
303-
//Reroll all.
362+
//Open quest panel and reroll all quests.
304363
//This does not handle out of BP.
364+
WhiteButtonWatcher panel(COLOR_BLUE, WhiteButton::ButtonB, {0.484, 0.117, 0.022, 0.037});
365+
int result = run_until<ProControllerContext>(
366+
stream, context,
367+
[&](ProControllerContext& context){
368+
for (int i = 0; i < 6; i++){
369+
pbf_press_dpad(context, DPAD_RIGHT, 50, 20);
370+
pbf_wait(context, 200);
371+
context.wait_for_all_requests();
372+
}
373+
},
374+
{{ panel }}
375+
);
376+
if (result == 0){
377+
stream.log("Found quest panel.");
378+
}
379+
context.wait_for_all_requests();
380+
305381
for (int i = 0; i < quest_list.size(); i++){
306382
pbf_press_button(context, BUTTON_A, 20, 50);
307383
pbf_press_button(context, BUTTON_A, 20, 50); //Yes.
@@ -312,16 +388,17 @@ std::vector<BBQuests> process_quest_list(
312388
context.wait_for_all_requests();
313389
}
314390
//Close quest panel - mash b
391+
press_Bs_to_back_to_overworld(info, stream, context);
315392
}
316-
317-
if (quests_to_do.size() == 0){
393+
/*
394+
if (!rerolled && quests_to_do.size() == 0){
318395
OperationFailedException::fire(
319396
ErrorReport::SEND_ERROR_REPORT,
320397
"No possible quests! Check language selection.",
321398
stream
322399
);
323400
}
324-
401+
*/
325402
return quests_to_do;
326403
}
327404

0 commit comments

Comments
 (0)