Esempio n. 1
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);
        }
Esempio n. 2
0
        void import()
        {
            var ft = "类型.txt";
            var f  = "御魂.txt";
            var fs = "式神.txt";

            var t  = File.ReadAllText(f);
            var tt = File.ReadAllText(ft);
            var ts = File.ReadAllText(fs);


            var sslist = App.Settings.ShishenList;

            foreach (var x in ts.Split(new char[] { '\r', '\n' }))
            {
                if (string.IsNullOrWhiteSpace(x))
                {
                    continue;
                }
                var a = splitString(x);
                if (a == null)
                {
                    continue;
                }

                if (sslist.Any(xx => xx.Name == a[0]))
                {
                    continue;
                }

                var ss = new Shishen()
                {
                    Name      = a[0],
                    Gongji    = Convert.ToInt32(a[1]),
                    Shengming = Convert.ToInt32(a[2]),
                    Fangyu    = Convert.ToInt32(a[3]),
                    Sudu      = Convert.ToInt32(a[4]),
                    Baoji     = Convert.ToInt32(a[5]),
                    Baoshang  = Convert.ToInt32(a[6]),
                    Mingzhong = Convert.ToInt32(a[7]),
                    Dikang    = Convert.ToInt32(a[8]),
                };
                sslist.Add(ss);
            }


            var tlist = App.Settings.YuhunTypeList;

            foreach (var x in tt.Split(new char[] { '\r', '\n' }))
            {
                if (string.IsNullOrWhiteSpace(x))
                {
                    continue;
                }

                var a = splitString(x);
                if (a == null)
                {
                    continue;
                }

                if (tlist.Any(xx => xx.Name == a[0]))
                {
                    var re = tlist.First(yy => yy.Name == a[0]);
                    re.SetColor(a[1]);
                    continue;
                }

                var yt = new YuHunType();
                yt.Name = a[0];
                yt.SetColor(a[1]);
                yt.Note        = a[2];
                yt.Val         = Convert.ToInt32(a[3]);
                yt.ShuxingName = a[4];
                tlist.Add(yt);
            }

            var yl = App.db.YuhunList;

            foreach (var x in t.Split(new char[] { '\r', '\n' }))
            {
                if (string.IsNullOrWhiteSpace(x))
                {
                    continue;
                }
                var a = splitString(x);
                if (a == null)
                {
                    continue;
                }


                var yh = new YuHun();
                yh.Index    = Convert.ToInt32(a[0]) - 1;
                yh.TypeName = a[1];
                for (int i = 0; i < 5; i++)
                {
                    yh.Shuxings[i].Name = a[2 + i];
                }

                for (int i = 1; i < 5; i++)
                {
                    yh.Shuxings[i].Val = Convert.ToInt32(a[6 + i]) / 10.0;
                }

                int ind    = Convert.ToInt32(a[11]) - 1;
                var sxname = yh.Shuxings[0].Name;

                if (AppSettings.ZhushuxingDict.ContainsKey(sxname))
                {
                    var d = AppSettings.ZhushuxingDict[sxname];
                    yh.Shuxings[0].Val = d[ind];
                }
                else
                {
                    yh.Shuxings[0].Val = 55;
                }

                if (yl.Any(xx => isequal(xx, yh)))
                {
                    continue;
                }
                yh.Type = App.Settings.YuhunTypeList.First(xx => xx.Name == yh.TypeName);
                yl.Add(yh);
            }
        }
Esempio n. 3
0
        void calYuhun(Dictionary <string, double> d, YuHun yh, int nSameType, char c, Shishen ss)
        {
            int param = 1;

            if (c == '-')
            {
                param = -1;
            }

            if (nSameType == 1 || nSameType == 5)
            {
                d[yh.Type.ShuxingName] += yh.Type.Val * param;
            }

            foreach (var x in yh.Shuxings)
            {
                switch (x.Name)
                {
                case "攻击":
                    d["攻击加成"] += 100 * (x.Val / ss.Gongji) * param;
                    break;

                case "防御":
                    d["防御加成"] += 100 * (x.Val / ss.Fangyu) * param;
                    break;

                case "生命":
                    d["生命加成"] += 100 * (x.Val / ss.Shengming) * param;
                    break;

                default:
                    d[x.Name] += x.Val * param;
                    break;
                }
            }
        }