Esempio n. 1
0
        private bool Upgraded()
        {
            Utils.doScreenShoot(tempImgName);
            var sb = new StringBuilder();

            sb.Append($"-input {tempImgName} ");
            sb.Append($"-name g1 -match data\\check\\upgradeWithEliButton.png 400 ");
            sb.Append($" -name g2 -match data\\check\\upgradeWithGoldButton.png 400 ");
            var btns = context.GetAppInfo(sb.ToString());

            foreach (var btn in btns)
            {
                context.DebugLog("           check train button " + btn);
            }
            btns = btns.Where(r => r.decision == "true").OrderBy(r => r.cmpRes).ToList();
            if (btns.FirstOrDefault() != null)
            {
                var btn   = btns.First();
                var fname = btn.extraInfo == "g1" ? "upgradeWithEliButton.png" : "upgradeWithGoldButton.png";
                context.LogMatchAnalyst($"UPGRADING -match {fname} 400", btn.cmpRes);
                context.MoveMouseAndClick(btn.x + 20, btn.y + 20);
                return(true);
            }
            return(false);
        }
Esempio n. 2
0
        static void checkLoop(ProcessingContext context)
        {
            //Utils.doScreenShoot("tstimgs\\full.png");

            context.DebugLog("Getting app info");
            //cmds = Utils.GetAppInfo("-name allfull -screenshoot");
            //cmds = Utils.GetAppInfo("-name c5 -matchRect 79,32,167,22_200 -screenshoot");
            context.GetToEntrance();
            context.DebugLog("Do shift");
            context.DoShift();
            var controller = context.vdcontroller;

            controller.Init();
            while (controller.canContinue())
            {
                try
                {
                    controller.CustomAction(context);
                    DoProcess(context);
                } catch (SwitchProcessingActionException swa)
                {
                    controller.Log("info", "switch action " + swa.Message);
                }
            }
        }
Esempio n. 3
0
        public void Process()
        {
            var items = upgradeBuildingFinder.Processing();

            foreach (var itm in items)
            {
                if (itm.x > 200)
                {
                    if (!StandardClicks.isRegionGood(itm))
                    {
                        context.InfoLog($"found too far skipp {itm.extraInfo} {itm.x}/{itm.y}");
                        continue;
                    }
                    context.InfoLog($"found {itm.extraInfo} {itm.x}/{itm.y}");
                    var cmdres      = ActionStructureNameReco.GetNameAtPoint(context, itm);
                    var numBuilders = NumBuilders(context, cmdres);
                    if (numBuilders == 0)
                    {
                        context.InfoLog($"No builder");
                        return;
                    }
                    Thread.Sleep(1000);
                    var nameLevel = ActionStructureNameReco.GetStructureName(itm, cmdres, context);
                    if (nameLevel == null)
                    {
                        cmdres    = ActionStructureNameReco.GetNameAtPoint(context, itm);
                        nameLevel = ActionStructureNameReco.GetStructureName(itm, cmdres, context);
                        if (nameLevel == null)
                        {
                            context.InfoLog($"failed reco namelevel {itm.extraInfo} {itm.x}/{itm.y}");
                            continue;
                        }
                    }
                    var goodNames = ActionStructureNameReco.GetGoodNames();

                    foreach (var gname in goodNames)
                    {
                        if (gname.ToLower() == nameLevel.name.ToLower())
                        {
                            context.DebugLog($"found match name {gname}");
                            //context.MoveMouseAndClick(itm);
                            //Thread.Sleep(1000);
                            var upgGrood = canUpgrade(context, numBuilders);
                            if (upgGrood != null && upgGrood.extraInfo.Contains("Good"))
                            {
                                context.MoveMouseAndClick(upgGrood);
                                Upgraded();
                                numBuilders--;
                            }
                            break;
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        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);
                        }
                    }
                }
            }
        }
Esempio n. 5
0
 protected bool FoundOtherGoodAlts(StepContext stepCtx, StepInfo cur)
 {
     if (cur.otherStepCheck != null)
     {
         bool otherFound = false;
         foreach (var other in cur.otherStepCheck)
         {
             if (CheckStep(stepCtx, other))
             {
                 otherFound = true;
                 break;
             }
         }
         context.DebugLog($"   FOUND ALT {otherFound}");
         return(otherFound);
     }
     return(false);
 }
Esempio n. 6
0
        private static void GenerateAccountPics(ProcessingContext context, int who)
        {
            context.DebugLog("------------------Generate account pics");
            context.GetToEntrance();
            var fullImg = $"tstimgs\\accountFull_{who}.png";

            Utils.doScreenShoot(fullImg);
            //Utils.GetAppInfo($"-name data\\accounts\\img_act{who}.png -input {fullImg} {SwitchAccount.acctNameMatchRect} -imagecorp");
        }
Esempio n. 7
0
        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();
            }
        }
Esempio n. 8
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());
        }
Esempio n. 9
0
        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,
            });
        }
Esempio n. 10
0
        public void ProcessDonate(CommandInfo cmd)
        {
            if (cmd.cmpRes > 2)
            {
                return;
            }

            var donatedPos = new List <CommandInfo>();
            //ImgChecksAndTags("donatebutton1.png", "INFO_DonateButtonFound", Point(51,19)),
            var processed = new List <CommandInfo>();

            for (int i = 0; i < 5; i++)
            {
                //if (context.vdcontroller.humanMode) break;
                context.MoveMouseAndClick(cmd.x, cmd.y);
                bool found = false;
                context.Sleep(2000);
                Utils.doScreenShoot(ProcessorMapByText.tempImgName);
                context.DebugLog("DEBUGPRINTINFO trying to find donation button");
                //-matchRect 227,102,140,600_200
                const int donateRectx = 227;
                const int donateRecty = 102;
                var       results     = Utils.GetAppInfo($"-input {ProcessorMapByText.tempImgName} -name donate -matchRect {donateRectx},{donateRecty},140,600_200 -top 5  -match data\\check\\donatebutton.png 1900", context);
                foreach (var donate in results)
                {
                    //if (context.vdcontroller.humanMode) break;
                    if (donatedPos.Any(dp => dp.y == donate.y))
                    {
                        continue;
                    }
                    donatedPos.Add(donate);
                    if (donate.decision == "true")
                    {
                        if (processed.Any(p =>
                        {
                            return(Math.Abs(p.y - donate.y) < 20);
                        }))
                        {
                            continue;
                        }
                        processed.Add(donate);
                        found = true;
                        context.Sleep(100);
                        context.MoveMouseAndClick(donateRectx + donate.x + 55, donateRecty + donate.y + 23);
                        context.Sleep(1000);
                        for (int dwretry = 0; dwretry < 2; dwretry++)
                        {
                            Utils.doScreenShoot(ProcessorMapByText.tempImgName);
                            var dw    = Utils.GetAppInfo($"-input {ProcessorMapByText.tempImgName} -name dw  -match data\\check\\donate_wizard.png 300", context);
                            var dwbtn = dw.FirstOrDefault(dwf => dwf.decision == "true");
                            if (dwbtn != null)
                            {
                                context.MoveMouseAndClick(50 + dwbtn.x, 50 + dwbtn.y);
                                for (int cli = 0; cli < 5; cli++)
                                {
                                    context.MouseClick();
                                }
                                break;
                            }
                        }
                        DonateArchier();
                        context.DoStdClicks();
                    }
                }
                if (!found)
                {
                    break;
                }
            }
        }
Esempio n. 11
0
        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();
        }