Esempio n. 1
0
        public static List <string> ModsList(int stdoutIndex, D2Mod mod)
        {
            var stdoutIndexStr = stdoutIndex.ToString().ToCharArray().Length < 2 ? "0" + stdoutIndex.ToString() : stdoutIndex.ToString();

            try
            {
                var l         = new List <string>();
                var name      = Translate.Name(mod.name);
                var whichType = Translate.AttrModFromGearOrSkill(!name.Equals(mod.name), name, mod.attributes);
                var attribute = Translate.AttrValAndTextMods(mod.attributes, whichType == AttrModType.Unknown ? null : name);
                l.Add(stdoutIndexStr + ". " + name);
                var format = "".PadLeft((stdoutIndexStr + ". ").Length);
                l.Add(attribute.Count > 0 && whichType == AttrModType.Skill ? format + attribute[0].modsUseful + "技能模组" : (whichType == AttrModType.Gear ? format + "装备模组" : format + "未知模组"));
                l.Add("");
                var attrSB = new StringBuilder();
                foreach (var attr in attribute)
                {
                    var suffix = attr.desc.StartsWith("§") ? attr.desc.Substring(0, 2) : "";
                    attrSB.Append(format + suffix + attr.val + (attr.type == AttributeType.Percent ? "%" : "") + " " + attr.desc + (attr.val >= attr.valMax ? "[满]" : "") + " ");
                }
                l.Add(attrSB.ToString());
                return(l);
            }
            catch (Exception)
            {
                var l = new List <string>();
                l.Add(stdoutIndexStr + ". " + mod.name);
                l.Add("");
                l.Add("");
                l.Add("数据源异常");
                return(l);
            }
        }
Esempio n. 2
0
        public static List <string> ModsLarge(int stdoutIndex, D2Mod mod, int barLength)
        {
            var stdoutIndexStr = stdoutIndex.ToString().ToCharArray().Length < 2 ? "0" + stdoutIndex.ToString() : stdoutIndex.ToString();

            try
            {
                var l         = new List <string>();
                var name      = Translate.Name(mod.name);
                var whichType = Translate.AttrModFromGearOrSkill(!name.Equals(mod.name), name, mod.attributes);
                var rarity    = Translate.Rarity(mod.rarity);
                var attribute = Translate.AttrValAndTextMods(mod.attributes, whichType == AttrModType.Unknown ? null : name);
                l.Add(stdoutIndexStr + ". " + rarity + "§w " + name);
                var format = "".PadLeft((stdoutIndexStr + ". ").Length);
                l.Add(format + (attribute.Count > 0 && whichType == AttrModType.Skill ? attribute[0].modsUseful + "技能模组" : (whichType == AttrModType.Gear ? "装备模组" : "未知模组")));
                l.Add(format + Translate.Vendor(mod.vendor));
                l.Add("");
                var lattr = new List <string>();
                foreach (var attr in attribute)
                {
                    if (attr.val == 0)
                    {
                        continue;
                    }
                    var    valMax = attr.valMax == Translate.ATTRVALMAXDEFAULT ? "???" : attr.valMax.ToString();
                    var    tmp    = new List <string>();
                    double p;
                    if (attr.valMax == 0)
                    {
                        tmp.Add("+" + attr.val + (attr.type == AttributeType.Percent ? "%" : "") + " " + attr.desc);
                        p = 1;
                    }
                    else
                    {
                        tmp.Add("+" + attr.val + (attr.type == AttributeType.Percent ? "%" : "") + " " + attr.desc + "§w / " +
                                valMax + (attr.type == AttributeType.Percent ? "%" : ""));
                        p = attr.val / attr.valMax;
                    }
                    var bl       = int.Parse(Config.GetValueConf("barLength"));
                    var percent  = (int)Math.Floor(p * (barLength - 1)) / bl;
                    var percent2 = (int)Math.Floor(((barLength - 1) - (double)percent * bl) / bl);
                    if (percent2 < 0)
                    {
                        percent += percent2;
                        percent2 = 0;
                    }
                    var barStr = new StringBuilder();
                    for (int i = 0; i < percent; i++)
                    {
                        barStr.Append("█");
                    }
                    for (int i = 0; i < percent2; i++)
                    {
                        barStr.Append("▁");
                    }
                    tmp.Add("§w" + barStr.ToString());
                    lattr.AddRange(tmp);
                }
                l.Add("属性:");
                l.AddRange(lattr);
                return(l);
            }
            catch (Exception)
            {
                var l = new List <string>();
                l.Add(stdoutIndexStr + ". " + mod.name);
                l.Add("");
                l.Add("");
                l.Add("数据源信息无法正常显示");
                l.Add("可能是源录入错误");
                l.Add("可自行打开当周json文件排错");
                return(l);
            }
        }