예제 #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);
        }
예제 #2
0
 public CommandInfo FindSpot(string name, int retry = 5, string printDebug = "")
 {
     for (int retryi = 0; retryi < retry; retryi++)
     {
         context.DebugLog($"{printDebug}Trying to find SINGLEMATCH for {name}");
         var cmds  = Utils.GetAppInfo(name, context);
         var found = cmds.FirstOrDefault(cmd => cmd.command == "SINGLEMATCH");
         if (found != null && found.decision == "true")
         {
             context.InfoLog($"{printDebug}matching {name} found {found.cmpRes} {found.decision}");
             context.LogMatchAnalyst(name, found.cmpRes);
             return(found);
         }
         else
         {
             context.InfoLog($"{printDebug}matching {name} NOT found {found.cmpRes} {found.decision}");
         }
         context.Sleep(1000);
     }
     return(null);
 }
예제 #3
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,
            });
        }