예제 #1
0
        private async void jisuanButton(object sender, RoutedEventArgs e)
        {
            if (SelectedShishen == null || string.IsNullOrWhiteSpace(GoalText))
            {
                return;
            }
            try
            {
                beginAnimation();
                var sjt = SelectedYuHunType;
                if (IsSanjian)
                {
                    sjt = null;
                }
                tempYuhunfangan = await Task.Factory.StartNew(() => App.db.GetYuhunFangan(Limits.ToList(), SelectedShishen, GoalText, sjt));

                endAnimation();
                if (tempYuhunfangan == null)
                {
                    ResultTextBox.Text   = "没有满足条件的御魂组合";
                    UIResult.ItemsSource = null;
                    return;
                }
                UIResult.ItemsSource = null;
                UIResult.ItemsSource = tempYuhunfangan.YuhunList;
                ResultTextBox.Text   = tempYuhunfangan.ResultText;
            }
            catch
            {
                ResultTextBox.Text   = "没有满足条件的御魂组合";
                UIResult.ItemsSource = null;
                endAnimation();
            }
        }
예제 #2
0
 public bool IsYuhunFanganExsits(YuhunFangan f)
 {
     if (YuhunFanganList.Any(x => x == f || x.Name == f.Name))
     {
         return(true);
     }
     foreach (var x in YuhunFanganList)
     {
         var b = true;
         foreach (var y in x.Yuhuns)
         {
             if (!f.Yuhuns.Contains(y))
             {
                 b = false;
             }
         }
         if (b)
         {
             return(true);
         }
     }
     return(false);
 }
