private void Awake()
 {
     hand  = FindObjectOfType <Hand>();
     cards = Resources.LoadAll <Card>("Loadable Cards");
     Debug.Log("Loaded cards" + cards.Length);
     deck      = FindObjectOfType <Deck>();
     mulligan  = FindObjectOfType <Mulligan>();
     cardQueue = FindObjectOfType <UIManager>().futureSightQueue;
 }
        private bool PickCardLogic(out ICollection <IBotTask> tasks)
        {
            tasks = new List <IBotTask>();
            if (LeaderBuffMode)
            {
                LeaderBuffMode = false;
                tasks.Add(new TooltipTask("Leader mode..."));
                foreach (var cardType in LeaderBuffList)
                {
                    if (Mulligan.Contain(cardType))
                    {
                        var zone = Mulligan.GetCard(cardType).Area;
                        tasks.Add(new TooltipTask("Buffing..."));
                        tasks.Add(new MouseMoveTask(zone));
                        tasks.Add(new LeftMouseClick());
                        tasks.Add(new SleepTask(1000));
                        return(true);
                    }
                }
            }
            else
            {
                foreach (var cardType in FromHighToLowStr)
                {
                    if (Mulligan.Contain(cardType))
                    {
                        if (GhoulMode || OzzrelMode)
                        {
                            GameMemory.DeleteFromGraveyard(cardType);
                        }
                        if (WeavessIncantationMode)
                        {
                            GameMemory.AddToGraveyard(cardType);
                        }

                        GhoulMode              = false;
                        OzzrelMode             = false;
                        WeavessIncantationMode = false;

                        var zone = Mulligan.GetCard(cardType).Area;
                        tasks.Add(new TooltipTask("Consuming..."));
                        tasks.Add(new MouseMoveTask(zone));
                        tasks.Add(new LeftMouseClick());
                        tasks.Add(new SleepTask(4000));
                        return(true);
                    }
                }
            }
            tasks.Add(new TooltipTask("Choosing random target..."));
            tasks.Add(new KeyboardTask(Messaging.VKeys.Left));
            tasks.Add(new KeyboardTask(Messaging.VKeys.Right));
            tasks.Add(new KeyboardTask(Messaging.VKeys.Enter));
            tasks.Add(new KeyboardTask(Messaging.VKeys.Enter));
            tasks.Add(new SleepTask(1000));
            return(true);
        }
        private bool PickCard(ref Info info)
        {
            if (Extra.IsPickCard != true)
            {
                return(false);
            }
            var image = Services.Container.GetInstance <IScreenShotManager>().CloneImage(Hardware.PickCardArea);
            var items = Services.Container.GetInstance <NeuralNet>().GetItems(image.Bitmap);
            var cards = CardFactory.Create(items, new Point(Hardware.PickCardArea.X, Hardware.PickCardArea.Y));

            Mulligan.Update(cards);
            info = Info.PickCard;
            return(true);
        }
        private bool DetectMulligan(ref Info info)
        {
            if (Extra.IsMulligan != true)
            {
                return(false);
            }
            if (NeedToWaitMulligan)
            {
                NeedToWaitMulligan = false;
                Thread.Sleep(1500); // Mulligan animation is slow
            }
            var image = Services.Container.GetInstance <IScreenShotManager>().CloneImage(Hardware.MulliganArea);
            var items = Services.Container.GetInstance <NeuralNet>().GetItems(image.Bitmap);
            var cards = CardFactory.Create(items, new Point(Hardware.MulliganArea.X, Hardware.MulliganArea.Y));

            Mulligan.Update(cards);
            info = Mulligan.Count() < 3 ? Info.DoNothing : Info.Mulligan;
            return(true);
        }
 private void Reset()
 {
     Hand.Reset();
     Board.Reset();
     Mulligan.Reset();
 }
        private bool MulliganLogic(out ICollection <IBotTask> tasks)
        {
            tasks = new List <IBotTask>();

            #region Replace some pairs

            if (Mulligan.Count(typeof(WildHuntRider)) == 2)
            {
                var card = Mulligan.GetCard(typeof(WildHuntRider));
                return(AddMulliganTask(tasks, card, "Replace 2 riders"));
            }

            if (Mulligan.Count(typeof(Foglet)) == 2)
            {
                var card = Mulligan.GetCard(typeof(Foglet));
                return(AddMulliganTask(tasks, card, "Replace 2 foglets"));
            }

            if (Mulligan.Count(typeof(Werewolf)) == 2)
            {
                var card = Mulligan.GetCard(typeof(Werewolf));
                return(AddMulliganTask(tasks, card, "Replace 2 werewolfs"));
            }

            if (Mulligan.Count(typeof(CelaenoHarpy)) == 2)
            {
                var card = Mulligan.GetCard(typeof(CelaenoHarpy));
                return(AddMulliganTask(tasks, card, "Replace 2 celaeno"));
            }

            if (IsRound1())
            {
                if (Mulligan.Count(typeof(Nekker)) == 2)
                {
                    var card = Mulligan.GetCard(typeof(Nekker));
                    return(AddMulliganTask(tasks, card, "Replace 2 nekkers"));
                }
            }

            #endregion

            #region Already tried to thin foglet

            if (GameMemory.InGraveyard(typeof(Foglet)) &&
                Hand.Contain(typeof(Foglet)))
            {
                var card = Mulligan.GetCard(typeof(Foglet));
                return(AddMulliganTask(tasks, card, "Already tried to thin foglet"));
            }

            #endregion

            #region Replace ozzrel and ghouls

            if (IsRound1())
            {
                if (Mulligan.Contain(typeof(Ghoul)))
                {
                    var card = Mulligan.GetCard(typeof(Ghoul));
                    return(AddMulliganTask(tasks, card, "Don't need ghoul R1"));
                }

                if (Mulligan.Contain(typeof(Ozzrel)))
                {
                    var card = Mulligan.GetCard(typeof(Ozzrel));
                    return(AddMulliganTask(tasks, card, "Don't need ozzrel R1"));
                }
            }

            #endregion

            #region Replace weak card in R2+

            if (NotRound1())
            {
                if (Mulligan.Contain(typeof(Foglet)) &&
                    GameMemory.InGraveyard(typeof(Foglet)))
                {
                    var card = Mulligan.GetCard(typeof(Foglet));
                    return(AddMulliganTask(tasks, card, "Don't need Foglet in R2+"));
                }
                if (Mulligan.Contain(typeof(Plumard)))
                {
                    var card = Mulligan.GetCard(typeof(Plumard));
                    return(AddMulliganTask(tasks, card, "Don't need Plumard in R2+"));
                }
                if (Mulligan.Contain(typeof(Nekker)))
                {
                    var card = Mulligan.GetCard(typeof(Nekker));
                    return(AddMulliganTask(tasks, card, "Don't need Nekker in R2+"));
                }
                if (Mulligan.Contain(typeof(Wyvern)))
                {
                    var card = Mulligan.GetCard(typeof(Wyvern));
                    return(AddMulliganTask(tasks, card, "Don't need Wyvern in R2+"));
                }
                if (Mulligan.Contain(typeof(NekkerWarrior)))
                {
                    var card = Mulligan.GetCard(typeof(NekkerWarrior));
                    return(AddMulliganTask(tasks, card, "Don't need NekkerWarrior in R2+"));
                }
                if (Mulligan.Contain(typeof(Brewess)))
                {
                    var card = Mulligan.GetCard(typeof(Brewess));
                    return(AddMulliganTask(tasks, card, "Don't need Brewess in R2+"));
                }
            }

            #endregion

            tasks.Add(new FinishMulliganTask());
            return(false);
        }