From 9323ff976a7c5dc3d9e0368c13eca1fbdd8c1e45 Mon Sep 17 00:00:00 2001 From: Vld Mrk Date: Mon, 4 Nov 2024 14:30:17 +0100 Subject: [PATCH] Implement retry logic for monster retrieval in ArchMageMatsArmy with logging for attempts --- Army/Various/ArmyArchMageBossItems.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Army/Various/ArmyArchMageBossItems.cs b/Army/Various/ArmyArchMageBossItems.cs index fa0c4e30a..540d9c58d 100644 --- a/Army/Various/ArmyArchMageBossItems.cs +++ b/Army/Various/ArmyArchMageBossItems.cs @@ -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; }