Skip to content

Commit d926747

Browse files
committed
Migrate remaining uses of TimeExpressionOption to TimeDurationOption.
1 parent 18c1608 commit d926747

17 files changed

+124
-147
lines changed

Common/PokemonSwSh/PokemonSwSh_MultiHostTable.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*
55
*/
66

7+
#include "Common/NintendoSwitch/NintendoSwitch_SlotDatabase.h"
78
#include "PokemonSwSh_MultiHostTable.h"
89

910
namespace PokemonAutomation{
@@ -22,7 +23,7 @@ MultiHostSlot::MultiHostSlot(EditableTableOption& parent_table)
2223
, accept_FRs(LockMode::LOCK_WHILE_RUNNING, true)
2324
, move_slot(LockMode::LOCK_WHILE_RUNNING, 0, 0, 4)
2425
, dynamax(LockMode::LOCK_WHILE_RUNNING, true)
25-
, post_raid_delay(LockMode::LOCK_WHILE_RUNNING, TICKS_PER_SECOND, "0 * TICKS_PER_SECOND")
26+
, post_raid_delay(LockMode::LOCK_WHILE_RUNNING, "0 s")
2627
{
2728
PA_ADD_OPTION(game_slot);
2829
PA_ADD_OPTION(user_slot);

Common/PokemonSwSh/PokemonSwSh_MultiHostTable.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99

1010
#include "Common/Cpp/Options/BooleanCheckBoxOption.h"
1111
#include "Common/Cpp/Options/SimpleIntegerOption.h"
12-
#include "Common/Cpp/Options/TimeExpressionOption.h"
12+
#include "Common/Cpp/Options/TimeDurationOption.h"
1313
#include "Common/Cpp/Options/EnumDropdownOption.h"
1414
#include "Common/Cpp/Options/EditableTableOption.h"
15-
#include "Common/NintendoSwitch/NintendoSwitch_ControllerDefs.h"
16-
#include "Common/NintendoSwitch/NintendoSwitch_SlotDatabase.h"
1715

1816
namespace PokemonAutomation{
1917
namespace NintendoSwitch{
@@ -38,7 +36,7 @@ class MultiHostSlot : public EditableTableRow{
3836
BooleanCheckBoxCell accept_FRs;
3937
SimpleIntegerCell<uint8_t> move_slot;
4038
BooleanCheckBoxCell dynamax;
41-
TimeExpressionCell<uint16_t> post_raid_delay;
39+
MillisecondsCell post_raid_delay;
4240
};
4341

4442

SerialPrograms/Source/PokemonSwSh/Programs/PokemonSwSh_RaidItemFarmerOKHO.cpp

Lines changed: 35 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -47,67 +47,60 @@ RaidItemFarmerOHKO::RaidItemFarmerOHKO()
4747
// , m_advanced_options(
4848
// "<font size=4><b>Advanced Options:</b> You should not need to touch anything below here.</font>"
4949
// )
50-
, WAIT_FOR_STAMP_DELAY(
50+
, WAIT_FOR_STAMP_DELAY0(
5151
"<b>Wait for Stamp Delay:</b><br>Wait this long for the stamp to show up.",
5252
LockMode::LOCK_WHILE_RUNNING,
53-
TICKS_PER_SECOND,
54-
"3 * TICKS_PER_SECOND"
53+
"3000 ms"
5554
)
56-
, ENTER_STAMP_MASH_DURATION(
55+
, ENTER_STAMP_MASH_DURATION0(
5756
"<b>Enter Stamp Mash Duration:</b><br>Mash A this long to enter a raid from its stamp.",
5857
LockMode::LOCK_WHILE_RUNNING,
59-
TICKS_PER_SECOND,
60-
"5 * TICKS_PER_SECOND"
58+
"5000 ms"
6159
)
62-
, RAID_START_MASH_DURATION(
60+
, RAID_START_MASH_DURATION0(
6361
"<b>Raid Start Mash Duration:</b><br>Mash A this long to start raid.",
6462
LockMode::LOCK_WHILE_RUNNING,
65-
TICKS_PER_SECOND,
66-
"10 * TICKS_PER_SECOND"
63+
"10 s"
6764
)
68-
, RAID_START_TO_ATTACK_DELAY(
65+
, RAID_START_TO_ATTACK_DELAY0(
6966
"<b>Raid Start to Attack Delay:</b><br>Time from start raid to when the raiders attack.<br>"
7067
"Do not over-optimize this timing unless you are running with 4 Switches. The Wishiwashi NPC will break the program.",
7168
LockMode::LOCK_WHILE_RUNNING,
72-
TICKS_PER_SECOND,
73-
"30 * TICKS_PER_SECOND"
69+
"30 s"
7470
)
75-
, ATTACK_TO_CATCH_DELAY(
71+
, ATTACK_TO_CATCH_DELAY0(
7672
"<b>Attack to Catch Delay:</b><br>Time from when you attack to when the catch selection appears.<br>"
7773
"Do not over-optimize this timing unless you are running with 4 Switches. The Clefairy NPC's Follow Me will break the program.",
7874
LockMode::LOCK_WHILE_RUNNING,
79-
TICKS_PER_SECOND,
80-
"18 * TICKS_PER_SECOND"
75+
"18 s"
8176
)
82-
, RETURN_TO_OVERWORLD_DELAY(
77+
, RETURN_TO_OVERWORLD_DELAY0(
8378
"<b>Return to Overworld Delay:</b><br>Time from when you don't catch to when you return to the overworld.",
8479
LockMode::LOCK_WHILE_RUNNING,
85-
TICKS_PER_SECOND,
86-
"18 * TICKS_PER_SECOND"
80+
"18 s"
8781
)
88-
, TOUCH_DATE_INTERVAL(
82+
, TOUCH_DATE_INTERVAL0(
8983
"<b>Rollover Prevention:</b><br>Prevent the den from rolling over by periodically touching the date. If set to zero, this feature is disabled.",
9084
LockMode::LOCK_WHILE_RUNNING,
91-
TICKS_PER_SECOND,
92-
"4 * 3600 * TICKS_PER_SECOND"
85+
"4 hours"
9386
)
9487
{
9588
PA_ADD_OPTION(BACKUP_SAVE);
9689
// PA_ADD_STATIC(m_advanced_options);
97-
PA_ADD_OPTION(WAIT_FOR_STAMP_DELAY);
98-
PA_ADD_OPTION(ENTER_STAMP_MASH_DURATION);
99-
PA_ADD_OPTION(RAID_START_MASH_DURATION);
100-
PA_ADD_OPTION(RAID_START_TO_ATTACK_DELAY);
101-
PA_ADD_OPTION(ATTACK_TO_CATCH_DELAY);
102-
PA_ADD_OPTION(RETURN_TO_OVERWORLD_DELAY);
103-
PA_ADD_OPTION(TOUCH_DATE_INTERVAL);
90+
PA_ADD_OPTION(WAIT_FOR_STAMP_DELAY0);
91+
PA_ADD_OPTION(ENTER_STAMP_MASH_DURATION0);
92+
PA_ADD_OPTION(RAID_START_MASH_DURATION0);
93+
PA_ADD_OPTION(RAID_START_TO_ATTACK_DELAY0);
94+
PA_ADD_OPTION(ATTACK_TO_CATCH_DELAY0);
95+
PA_ADD_OPTION(RETURN_TO_OVERWORLD_DELAY0);
96+
PA_ADD_OPTION(TOUCH_DATE_INTERVAL0);
10497
}
10598

10699
void RaidItemFarmerOHKO::program(MultiSwitchProgramEnvironment& env, CancellableScope& scope){
107100
SwitchControllerContext host(scope, env.consoles[0].controller());
108101
size_t switches = env.consoles.size();
109102

110-
WallDuration TOUCH_DATE_INTERVAL0 = std::chrono::milliseconds(TOUCH_DATE_INTERVAL * 1000 / TICKS_PER_SECOND);
103+
WallDuration TOUCH_DATE_INTERVAL = TOUCH_DATE_INTERVAL0;
111104

112105
env.run_in_parallel(
113106
scope,
@@ -118,7 +111,7 @@ void RaidItemFarmerOHKO::program(MultiSwitchProgramEnvironment& env, Cancellable
118111

119112
WallClock last_touch = current_time();
120113
// uint32_t last_touch = 0;
121-
if (TOUCH_DATE_INTERVAL > 0){
114+
if (TOUCH_DATE_INTERVAL > 0ms){
122115
touch_date_from_home(host, ConsoleSettings::instance().SETTINGS_TO_HOME_DELAY0);
123116
last_touch = current_time();
124117
// last_touch = system_clock(host);
@@ -159,10 +152,10 @@ void RaidItemFarmerOHKO::program(MultiSwitchProgramEnvironment& env, Cancellable
159152
env.run_in_parallel(
160153
scope, 1, switches,
161154
[&](ConsoleHandle& console, SwitchControllerContext& context){
162-
pbf_wait(context, WAIT_FOR_STAMP_DELAY);
155+
pbf_wait(context, WAIT_FOR_STAMP_DELAY0);
163156
pbf_press_button(context, BUTTON_X, 10, 10);
164157
pbf_press_dpad(context, DPAD_RIGHT, 10, 10);
165-
pbf_mash_button(context, BUTTON_A, ENTER_STAMP_MASH_DURATION);
158+
pbf_mash_button(context, BUTTON_A, ENTER_STAMP_MASH_DURATION0);
166159
}
167160
);
168161

@@ -173,10 +166,10 @@ void RaidItemFarmerOHKO::program(MultiSwitchProgramEnvironment& env, Cancellable
173166
env.run_in_parallel(
174167
scope,
175168
[&](ConsoleHandle& console, SwitchControllerContext& context){
176-
pbf_mash_button(context, BUTTON_A, RAID_START_MASH_DURATION);
177-
pbf_wait(context, RAID_START_TO_ATTACK_DELAY);
169+
pbf_mash_button(context, BUTTON_A, RAID_START_MASH_DURATION0);
170+
pbf_wait(context, RAID_START_TO_ATTACK_DELAY0);
178171
pbf_mash_button(context, BUTTON_A, 5 * TICKS_PER_SECOND);
179-
pbf_wait(context, ATTACK_TO_CATCH_DELAY);
172+
pbf_wait(context, ATTACK_TO_CATCH_DELAY0);
180173

181174
if (console.index() == 0){
182175
// Add a little extra wait time since correctness matters here.
@@ -185,11 +178,9 @@ void RaidItemFarmerOHKO::program(MultiSwitchProgramEnvironment& env, Cancellable
185178
close_game(console, context);
186179

187180
// Touch the date.
188-
if (TOUCH_DATE_INTERVAL > 0 && current_time() - last_touch >= TOUCH_DATE_INTERVAL0){
189-
// if (TOUCH_DATE_INTERVAL > 0 && system_clock(context) - last_touch >= TOUCH_DATE_INTERVAL){
181+
if (TOUCH_DATE_INTERVAL > 0ms && current_time() - last_touch >= TOUCH_DATE_INTERVAL){
190182
touch_date_from_home(context, ConsoleSettings::instance().SETTINGS_TO_HOME_DELAY0);
191-
last_touch += TOUCH_DATE_INTERVAL0;
192-
// last_touch += TOUCH_DATE_INTERVAL;
183+
last_touch += TOUCH_DATE_INTERVAL;
193184
}
194185
start_game_from_home_with_inference(
195186
console, context,
@@ -199,11 +190,12 @@ void RaidItemFarmerOHKO::program(MultiSwitchProgramEnvironment& env, Cancellable
199190
);
200191
}else{
201192
pbf_press_dpad(context, DPAD_DOWN, 10, 10);
202-
if (RETURN_TO_OVERWORLD_DELAY > 5 * TICKS_PER_SECOND){
203-
pbf_mash_button(context, BUTTON_A, RETURN_TO_OVERWORLD_DELAY - 5 * TICKS_PER_SECOND);
204-
pbf_mash_button(context, BUTTON_B, 5 * TICKS_PER_SECOND);
193+
Milliseconds delay = RETURN_TO_OVERWORLD_DELAY0;
194+
if (delay > 5000ms){
195+
pbf_mash_button(context, BUTTON_A, delay - 5000ms);
196+
pbf_mash_button(context, BUTTON_B, 5000ms);
205197
}else{
206-
pbf_mash_button(context, BUTTON_A, RETURN_TO_OVERWORLD_DELAY);
198+
pbf_mash_button(context, BUTTON_A, delay);
207199
}
208200
}
209201
}

SerialPrograms/Source/PokemonSwSh/Programs/PokemonSwSh_RaidItemFarmerOKHO.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#define PokemonAutomation_PokemonSwSh_RaidItemFarmerOHKO_H
99

1010
#include "Common/Cpp/Options/BooleanCheckBoxOption.h"
11-
#include "Common/Cpp/Options/TimeExpressionOption.h"
11+
#include "Common/Cpp/Options/TimeDurationOption.h"
1212
#include "NintendoSwitch/NintendoSwitch_MultiSwitchProgram.h"
1313

1414
namespace PokemonAutomation{
@@ -32,13 +32,13 @@ class RaidItemFarmerOHKO : public MultiSwitchProgramInstance{
3232
private:
3333
BooleanCheckBoxOption BACKUP_SAVE;
3434
// SectionDivider m_advanced_options;
35-
TimeExpressionOption<uint16_t> WAIT_FOR_STAMP_DELAY;
36-
TimeExpressionOption<uint16_t> ENTER_STAMP_MASH_DURATION;
37-
TimeExpressionOption<uint16_t> RAID_START_MASH_DURATION;
38-
TimeExpressionOption<uint16_t> RAID_START_TO_ATTACK_DELAY;
39-
TimeExpressionOption<uint16_t> ATTACK_TO_CATCH_DELAY;
40-
TimeExpressionOption<uint16_t> RETURN_TO_OVERWORLD_DELAY;
41-
TimeExpressionOption<uint32_t> TOUCH_DATE_INTERVAL;
35+
MillisecondsOption WAIT_FOR_STAMP_DELAY0;
36+
MillisecondsOption ENTER_STAMP_MASH_DURATION0;
37+
MillisecondsOption RAID_START_MASH_DURATION0;
38+
MillisecondsOption RAID_START_TO_ATTACK_DELAY0;
39+
MillisecondsOption ATTACK_TO_CATCH_DELAY0;
40+
MillisecondsOption RETURN_TO_OVERWORLD_DELAY0;
41+
MillisecondsOption TOUCH_DATE_INTERVAL0;
4242
};
4343

4444

SerialPrograms/Source/PokemonSwSh/Programs/ShinyHuntAutonomous/PokemonSwSh_ShinyHuntAutonomous-IoATrade.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "CommonFramework/VideoPipeline/VideoFeed.h"
1010
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
1111
#include "NintendoSwitch/NintendoSwitch_Settings.h"
12+
#include "Pokemon/Pokemon_Strings.h"
1213
#include "Pokemon/Pokemon_Notification.h"
1314
#include "PokemonSwSh/PokemonSwSh_Settings.h"
1415
#include "PokemonSwSh/ShinyHuntTracker.h"
@@ -20,6 +21,8 @@ namespace PokemonAutomation{
2021
namespace NintendoSwitch{
2122
namespace PokemonSwSh{
2223

24+
using namespace Pokemon;
25+
2326

2427
ShinyHuntAutonomousIoATrade_Descriptor::ShinyHuntAutonomousIoATrade_Descriptor()
2528
: SingleSwitchProgramDescriptor(
@@ -66,11 +69,10 @@ ShinyHuntAutonomousIoATrade::ShinyHuntAutonomousIoATrade()
6669
, m_advanced_options(
6770
"<font size=4><b>Advanced Options:</b> You should not need to touch anything below here.</font>"
6871
)
69-
, MASH_TO_TRADE_DELAY(
72+
, MASH_TO_TRADE_DELAY0(
7073
"<b>Mash to Trade Delay:</b><br>Time to perform the trade.",
7174
LockMode::LOCK_WHILE_RUNNING,
72-
TICKS_PER_SECOND,
73-
"30 * TICKS_PER_SECOND"
75+
"30 s"
7476
)
7577
, RUN_FROM_EVERYTHING(
7678
"<b>Run from Everything:</b><br>Run from everything - even if it is shiny. (For testing only.)",
@@ -86,7 +88,7 @@ ShinyHuntAutonomousIoATrade::ShinyHuntAutonomousIoATrade()
8688
PA_ADD_OPTION(NOTIFICATIONS);
8789

8890
PA_ADD_STATIC(m_advanced_options);
89-
PA_ADD_OPTION(MASH_TO_TRADE_DELAY);
91+
PA_ADD_OPTION(MASH_TO_TRADE_DELAY0);
9092
if (PreloadSettings::instance().DEVELOPER_MODE){
9193
PA_ADD_OPTION(RUN_FROM_EVERYTHING);
9294
}
@@ -112,7 +114,7 @@ void ShinyHuntAutonomousIoATrade::program(SingleSwitchProgramEnvironment& env, S
112114
pbf_press_button(context, BUTTON_A, 10, 50);
113115
pbf_press_button(context, BUTTON_A, 80ms, GameSettings::instance().POKEMON_TO_BOX_DELAY0);
114116
pbf_press_dpad(context, DPAD_LEFT, 10, 10);
115-
pbf_mash_button(context, BUTTON_A, MASH_TO_TRADE_DELAY);
117+
pbf_mash_button(context, BUTTON_A, MASH_TO_TRADE_DELAY0);
116118

117119
// Enter box system.
118120
pbf_press_button(context, BUTTON_X, 80ms, GameSettings::instance().OVERWORLD_TO_MENU_DELAY0);

SerialPrograms/Source/PokemonSwSh/Programs/ShinyHuntAutonomous/PokemonSwSh_ShinyHuntAutonomous-IoATrade.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@
99

1010
#include "Common/Cpp/Options/StaticTextOption.h"
1111
#include "Common/Cpp/Options/BooleanCheckBoxOption.h"
12-
#include "Common/Cpp/Options/TimeExpressionOption.h"
12+
#include "Common/Cpp/Options/TimeDurationOption.h"
1313
#include "CommonFramework/Notifications/EventNotificationsTable.h"
1414
#include "NintendoSwitch/Options/NintendoSwitch_StartInGripMenuOption.h"
1515
#include "NintendoSwitch/Options/NintendoSwitch_GoHomeWhenDoneOption.h"
1616
#include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h"
17-
#include "Pokemon/Options/Pokemon_EncounterBotOptions.h"
1817
#include "PokemonSwSh/Options/PokemonSwSh_DateToucher.h"
1918

2019
namespace PokemonAutomation{
@@ -47,7 +46,7 @@ class ShinyHuntAutonomousIoATrade : public SingleSwitchProgramInstance{
4746
EventNotificationsOption NOTIFICATIONS;
4847

4948
SectionDividerOption m_advanced_options;
50-
TimeExpressionOption<uint16_t> MASH_TO_TRADE_DELAY;
49+
MillisecondsOption MASH_TO_TRADE_DELAY0;
5150
BooleanCheckBoxOption RUN_FROM_EVERYTHING;
5251
};
5352

SerialPrograms/Source/PokemonSwSh/Programs/ShinyHuntAutonomous/PokemonSwSh_ShinyHuntAutonomous-Regigigas2.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,10 @@ ShinyHuntAutonomousRegigigas2::ShinyHuntAutonomousRegigigas2()
6262
, m_advanced_options(
6363
"<font size=4><b>Advanced Options:</b> You should not need to touch anything below here.</font>"
6464
)
65-
, CATCH_TO_OVERWORLD_DELAY(
65+
, CATCH_TO_OVERWORLD_DELAY0(
6666
"<b>Catch to Overworld Delay:</b>",
6767
LockMode::LOCK_WHILE_RUNNING,
68-
TICKS_PER_SECOND,
69-
"8 * TICKS_PER_SECOND"
68+
"8000 ms"
7069
)
7170
{
7271
PA_ADD_OPTION(START_LOCATION);
@@ -78,7 +77,7 @@ ShinyHuntAutonomousRegigigas2::ShinyHuntAutonomousRegigigas2()
7877
PA_ADD_OPTION(NOTIFICATIONS);
7978

8079
PA_ADD_STATIC(m_advanced_options);
81-
PA_ADD_OPTION(CATCH_TO_OVERWORLD_DELAY);
80+
PA_ADD_OPTION(CATCH_TO_OVERWORLD_DELAY0);
8281
}
8382

8483

@@ -95,7 +94,7 @@ bool ShinyHuntAutonomousRegigigas2::kill_and_return(VideoStream& stream, SwitchC
9594
switch (result){
9695
case 0:
9796
pbf_press_dpad(context, DPAD_DOWN, 10, 0);
98-
pbf_press_button(context, BUTTON_A, 10, CATCH_TO_OVERWORLD_DELAY);
97+
pbf_press_button(context, BUTTON_A, 80ms, CATCH_TO_OVERWORLD_DELAY0);
9998
return true;
10099
default:
101100
stream.log("Raid Catch Menu not found.", COLOR_RED);

SerialPrograms/Source/PokemonSwSh/Programs/ShinyHuntAutonomous/PokemonSwSh_ShinyHuntAutonomous-Regigigas2.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include "Common/Cpp/Options/StaticTextOption.h"
1111
#include "Common/Cpp/Options/SimpleIntegerOption.h"
12-
#include "Common/Cpp/Options/TimeExpressionOption.h"
12+
#include "Common/Cpp/Options/TimeDurationOption.h"
1313
#include "CommonFramework/Notifications/EventNotificationsTable.h"
1414
#include "NintendoSwitch/Options/NintendoSwitch_StartInGripMenuOption.h"
1515
#include "NintendoSwitch/Options/NintendoSwitch_GoHomeWhenDoneOption.h"
@@ -51,7 +51,7 @@ class ShinyHuntAutonomousRegigigas2 : public SingleSwitchProgramInstance{
5151
EventNotificationsOption NOTIFICATIONS;
5252

5353
SectionDividerOption m_advanced_options;
54-
TimeExpressionOption<uint16_t> CATCH_TO_OVERWORLD_DELAY;
54+
MillisecondsOption CATCH_TO_OVERWORLD_DELAY0;
5555
};
5656

5757
}

SerialPrograms/Source/PokemonSwSh/Programs/ShinyHuntAutonomous/PokemonSwSh_ShinyHuntAutonomous-StrongSpawn.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
#ifndef PokemonAutomation_PokemonSwSh_ShinyHuntAutonomousStrongSpawn_H
88
#define PokemonAutomation_PokemonSwSh_ShinyHuntAutonomousStrongSpawn_H
99

10-
#include "Common/Cpp/Options/StaticTextOption.h"
11-
#include "Common/Cpp/Options/SimpleIntegerOption.h"
12-
#include "Common/Cpp/Options/TimeExpressionOption.h"
1310
#include "CommonFramework/Notifications/EventNotificationsTable.h"
1411
#include "NintendoSwitch/Options/NintendoSwitch_StartInGripMenuOption.h"
1512
#include "NintendoSwitch/Options/NintendoSwitch_GoHomeWhenDoneOption.h"
@@ -22,6 +19,9 @@ namespace PokemonAutomation{
2219
namespace NintendoSwitch{
2320
namespace PokemonSwSh{
2421

22+
using namespace Pokemon;
23+
24+
2525

2626
class ShinyHuntAutonomousStrongSpawn_Descriptor : public SingleSwitchProgramDescriptor{
2727
public:

0 commit comments

Comments
 (0)