Пример #1
0
        public static CommandInfo canUpgrade(ProcessingContext context, int numBuilders)
        {
            context.MouseMouseTo(0, 0);
            string imgName = StandardClicks.GetTempDirFile("tempUpgradeBuildingUpg.png");

            Utils.doScreenShoot(imgName);
            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 {itm}_{rt} -matchRect {actx},{acty},650,105_200 -match data\\check\\upgrade{itm}{rt}.png 40 ");
                    }
                }
            }
            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);
                }
            }
            return(res.Where(r => r.decision == "true").OrderBy(r => r.cmpRes).FirstOrDefault());
        }
Пример #2
0
        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);
        }