Skip to content

Commit

Permalink
Implement retry logic for monster retrieval in ArchMageMatsArmy with …
Browse files Browse the repository at this point in the history
…logging for attempts
  • Loading branch information
PUNK3DAF committed Nov 4, 2024
1 parent 74a5277 commit 9323ff9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Army/Various/ArmyArchMageBossItems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,19 @@ public void ArmyKillMonster(string map, string cell, int MonID, string item, int
Core.Join(map);
Army.waitForPartyCell(cell, playerCount: Army.Players().Count());

Monster? mon = Bot.Monsters.MapMonsters.FirstOrDefault(x => x != null && x.ID == MonID);
Monster? mon = null;
for (int i = 0; i < 5; i++)
{
mon = Bot.Monsters.MapMonsters.FirstOrDefault(x => x != null && x.ID == MonID);
if (mon != null)
break;
Core.Logger($"Attempt {i + 1}: Monster {MonID} not found. Retrying...");
Core.Sleep(1000); // Wait for 1 second before retrying
}

if (mon == null)
{
Core.Logger($"Monster {MonID} not found.");
Core.Logger($"Monster {MonID} not found after 5 attempts.");
return;
}

Expand Down

0 comments on commit 9323ff9

Please sign in to comment.