コード例 #1
0
ファイル: MacroData.cs プロジェクト: ray2k/Maacro
 public MacroData(IEnumerable<ScreenElement> elements, IEnumerable<DeploymentSlot> deployment, int uiDelay, int heroPageCount, DeployLength length)
 {
     _Deployment = new ReactiveCollection<DeploymentSlot>(deployment);
     _ScreenElements = new ReactiveCollection<ScreenElement>(elements);
     _Deployment.ChangeTrackingEnabled = true;
     _ScreenElements.ChangeTrackingEnabled = true;
     _UIDelay = uiDelay;
     _HeroPageCount = heroPageCount;
     _Length = length;
 }
コード例 #2
0
ファイル: MacroGenerator.cs プロジェクト: ray2k/Maacro
        public IEnumerable<MacroStep> GenerateMacro(IEnumerable<DeploymentSlot> deployment, IEnumerable<ScreenElement> screenElements,  int uiDelay, int totalHeroPages, DeployLength length)
        {
            this.Builder = new MacroBuilder(screenElements, uiDelay);
            int deploymentNumber = 1;
            SetupBayLookup(screenElements);
            SetupSlotLookup(screenElements);

            foreach (var toDeploy in deployment)
            {
                Trace.WriteLine(string.Format("Writing steps for Page {0} Slot {1}", toDeploy.PageNumber, toDeploy.SlotNumber));

                Builder.AddDelay("Startup delay")
                        .AddClick(GetBayFor(deploymentNumber))
                        .AddDelay()
                        .AddClick(GetBayFor(deploymentNumber)) // click deploy
                        .AddDelay();

                if (deploymentNumber == 1)
                {
                    int pagesToDecrement = totalHeroPages - 1;
                    for (int i = 0; i < pagesToDecrement; i++)
                    {
                        Builder.AddClick(ScreenElementType.PrevHeroPage, "to get back to page 1");
                        Builder.AddDelay();
                    }
                }

                if (toDeploy.PageNumber > 1)
                {
                    int pagesToIncrement = toDeploy.PageNumber - 1;
                    for (int i = 0; i < pagesToIncrement; i++)
                    {
                        Builder.AddClick(ScreenElementType.NextHeroPage, "to get to target page").AddDelay();
                    }
                }

                Builder.AddClick(GetSlotFor(toDeploy.SlotNumber))
                       .AddDelay()
                       .AddClick(ScreenElementType.ConfirmButton);

                deploymentNumber++;
            }

            var deployDelay = TimeSpan.Zero;

            if (length == DeployLength.TwentyMinute)
            {
                deployDelay = new TimeSpan(0, 20, 3);

                int remainingDelay = (int) deployDelay.TotalMilliseconds;
                int totalDelayAccountedFor = 0;

                while (totalDelayAccountedFor < (int)deployDelay.TotalMilliseconds)
                {
                    int batchSizeInMs = (int)TimeSpan.FromMinutes(4.0).TotalMilliseconds;
                    if (remainingDelay > batchSizeInMs)
                    {
                        Builder.AddDelay(batchSizeInMs);
                        Builder.AddClick(ScreenElementType.NextHeroPage);

                        totalDelayAccountedFor += batchSizeInMs;
                        remainingDelay -= batchSizeInMs;
                    }
                    else
                    {
                        Builder.AddDelay(remainingDelay); //whatever's left thats < batchsize
                        totalDelayAccountedFor += remainingDelay;
                        remainingDelay = 0;
                    }
                }
            }
            else
            {
                deployDelay = new TimeSpan(0, 3, 3);
                Builder.AddDelay((int)deployDelay.TotalMilliseconds);
            }

            int restockingDelay = deployment.Count() * 2750;

            Builder.AddClick(ScreenElementType.JetBay1)
                   .AddDelay()
                   .AddClick(ScreenElementType.CollectAll)
                   .AddDelay(restockingDelay);

            return Builder.GetMacro();
        }