Skip to content

Commit

Permalink
Make StartGame more configurable for slow switches
Browse files Browse the repository at this point in the history
  • Loading branch information
LegoFigure11 committed Sep 21, 2023
1 parent 27c5ca3 commit 21fdb95
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 32 deletions.
8 changes: 7 additions & 1 deletion RaidCrawler.Core/Connection/ConnectionWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ public async Task CloseGame(CancellationToken token)
_statusUpdate("Closed out of the game!");
}

public async Task StartGame(CancellationToken token)
public async Task StartGame(IDateAdvanceConfig config, CancellationToken token)
{
// Open game.
_statusUpdate("Starting the game!");
Expand All @@ -414,6 +414,9 @@ public async Task StartGame(CancellationToken token)
await Click(DUP, 0_600, token).ConfigureAwait(false);
await Click(A, 1_000, token).ConfigureAwait(false);

// Allow time for profile check if required
await Task.Delay(config.RelaunchDelay, token).ConfigureAwait(false);

// If they have DLC on the system and can't use it, requires an UP + A to start the game.
// Should be harmless otherwise since they'll be in loading screen.
await Click(DUP, 0_600, token).ConfigureAwait(false);
Expand All @@ -425,6 +428,9 @@ public async Task StartGame(CancellationToken token)
for (int i = 0; i < 20; i++)
await Click(A, 1_000, token).ConfigureAwait(false);

// Particularly slow switches need more time to load the overworld
await Task.Delay(config.ExtraOverworldWait, token).ConfigureAwait(false);

_statusUpdate("Back in the overworld! Refreshing the base block key pointer...");
BaseBlockKeyPointer = await Connection
.PointerAll(BlockKeyPointer, token)
Expand Down
2 changes: 2 additions & 0 deletions RaidCrawler.Core/Interfaces/IDateAdvanceConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ public interface IDateAdvanceConfig
int ReturnGameDelay { get; set; }
int BaseDelay { get; set; }
int SaveGameDelay { get; set; }
int RelaunchDelay { get; set; }
int ExtraOverworldWait { get; set; }
}
}
2 changes: 2 additions & 0 deletions RaidCrawler.WinForms/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public class ClientConfig : IDateAdvanceConfig, IWebhookConfig
public int BaseDelay { get; set; } = 0;
public int SaveGameDelay { get; set; } = 0;
public int SystemReset { get; set; } = 30;
public int RelaunchDelay { get; set; } = 0;
public int ExtraOverworldWait { get; set; } = 0;

// Webhook
public bool EnableEmoji { get; set; } = true;
Expand Down
2 changes: 1 addition & 1 deletion RaidCrawler.WinForms/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ private async Task AdvanceDateClick(CancellationToken token)
if (skips >= Config.SystemReset)
{
await ConnectionWrapper.CloseGame(token).ConfigureAwait(false);
await ConnectionWrapper.StartGame(token).ConfigureAwait(false);
await ConnectionWrapper.StartGame(Config, token).ConfigureAwait(false);
RaidBlockOffsetBase = 0;
RaidBlockOffsetKitakami = 0;
skips = 0;
Expand Down
Loading

0 comments on commit 21fdb95

Please sign in to comment.