Exemple #1
0
        public static List <string> WeaponsLarge(int stdoutIndex, D2Weapon weapon, int barLength)
        {
            var stdoutIndexStr = stdoutIndex.ToString().ToCharArray().Length < 2 ? "0" + stdoutIndex.ToString() : stdoutIndex.ToString();

            try
            {
                var l          = new List <string>();
                var name       = Translate.Name(weapon.name, true);
                var rarity     = Translate.Rarity(weapon.rarity);
                var attribute  = Translate.AttrValAndText(weapon.attribute1, weapon.attribute2, weapon.attribute3);
                var talent     = Translate.Talents(weapon.talent);
                var talentDesc = Translate.TalentsDesc(talent);
                var format     = "".PadLeft((stdoutIndexStr + ". ").Length);
                l.Add(stdoutIndexStr + ". " + rarity + "§w " + name);
                l.Add(format + weapon.dmg + " 伤害");
                l.Add(format + "射速:" + weapon.rpm + " 弹夹:" + weapon.mag);
                l.Add(format + "商人:" + Translate.Vendor(weapon.vendor));
                l.Add("");
                var lattrmain = new List <string>();
                var lattroff  = new List <string>();
                foreach (var attr in attribute)
                {
                    if (attr.val == 0 || attr.valMax == 0)
                    {
                        continue;
                    }
                    var valMax = attr.valMax == Translate.ATTRVALMAXDEFAULT ? "???" : attr.valMax.ToString();
                    var tmp    = new List <string>();
                    var str    = attr.val >= attr.valMax ? "§o▲§w +" : "+";
                    if (attr.isMainAttr && attr.valType == AttrValType.Utility)
                    {
                        str = "+";
                    }
                    var checkValError = attr.val > (attr.valMax * 1.67) ? " §y数值异常?§w" : "";
                    tmp.Add(str + attr.val + (attr.type == AttributeType.Percent ? "%" : "") + " " + attr.desc + "§w / " +
                            valMax + (attr.type == AttributeType.Percent ? "%" : "") + checkValError);
                    var bl       = int.Parse(Config.GetValueConf("barLength"));
                    var percent  = (int)Math.Floor(attr.val / attr.valMax * (barLength - 1)) / bl;
                    var percent2 = (int)Math.Floor(((barLength - 1) - (double)percent * bl) / bl);
                    if (percent2 < 0)
                    {
                        percent += percent2;
                        percent2 = 0;
                    }
                    var color = "";
                    switch (attr.valType)
                    {
                    case AttrValType.Offensive:
                        color = "§r";
                        break;

                    case AttrValType.Defensive:
                        color = "§c";
                        break;

                    case AttrValType.Utility:
                        color = "§y";
                        break;

                    case AttrValType.Unknown:
                    default:
                        color = "§w";
                        break;
                    }
                    var barStr = new StringBuilder();
                    for (int i = 0; i < percent; i++)
                    {
                        barStr.Append("█");
                    }
                    for (int i = 0; i < percent2; i++)
                    {
                        barStr.Append("▁");
                    }
                    tmp.Add(color + barStr.ToString());
                    if (attr.isMainAttr)
                    {
                        lattrmain.AddRange(tmp);
                    }
                    else
                    {
                        lattroff.AddRange(tmp);
                    }
                }
                l.Add("主要属性:");
                l.AddRange(lattrmain);
                l.Add("");
                l.Add("次要属性:");
                l.AddRange(lattroff);
                if (!string.IsNullOrWhiteSpace(talent))
                {
                    l.Add("");
                    l.Add("天赋:" + talent);
                    if (talentDesc.Length != 0)
                    {
                        foreach (string str in talentDesc)
                        {
                            l.Add(str);
                        }
                    }
                }
                return(l);
            }
            catch (Exception)
            {
                var l = new List <string>();
                l.Add(stdoutIndexStr + ". " + weapon.name);
                l.Add("");
                l.Add("");
                l.Add("数据源信息无法正常显示");
                l.Add("可能是源录入错误");
                l.Add("可自行打开当周json文件排错");
                return(l);
            }
        }
Exemple #2
0
        public static List <string> WeaponsList(int stdoutIndex, D2Weapon weapon)
        {
            var stdoutIndexStr = stdoutIndex.ToString().ToCharArray().Length < 2 ? "0" + stdoutIndex.ToString() : stdoutIndex.ToString();

            try
            {
                var l         = new List <string>();
                var name      = Translate.Name(weapon.name, true);
                var attribute = Translate.AttrValAndText(weapon.attribute1, weapon.attribute2, weapon.attribute3);
                var type      = Translate.WeaponAttrToType(attribute);
                var talent    = Translate.Talents(weapon.talent);
                l.Add(stdoutIndexStr + ". " + name);
                //l.Add("伤害:" + weapon.dmg + " 射速:" + weapon.rpm + " 弹夹:" + weapon.mag);
                l.Add(string.IsNullOrWhiteSpace(type) ? "" : $"[{type}]");
                var attrstr     = string.Empty;
                var attrstrmain = new List <string>();
                var attrstroff  = new List <string>();
                foreach (var attr in attribute)
                {
                    string tmp;
                    if (attr.val == 0)
                    {
                        tmp = Translate.TransAttrValType(attr.valType);
                    }
                    else
                    {
                        if (attr.val >= attr.valMax && attr.val / attr.valMax < 3)
                        {
                            if (attr.isMainAttr && attr.valType == AttrValType.Utility)
                            {
                                tmp = Translate.TransAttrValType(attr.valType);
                            }
                            else
                            {
                                tmp = Translate.TransAttrValType(attr.valType) + "[满]";
                            }
                        }
                        else
                        {
                            tmp = Translate.TransAttrValType(attr.valType);
                        }
                    }
                    if (attr.isMainAttr)
                    {
                        attrstrmain.Add(tmp);
                    }
                    else
                    {
                        attrstroff.Add(tmp);
                    }
                }
                attrstr += "主属性:" + string.Join(" ", attrstrmain);
                l.Add(attrstr);
                attrstr = "次属性:" + string.Join(" ", attrstroff);
                l.Add(attrstr);
                if (!string.IsNullOrWhiteSpace(talent))
                {
                    l.Add("天赋:" + talent);
                }
                return(l);
            }
            catch (Exception)
            {
                var l = new List <string>();
                l.Add(stdoutIndexStr + ". " + weapon.name);
                l.Add("");
                l.Add("");
                l.Add("数据源异常");
                return(l);
            }
        }