Skip to content

Commit 641061d

Browse files
committed
some code cleaning
1 parent 27eee76 commit 641061d

File tree

3 files changed

+17
-29
lines changed

3 files changed

+17
-29
lines changed

SysBot.Pokemon/Actions/PokeRoutineExecutor.cs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -452,20 +452,11 @@ public static uint GetOverworldOffset(ConsoleLanguageParameter value)
452452
public async Task PokeCamp(PokeTradeHubConfig config, CancellationToken token)
453453
{
454454
// Open Poke Camp and return to the overworld
455-
try
456-
{
457-
Log("Opening Camp...");
458-
await Click(X, 2_500, token).ConfigureAwait(false);
459-
await Click(A, 9_000, token).ConfigureAwait(false);
460-
await Click(B, 2_000, token).ConfigureAwait(false);
461-
await Click(A, 2_000, token).ConfigureAwait(false);
462-
}
463-
catch (Exception e)
464-
{
465-
Log(e + "Exception Caught. Trying to restart.");
466-
await CloseGame(config, token).ConfigureAwait(false);
467-
await StartGame(config, token).ConfigureAwait(false);
468-
}
455+
Log("Opening Camp...");
456+
await Click(X, 2_500, token).ConfigureAwait(false);
457+
await Click(A, 9_000, token).ConfigureAwait(false);
458+
await Click(B, 2_000, token).ConfigureAwait(false);
459+
await Click(A, 2_000, token).ConfigureAwait(false);
469460
}
470461
}
471462
}

SysBot.Pokemon/BotEncounter/EncounterBot.cs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -183,18 +183,12 @@ private async Task DoDogEncounter(CancellationToken token)
183183
Log("Looking for a new dog...");
184184

185185
// At the start of each loop, an A press is needed to exit out of a prompt.
186-
await Click(A, 0_500, token).ConfigureAwait(false);
186+
await Click(A, 0_200, token).ConfigureAwait(false);
187187
await SetStick(LEFT, 0, 30000, 1_000, token).ConfigureAwait(false);
188188

189-
// Encounters Zacian/Zamazenta
190-
await Click(A, 0_600, token).ConfigureAwait(false);
191-
192-
// Cutscene loads
193-
await Click(A, 2_600, token).ConfigureAwait(false);
194-
195-
// Click through all the menus.
189+
// Encounters Zacian/Zamazenta and clicks through all the menus.
196190
while (!await IsInBattle(token).ConfigureAwait(false))
197-
await Click(A, 1_000, token).ConfigureAwait(false);
191+
await Click(A, 0_300, token).ConfigureAwait(false);
198192

199193
Log("Encounter started! Checking details...");
200194
var pk = await ReadUntilPresent(LegendaryPokemonOffset, 2_000, 0_200, token).ConfigureAwait(false);
@@ -307,7 +301,7 @@ private async Task DoGArticunoEncounter(CancellationToken token)
307301
}
308302

309303
//Read Pokémon Information
310-
Log("Encounter Articuno started! Checking details...");
304+
Log("Articuno Encounter started! Checking details...");
311305
var pk = await ReadUntilPresent(WildPokemonOffset, 2_000, 0_200, token).ConfigureAwait(false);
312306
if (pk == null)
313307
Log("Not right Offset.");
@@ -416,7 +410,7 @@ private async Task<bool> HandleEncounter(PK8 pk, bool legends, CancellationToken
416410
private string getRibbonsList(PK8 pk)
417411
{
418412
string ribbonsList = "Ribbons: ";
419-
for (var mark = RibbonIndex.MarkLunchtime; mark <= RibbonIndex.MarkSlump; mark++)
413+
for (var mark = MarkIndex.MarkLunchtime; mark <= MarkIndex.MarkSlump; mark++)
420414
if (pk.GetRibbon((int)mark))
421415
ribbonsList += mark;
422416

SysBot.Pokemon/Settings/StopConditionSettings.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,14 @@ public static int[] InitializeTargetIVs(PokeTradeHub<PK8> hub)
102102

103103
private static bool HasMark(IRibbonIndex pk, MarkIndex target, bool specific)
104104
{
105-
for (var mark = RibbonIndex.MarkLunchtime; mark <= RibbonIndex.MarkSlump; mark++)
106-
{
107-
if ((!specific && pk.GetRibbon((int)mark)) || (specific && pk.GetRibbon((int)mark) && mark.Equals(target)))
108-
return true;
105+
if (!specific) {
106+
for (var mark = RibbonIndex.MarkLunchtime; mark <= RibbonIndex.MarkSlump; mark++)
107+
if ((!specific && pk.GetRibbon((int)mark)) || (specific && pk.GetRibbon((int)mark) && mark.Equals(target)))
108+
return true;
109109
}
110+
else if (specific && pk.GetRibbon((int)target))
111+
return true;
112+
110113
return false;
111114
}
112115
}

0 commit comments

Comments
 (0)