const int YOFF = 0;// 21; public static void MouseMouseTo(IMouse mouse, int x, int y, ProcessingContext context) { y -= YOFF; for (int i = 0; i < 5; i++) { mouse.PutMouseEvent(-200, -200, 0, 0, 0); context.Sleep(100); } const int MAX = 200; while (x > MAX || y > MAX) { int mx = x > MAX ? MAX : x; x -= mx; int my = y > MAX ? MAX : y; y -= my; mouse.PutMouseEvent(mx, my, 0, 0, 0); context.Sleep(100); } mouse.PutMouseEvent(x, y, 0, 0, 0); }
public BaseProcessor(ProcessingContext ctx) { context = ctx; }
public StandardClicks(ProcessingContext ctx) { context = ctx; }
public ActionUpgrade(ProcessingContext ctx) { context = ctx; upgradeBuildingFinder = new AutoResourceLoader(ctx, tempImgName, @"data\check\action\buildings\autocheck"); }
public static UpgradeTrain canUpgrade(ProcessingContext context, string imgName, int numBuilders) { string[] resultTypes = new[] { "Good", "Bad" }; string[] itemTypes = new[] { "Gold", "Eli" }; var sb = new StringBuilder(); sb.Append($"-input {imgName} "); const int actx = 200; const int acty = 630; if (numBuilders > 0) { foreach (var rt in resultTypes) { foreach (var itm in itemTypes) { sb.Append($"-name {rt} -matchRect {actx},{acty},650,105_200 -match data\\check\\upgrade{itm}{rt}.png 40 "); } } } var otherActs = new[] { "Train", "RearmAll" }; var otherImgs = new Dictionary <string, string> { { "Train", "data\\check\\traintroops.png 30" }, { "RearmAll", "data\\check\\rearmall.png 30" } }; foreach (var name in otherActs) { sb.Append($" -name {name} -matchRect {actx},{acty},650,105_200 -match {otherImgs[name]} "); } var res = context.GetAppInfo(sb.ToString()); res.ForEach(r => { r.x += actx; r.y += acty; }); if (context != null) { foreach (var r in res) { context.DebugLog(" DEBUGRM " + r); } } res = res.Where(r => r.decision == "true").OrderBy(r => r.cmpRes).ToList(); if (context != null) { var upgrade = res.FirstOrDefault(r => r.extraInfo == "Good" || r.extraInfo == "Bad"); if (upgrade != null) { context.LogMatchAnalyst(sb.ToString(), upgrade.cmpRes); } } var others = new List <CommandInfo>(); foreach (var name in otherActs) { var found = res.FirstOrDefault(r => r.extraInfo == name); if (found != null) { others.Add(found); context.LogMatchAnalyst(sb.ToString(), found.cmpRes); } } return(new UpgradeTrain { upgrade = res.FirstOrDefault(r => r.extraInfo == "Good" || r.extraInfo == "Bad"), other = others, }); }
public ProcessorMapByText(ProcessingContext ctx) { context = ctx; }
public ProcessorDonation(ProcessingContext ctx) { context = ctx; }
private static void DoProcess(ProcessingContext context) { var controller = context.vdcontroller; //context.DebugLog("TODOREMOVETEMP"); //Thread.Sleep(5000); //context.MouseDragTo(1024/2, 768/2, 1024/4, 768/4); //Christmas hack var resourceClick = new ResourceClicks(context); var baseType = resourceClick.PrimaryOrSecondary(); bool skipProcessing = TryForceMoveToPrimary(resourceClick, context); resourceClick.Processing(baseType); skipProcessing = TryForceMoveToPrimary(resourceClick, context); context.DebugLog("ENDTODOREMOVETEMP"); resourceClick.RearmAll(); new ActionJunkRemove(context).Process(); new ActionUpgrade(context).Process(); //while(controller.humanMode && controller.CurState != ProcessState.SwitchAccount) //{ // controller.Sleep(100); //} var switchAccount = new SwitchAccount(context); context.GetToEntrance(); context.DebugLog("In Entrance, sleep 100"); context.Sleep(1000); int acct = switchAccount.CheckAccount(); if (acct <= 0) { context.InfoLog("failed to get account, try again"); context.Sleep(4000); acct = switchAccount.CheckAccount(); } context.InfoLog($"===>Step gen acct pic {acct}"); switchAccount.CurAccount = acct; GenerateAccountPics(context, switchAccount.CurAccount); context.InfoLog($"===>Step Using account {switchAccount.CurAccount}"); context.vdcontroller.NotifyStartingAccount(switchAccount); if (!skipProcessing) { if (controller.DoDonate()) { var train = new ActionTrainUnits(context); train.ProcessCommand(context); } if (controller.DoDonate() && controller.doDonate) { context.InfoLog("===>Step Donate"); //cmds = Utils.GetAppInfo(); ProcessDonate(context, context.GetToEntrance()); context.GetToEntrance(); } if (controller.DoBuilds() && !controller.switchAccountOnly) { context.InfoLog("===>Step textmap"); new ProcessorMapByText(context).ProcessCommand(acct); } } DoProcessSecondary(resourceClick, context); switchAccount.CurAccount = controller.CheckSetCurAccount(acct); context.InfoLog("===>Step SwitchAccount"); switchAccount.Process(); context.InfoLog("===>Step get to entrance"); context.GetToEntrance(); context.Sleep(4000); controller.DoneCurProcessing(); }
public static void MoveMouseAndClick(IMouse mouse, int x, int y, ProcessingContext context) { MouseMouseTo(mouse, x, y, context); MouseClick(mouse, context); }