예제 #1
0
 public MythGame(int _timeLeft = 59)
 {
     currentIndex = 0;
     aRight = 0;
     aWrong = 0;
     timeLeft = _timeLeft;
     // get all characters with nations filter
     characters = (from fd in MythDB.Instance.Database.Characters where fd.Nation.IsActive select fd).ToList();
     characters.Shuffle();
 }
예제 #2
0
        private void print()
        {
            sppool1.Children.Clear();
            sppool2.Children.Clear();
            sppool3.Children.Clear();

            var l1 = new List<Image>();
            var l2 = new List<Image>();
            var l3 = new List<Image>();

            foreach (var item in pool1)
            {
                Image img = new Image();
                string url = "Images/" + item + ".png";
                img.Source = new BitmapImage(new Uri(url, UriKind.RelativeOrAbsolute));
                img.Height = 96;
                img.Width = 72;
                img.VerticalAlignment = VerticalAlignment.Top;
                img.Margin = new Thickness(10);
                l1.Add(img);
                //sppool1.Children.Add(img);
            }

            foreach (var item in pool2)
            {
                Image img = new Image();
                string url = "Images/" + item + ".png";
                img.Source = new BitmapImage(new Uri(url, UriKind.RelativeOrAbsolute));
                img.Height = 96;
                img.Width = 72;
                img.VerticalAlignment = VerticalAlignment.Top;
                img.Margin = new Thickness(10);
                l2.Add(img);
                //sppool2.Children.Add(img);
            }
            foreach (var item in pool3)
            {
                Image img = new Image();
                string url = "Images/" + item + ".png";
                img.Source = new BitmapImage(new Uri(url, UriKind.RelativeOrAbsolute));
                img.Height = 96;
                img.Width = 72;
                img.VerticalAlignment = VerticalAlignment.Top;
                img.Margin = new Thickness(10);
                l3.Add(img);
                //sppool3.Children.Add(img);
            }

            l1.Shuffle();
            l2.Shuffle();
            l3.Shuffle();

            foreach (var item in l1)
            {
                sppool1.Children.Add(item);
            }

            foreach (var item in l2)
            {
                sppool2.Children.Add(item);
            }

            foreach (var item in l3)
            {
                sppool3.Children.Add(item);
            }

            //lbxpool1.ItemsSource = pool1;
            //lbxpool2.ItemsSource = pool2;
            //lbxpool3.ItemsSource = pool3;
        }
예제 #3
0
 private void Initializedeck()
 {
     deck = new List<int>();
     for (int i = 1; i < 22; i++)
     {
         deck.Add(i);
     }
     deck.Shuffle();
 }
예제 #4
0
        /// <summary>
        /// This task implements custom mulligan choosing logic for the bot.
        /// The user is expected to set the Mulligans list elements to true/false 
        /// to signal to the bot which cards should/shouldn't be mulliganed. 
        /// This task should also implement humanization factors, such as hovering 
        /// over cards, or delaying randomly before returning, as the mulligan 
        /// process takes place as soon as the task completes.
        /// </summary>
        /// <param name="mulliganData">An object that contains relevant data for the mulligan process.</param>
        /// <returns></returns>
        public async Task MulliganLogic(MulliganData mulliganData)
        {
            Log.InfoFormat("[Mulligan] {0} vs {1}.", mulliganData.UserClass, mulliganData.OpponentClass);

            var count = mulliganData.Cards.Count;

            /*string ownName = mulliganData.UserClass.ToString();
            string enemName = mulliganData.OpponentClass.ToString();
            if (Mulligan.Instance.hasmulliganrules(ownName, enemName))
            {
                    bool hascoin = false;
                    List<Mulligan.CardIDEntity> celist = new List<Mulligan.CardIDEntity>();
                    

                    for (var i = 0; i < mulliganData.Cards.Count; i++)
                    {
                        string id = mulliganData.Cards[i].Entity.Id
                        if ( id != "GAME_005")// dont mulligan coin
                        {
                            celist.Add(new Mulligan.CardIDEntity(id, i));
                        }
                        else
                        {
                            hascoin = true;
                        }
                        
                    }

                    if (celist.Count >= 4) hascoin = true;
                    List<int> mullientitys = Mulligan.Instance.whatShouldIMulligan(celist, ownName, enemName, hascoin);

                    for (var i = 0; i < mulliganData.Cards.Count; i++)
                    {
                        if (mullientitys.Contains(i))
                        {
                            Helpfunctions.Instance.ErrorLog("Rejecting Mulligan Card " + mulliganData.Cards[i].Entity.Id + " because of your rules");                            

                            
                        }
                    }

            }*/

            if (Mulligan.Instance.mulliganRulesLoaded)
            {
                Mulligan.Instance.getHoldList(mulliganData);
            }
            else
            {
                for (var i = 0; i < count; i++)
                {
                    var card = mulliganData.Cards[i];

                    try
                    {
                        foreach (var tuple in _mulliganRules)
                        {
                            if (GetCondition(tuple.Item1,
                                new List<RegisterScriptVariableDelegate>
                            {
                                scope => scope.SetVariable("mulliganData", mulliganData)
                            }))
                            {
                                if (GetCondition(tuple.Item2,
                                    new List<RegisterScriptVariableDelegate>
                                {
                                    scope => scope.SetVariable("mulliganData", mulliganData),
                                    scope => scope.SetVariable("card", card)
                                }))
                                {
                                    mulliganData.Mulligans[i] = true;
                                    Log.InfoFormat(
                                        "[Mulligan] {0} should be mulliganed because it matches the user's mulligan rule: [{1}] ({2}).",
                                        card.Entity.Id, tuple.Item2, tuple.Item1);
                                }
                            }
                            else
                            {
                                Log.InfoFormat(
                                    "[Mulligan] The mulligan execution check [{0}] is false, so the mulligan criteria [{1}] will not be evaluated.",
                                    tuple.Item1, tuple.Item2);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.ErrorFormat("[Mulligan] An exception occurred: {0}.", ex);
                        BotManager.Stop();
                        return;
                    }
                }
            }

            var thinkList = new List<KeyValuePair<int, int>>();
            for (var i = 0; i < count; i++)
            {
                thinkList.Add(new KeyValuePair<int, int>(i%count, RandomMulliganThinkTime()));
            }
            thinkList.Shuffle();

            foreach (var entry in thinkList)
            {
                var card = mulliganData.Cards[entry.Key];

                Log.InfoFormat("[Mulligan] Now thinking about mulliganing {0} for {1} ms.", card.Entity.Id, entry.Value);

                // Instant think time, skip the card.
                if (entry.Value == 0)
                    continue;

                Client.MouseOver(card.InteractPoint);

                await Coroutine.Sleep(entry.Value);
            }
        }