예제 #3
0
        public YuhunFangan GetYuhunFangan(List <Limit> limits, Shishen ss, string goal, YuHunType sijiantao)
        {
            ncurrent = nProcessTotal = nProcess = 0;
            var g = goal.Split(splitChar).ToList();

            g.RemoveAll(x => string.IsNullOrWhiteSpace(x));
            if (g.Count > 2)
            {
                MessageBox.Show("目标格式错误");
                return(null);
            }
            var allshuxing = App.Settings.ShuxingList;

            for (int i = 0; i < g.Count; i++)
            {
                g[i] = errorInputCorrect(g[i]);
            }

            limits.RemoveAll(x => string.IsNullOrWhiteSpace(x.Name));
            foreach (var x in limits)
            {
                x.Name = errorInputCorrect(x.Name);
            }

            foreach (var x in g)
            {
                if (!allshuxing.Contains(x))
                {
                    MessageBox.Show("目标格式错误");
                    return(null);
                }
            }

            bool isShuchu    = false;
            bool isBaoshang  = false;
            bool isSudu      = false;
            bool isBaoji     = false;
            bool isShengming = false;
            bool isFangyu    = false;
            bool isDikang    = false;
            bool isMingzhong = false;

            if (goal.Contains("攻击"))
            {
                isShuchu = true;
            }
            if (goal.Contains("伤"))
            {
                isBaoshang = true;
            }
            if (goal.Contains("暴击"))
            {
                isBaoji = true;
            }
            if (goal.Contains("防御"))
            {
                isFangyu = true;
            }
            if (goal.Contains("生命"))
            {
                isShengming = true;
            }
            if (goal.Contains("速度"))
            {
                isSudu = true;
            }
            if (goal.Contains("命中"))
            {
                isMingzhong = true;
            }
            if (goal.Contains("抵抗"))
            {
                isDikang = true;
            }

            foreach (var x in limits)
            {
                if (x.Name == "速度" && x.left - ss.Sudu > 56)
                {
                    isSudu = true;
                }
                if (x.Name == "暴击伤害" && x.left - ss.Baoshang >= 89)
                {
                    isBaoshang = true;
                }
                if (x.Name == "暴击" && x.left > 84)
                {
                    isBaoji = true;
                }
                if (x.Name == "攻击加成" && x.left > 170)
                {
                    isShuchu = true;
                }
                if (x.Name == "防御加成" && x.left > 185)
                {
                    isFangyu = true;
                }
                if (x.Name == "生命加成" && x.left > 185)
                {
                    isShengming = true;
                }
                if (x.Name == "效果抵抗" && x.left - ss.Dikang > 80)
                {
                    isDikang = true;
                }
                if (x.Name == "效果命中" && x.left - ss.Mingzhong > 80)
                {
                    isMingzhong = true;
                }
            }


            //初始化


            for (int i = 0; i < 8; i++)
            {
                topVal[AppSettings.shuxingList[i]]    = MaxInt;
                bottomVal[AppSettings.shuxingList[i]] = 0;
            }
            topVal["暴击"] = 114;
            foreach (var x in limits)
            {
                if (topVal.ContainsKey(x.Name))
                {
                    topVal[x.Name] = x.right;
                }
                if (bottomVal.ContainsKey(x.Name))
                {
                    bottomVal[x.Name] = x.left;
                }
            }


            goalParam1    = goalParam2 = null;
            goalType      = 0;
            ans           = null;
            ansYuhun      = new YuHun[6];
            tempsijiantao = sijiantao;
            if (tempsijiantao != null)
            {
                isSanjian = string.IsNullOrWhiteSpace(tempsijiantao.Name);
            }
            else
            {
                isSanjian = true;
            }
            tempShishen = ss;
            tempLimits  = limits;
            goalParam1  = g[0];
            if (g.Count > 1)
            {
                goalParam2 = g[1];
            }
            if (goal.Contains('+') && g.Count == 2)
            {
                goalType = GoalType.plus;
            }
            else if (goal.Contains('*') && g.Count == 2)
            {
                goalType = GoalType.mul;
            }

            var srcList = GetYuhunListNotInYuhunFangan();

            //第一步,主属性
            if (!isBaoshang)
            {
                srcList.RemoveAll(x => x.Shuxings[0].Name == "暴击伤害");
            }
            if (!isSudu)
            {
                srcList.RemoveAll(x => x.Shuxings[0].Name == "速度");
            }
            if (!isDikang)
            {
                srcList.RemoveAll(x => x.Shuxings[0].Name == "效果抵抗");
            }
            if (!isMingzhong)
            {
                srcList.RemoveAll(x => x.Shuxings[0].Name == "效果命中");
            }
            if (!isBaoji)
            {
                srcList.RemoveAll(x => x.Shuxings[0].Name == "暴击");
            }

            if (isFangyu || isFangyu || isShuchu)
            {
                if (!isShuchu)
                {
                    srcList.RemoveAll(x => x.Shuxings[0].Name == "攻击加成");
                }
                if (!isShengming)
                {
                    srcList.RemoveAll(x => x.Shuxings[0].Name == "生命加成");
                }
                if (!isFangyu)
                {
                    srcList.RemoveAll(x => x.Shuxings[0].Name == "防御加成");
                }
            }


            //第二步,删除所有属性值教弱且不能包含不自由属性的御魂

            {
                var notfreeShuxingList = new HashSet <string>();
                var mainShuxingList    = new HashSet <string>();
                foreach (var x in topVal)
                {
                    if (x.Value < 200)
                    {
                        notfreeShuxingList.Add(x.Key);
                    }
                }

                foreach (var x in g)
                {
                    mainShuxingList.Add(x);
                }
                foreach (var x in limits)
                {
                    if (x.left > 0 && !notfreeShuxingList.Contains(x.Name))
                    {
                        mainShuxingList.Add(x.Name);
                    }
                }
                NotFreeShuxingList = notfreeShuxingList;
                MainShuxingList    = mainShuxingList;


                foreach (var x in srcList.ToList())
                {
                    var needRemoveList = new List <YuHun>();

                    foreach (var y in srcList)
                    {
                        //如果类型不同,主属性不同,直接跳过
                        if (y == x || y.Type != x.Type || x[0].Name != y[0].Name)
                        {
                            continue;
                        }

                        //两件套属性相同,但是是四件套,跳过

                        //if ( y.TypeName!=x.TypeName && (y.TypeName == sijiantao.Name || x.TypeName==sijiantao.Name))
                        //    continue;

                        var containsNotFree = false;
                        for (int i = 1; i < 5; i++)
                        {
                            if (notfreeShuxingList.Contains(y[i].Name))
                            {
                                containsNotFree = true;
                                break;
                            }
                        }
                        //包含不自由属性,直接跳过
                        if (containsNotFree)
                        {
                            continue;
                        }

                        var isyx = false;
                        for (int i = 1; i < 5; i++)
                        {
                            if (mainShuxingList.Contains(y[i].Name))
                            {
                                double vy = y[i].Val;
                                double vx = 0;
                                for (int j = 1; j < 5; j++)
                                {
                                    if (x[j].Name == y[i].Name)
                                    {
                                        vx = x[j].Val;
                                        break;
                                    }
                                }
                                if (vy > vx)
                                {
                                    isyx = true;
                                    break;
                                }
                            }
                        }

                        //如果y有属性大于x,跳过
                        if (isyx)
                        {
                            continue;
                        }

                        needRemoveList.Add(y);
                    }

                    foreach (var item in needRemoveList)
                    {
                        srcList.Remove(item);
                    }
                }

                resetYuhunInIndex(srcList);
            }


            Dictionary <string, double> valDict = new Dictionary <string, double>();

            valDict["暴击"]   = ss.Baoji;
            valDict["暴击伤害"] = ss.Baoshang;
            valDict["效果命中"] = ss.Mingzhong;
            valDict["效果抵抗"] = ss.Dikang;
            valDict["速度"]   = ss.Sudu;
            valDict["防御加成"] = 100;
            valDict["生命加成"] = 100;
            valDict["攻击加成"] = 100;

            nProcessTotal = yuhunInIndex[0].Count;
            search(0, valDict);

            if (ansYuhun[0] == null)
            {
                return(null);
            }

            var result = new YuhunFangan(goal, limits, ansYuhun);


            var fast = "";

            foreach (var x in App.Settings.YuhunFanganList)
            {
                if (x.IsUsing)
                {
                    fast += string.Format("[{0}] ", x.Name);
                }
            }

            var st = "";

            st += string.Format("式神:{0}\t四件套:{1}\t以下方案中的御魂没有参与计算:{2}\n\n", ss.Name, isSanjian?"散件":sijiantao.Name, fast);
            st += string.Format("攻击:{0:0.0}\t暴击伤害:{1:0.0}\n", ans["攻击加成"] * ss.Gongji / 100, ans["暴击伤害"]);
            st += string.Format("暴击:{0:0.0}\t速度:{1:0.0}\n", ans["暴击"], ans["速度"]);
            st += string.Format("生命:{0:0.0}\t抵抗:{1:0.0}\n", ans["生命加成"] * ss.Shengming / 100, ans["效果抵抗"]);
            st += string.Format("防御:{0:0.0}\t命中:{1:0.0}\n\n", ans["防御加成"] * ss.Fangyu / 100, ans["效果命中"]);

            int ii = 0;

            foreach (var x in ans)
            {
                st += string.Format("[{0}:{1:0.00}] ", x.Key, x.Value);
                ++ii;
                if (ii == 4)
                {
                    st += '\n';
                }
            }

            result.ResultText = st;

            return(result);
        }