public void Process() { var numBuilders = getNumBuilders(); if (numBuilders == 0) { context.InfoLog($"No builder"); return; } const int SLEEPS = 5; var junks = junkFinder.Processing(); foreach (var junk in junks) { if (StandardClicks.isRegionGood(junk) && junk.decision == "true") { context.DebugLog($"Found {junk.extraInfo} {junk.cmpRes}"); context.MoveMouseAndClick(junk); Thread.Sleep(1000); var btn = buttons.ProcessingWithRetryTop1(); if (btn != null && btn.decision == "true") { context.MoveMouseAndClick(btn); Thread.Sleep(1000); int found = 0; for (int i = 0; i < 30; i += SLEEPS) { btn = buttons.ProcessingWithRetryTop1(); if (btn != null && btn.decision == "true" && btn.extraInfo.Contains("cancelremove")) { found++; } else { break; } } if (found == 0) { context.DebugLog($"Wait not found, sleep 15s"); Thread.Sleep(1000 * 15); } } } } }
public void ProcessCommand(ProcessingContext context) { var cmd = trainButtonFinder.ProcessingWithRetryTop1(); if (cmd == null) { context.DebugLog("Didn't find Train button"); return; } context.MoveMouseAndClick(cmd); Thread.Sleep(1000); cmd = trainButtonFinder.ProcessingWithRetryTop1(); if (cmd == null) { context.DebugLog("Didn't find Train tab button"); return; } context.MoveMouseAndClick(cmd); Thread.Sleep(1000); var cmds = buildArcherWizardButton.ProcessingWithRetry(); if (!cmds.Any()) { context.DebugLog("Didn't find troop button"); return; } cmd = cmds.FirstOrDefault(c => c.extraInfo.Contains("buildwizardbutton")); if (cmd != null) { context.MoveMouseAndClick(cmd); for (int i = 0; i < 10; i++) { context.MouseClick(); } } cmd = cmds.FirstOrDefault(c => c.extraInfo.Contains("buildArchierButton")); if (cmd != null) { context.MoveMouseAndClick(cmd); context.MouseClick(); } }
public void RearmAll() { var ldr = new AutoResourceLoader(context, StandardClicks.GetTempDirFile("tmpRearmAll.png"), getCheckImgs()); var cmd = ldr.ProcessingWithRetryTop1(r => r.extraInfo != null && r.extraInfo.Contains("townhall")); if (cmd == null) { context.InfoLog("Warning, didn't find townhall"); return; } context.InfoLog($"Found townhall clicking {cmd.extraInfo} {cmd.cmpRes} {cmd.decision}"); context.MoveMouseAndClick(cmd); Thread.Sleep(1000); context.InfoLog($"done wait, try find rearmall"); var cmds = ldr.ProcessingWithRetry(); cmd = cmds.Where(c => c.decision == "true" && c.extraInfo.Contains("rearmall")).OrderBy(c => c.cmpRes).FirstOrDefault(); //cmd = cmds.FirstOrDefault(c => c.extraInfo.Contains("rearmall") && c.cmpRes < 30000); if (cmd == null) { context.InfoLog("Warning, didn't find rearm all"); return; } context.InfoLog($"Found rearm all {cmd.extraInfo} {cmd.cmpRes} {cmd.decision}"); context.MoveMouseAndClick(cmd); cmds = ldr.ProcessingWithRetry(r => r.extraInfo.Contains("ok_bigv1")); cmd = cmds.FirstOrDefault(); if (cmd == null) { context.InfoLog("Warning, didn't find ok button"); return; } context.InfoLog($"Found rearm all ok button {cmd.extraInfo} {cmd.cmpRes} {cmd.decision}"); context.MoveMouseAndClick(cmd); }