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); } }
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); } }
public static List <D2Empty> GetBestTU10(List <D2Gear> gears = null, List <D2Weapon> weapons = null, List <D2Mod> mods = null) { var nowThreshold = float.Parse(Config.GetValueConf("bestFilterThreshold")); var nowThresholdVal = float.Parse(Config.GetValueConf("bestFilterUpToMax")); var nowThresholdValPercent = float.Parse(Config.GetValueConf("bestFilterUpToMaxPercent")); var list = new List <D2Empty>(); if (gears == null) { gears = new List <D2Gear>(); } if (weapons == null) { weapons = new List <D2Weapon>(); } if (mods == null) { mods = new List <D2Mod>(); } var errorCount = 0; foreach (var o in gears) { try { var coreStr = string.Empty; if (o.core != null && !string.IsNullOrEmpty(o.core)) { coreStr = o.core + "<br/>"; } var attr = FilterAttribute(Translate.AttrValAndText(coreStr + o.attributes)); if (bool.Parse(Config.GetValueConf("ignoreSetsMainAttrIsUtility"))) { if (attr.Count > 0 && attr.Count < 3 && attr[0].isMainAttr && attr[0].valType == AttrValType.Utility && attr[0].valMax == 1) { continue; } } int counter = 0; var colorList = new List <AttrValType>(); foreach (var an in attr) { if (an.val >= an.valMax * nowThreshold) { counter++; colorList.Add(an.valType); } else { var c = an.valMax - an.val; if (an.type == AttributeType.Direct) { if (nowThresholdVal >= 0 && c <= nowThresholdVal) { counter++; colorList.Add(an.valType); } } else { if (nowThresholdValPercent >= 0 && c <= nowThresholdValPercent) { counter++; colorList.Add(an.valType); } } } } if (counter >= attr.Count - 1) { if (colorList.Count <= 1) { list.Add(o); } else if (colorList.Count == attr.Count) { int maxVal = -1; var r = RepeatItem <AttrValType> .GetRepeat(colorList); foreach (var item in r) { if (item.Counter > maxVal) { maxVal = item.Counter; } } if (maxVal != -1 && maxVal >= attr.Count - 1) { list.Add(o); } } else { int maxVal = -1; var r = RepeatItem <AttrValType> .GetRepeat(colorList); foreach (var item in r) { if (item.Counter > maxVal) { maxVal = item.Counter; } } if (maxVal != -1 && maxVal == colorList.Count) { list.Add(o); } } } } catch (Exception) { errorCount++; Logger.Put(LogPopType.File, LogType.Warn, String.Format("筛选优质装备时出现错误,原名称为: {0}", o.name)); } } foreach (var o in weapons) { try { var attr = FilterAttribute(Translate.AttrValAndText(o.attribute1, o.attribute2, o.attribute3)); int counter = 0; foreach (var an in attr) { if (an.val >= an.valMax * nowThreshold) { counter++; } else { var c = an.valMax - an.val; if (an.type == AttributeType.Direct) { if (nowThresholdVal >= 0 && c <= nowThresholdVal) { counter++; } } else { if (nowThresholdValPercent >= 0 && c <= nowThresholdValPercent) { counter++; } } } } if (counter >= attr.Count - 1) { list.Add(o); } } catch (Exception) { errorCount++; Logger.Put(LogPopType.File, LogType.Warn, String.Format("筛选优质武器时出现错误,原名称为: {0}", o.name)); } } foreach (var o in mods) { try { var name = Translate.Name(o.name); var attr = FilterAttribute(Translate.AttrValAndTextMods(o.attributes, name.Equals(o.name) ? null : name)); int counter = 0; foreach (var an in attr) { if (an.val >= an.valMax * nowThreshold) { counter++; } else { var c = an.valMax - an.val; if (an.type == AttributeType.Direct) { if (nowThresholdVal >= 0 && c <= nowThresholdVal) { counter++; } } else { if (nowThresholdValPercent >= 0 && c <= nowThresholdValPercent) { counter++; } } } } if (counter == attr.Count) { list.Add(o); } } catch (Exception) { errorCount++; Logger.Put(LogPopType.File, LogType.Warn, String.Format("筛选优质模组时出现错误,原名称为: {0}", o.name)); } } TitleFunc.theBestErrorCount = errorCount; return(list); }
public static List <D2Empty> GetBest(List <D2Gear> gears = null, List <D2Weapon> weapons = null, List <D2Mod> mods = null) { var list = new List <D2Empty>(); // 3词条判断时需要2词条高属性,2词条判断时只要1词条高属性 + 如果有词条满属性直接推荐 + 默认天赋合理 if (gears == null) { gears = new List <D2Gear>(); } if (weapons == null) { weapons = new List <D2Weapon>(); } if (mods == null) { mods = new List <D2Mod>(); } foreach (var o in gears) { var purple = false; if (Translate.RarityS(o.rarity).Equals("§p")) { purple = true; } var coreStr = string.Empty; if (o.core != null && !string.IsNullOrEmpty(o.core)) { coreStr = o.core + "<br/>"; } var attr = Translate.AttrValAndText(coreStr + o.attributes); if (CanAdd(attr, true, purple)) { list.Add(o); } } foreach (var o in weapons) { var purple = false; if (Translate.RarityS(o.rarity).Equals("§p")) { purple = true; } var attr = Translate.AttrValAndText(o.attribute1, o.attribute2, o.attribute3); if (CanAdd(attr, false, purple)) { list.Add(o); } } // 由于最高值不可信,故仅采用无条模组直接推荐、无最高值记录则忽略、否则大于等于最高值的80%方可推荐 foreach (var o in mods) { var name = Translate.Name(o.name); var attrs = Translate.AttrValAndTextMods(o.attributes, name.Equals(o.name) ? null : name); foreach (var attr in attrs) { if (attr.valMax == 0) { list.Add(o); break; } else if (attr.valMax == Translate.ATTRVALMAXDEFAULT) { continue; } else if (attr.val >= attr.valMax * 0.8) { if (Translate.RarityS(o.rarity).Equals("§p")) { continue; } list.Add(o); break; } } } return(list); }