//添加禁用词 public ActionResult AddContent(FormCollection form) { string msg = form["msg"]; msg = msg.Trim(); string[] words = msg.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); foreach (string str in words) { string[] word = str.Split('='); ForbiddenList forbid = new ForbiddenList(); forbid.WordPattern = word[0]; forbid.Id = Guid.NewGuid(); if (word[1] == "{BANNED}") { forbid.IsForbid = true; } else if (word[1] == "{MOD}") { forbid.IsMod = true; } else { forbid.ReplaceWord = word[1]; } ForbiddenListBll.Add(forbid); } return(Content("ok")); }
public ActionResult BannedDel(Guid id) { ForbiddenList b = new ForbiddenList() { Id = id }; if (ForbiddenListBll.Delete(b)) { return(Content("ok")); } else { return(Content("no")); } }
public static void LoadForbiddenLists() { ForbiddenLists = new List <ForbiddenList>(); try { ForbiddenList current = null; StreamReader reader = new StreamReader(Config.LfListPath); while (!reader.EndOfStream) { string line = reader.ReadLine(); if (string.IsNullOrEmpty(line) || line.StartsWith("#")) { continue; } if (line.StartsWith("!")) { current = new ForbiddenList(line.Substring(1, line.Length - 1)); ForbiddenLists.Add(current); continue; } if (!line.Contains(" ") || current == null) { continue; } string[] data = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (data?.Length > 1 && uint.TryParse(data[0], out uint code) && int.TryParse(data[1], out int qualf)) { current.Add(code, qualf); } } } catch (Exception e) { Debug.LogAssertion(e.Message + e.GetType() + e.StackTrace); } ForbiddenLists.Add(new ForbiddenList("N/A")); }
public static List <CardData> Search(CardData target, ForbiddenList flist = null, int qualification = 3) { List <CardData> results = new List <CardData>(); if (target.Name != null && uint.TryParse(target.Name, out uint tempcode)) { if (cardDictionary.TryGetValue(tempcode, out CardData data)) { results.Add(data); return(results); } } foreach (var data in cardDictionary.Values) { if ((data.Type & (uint)CardType.Token) > 0) { continue; } if (flist != null && qualification < 3) { if (flist.Query(data) != qualification) { continue; } } if (target.Type > 0) { if ((target.Type & 0x1) > 0) { if ((target.Type & data.Type) != target.Type) { continue; } if ((target.Race != 0 && (target.Race & data.Race) != target.Race) || (target.Attribute != 0 && (target.Attribute & data.Attribute) == 0)) { continue; } if ((target.Attack > 0 && target.Attack != data.Attack)) { continue; } if ((target.Type & (uint)CardType.Link) == 0 && target.Defense > 0 && target.Defense != data.Defense) { continue; } if ((target.Level > 0 && target.Level != data.Level) || (target.LScale > 0 && target.LScale != data.LScale)) { continue; } if (target.LinkMarker != 0 && (data.LinkMarker & target.LinkMarker) != target.LinkMarker) { continue; } } else if ((target.Type & 0x2) > 0) { if (target.Type == 0x2) { if ((data.Type & 0x2) == 0) { continue; } } else { if ((data.Type & target.Type) != data.Type) { continue; } if ((target.Type & (uint)CardType.Normal) == 0) { if (data.Type == 0x2) { continue; } } } } } else if ((target.Attribute & 0x4) > 0) { if (target.Attribute == 0x4) { if ((data.Type & 0x4) == 0) { continue; } } else { if ((data.Type & target.Attribute) != data.Type) { continue; } if ((target.Attribute & (uint)CardType.Normal) == 0) { if (data.Type == 0x4) { continue; } } } } if (target.Name != null) { if (!data.Name.Contains(target.Name) && !data.Descrition.Contains(target.Name)) { continue; } } if (target.Category > 0 && !((target.Category & data.Category) > 0)) { continue; } if (target.OTExclusive > 0 && target.OTExclusive != data.OTExclusive) { continue; } results.Add(data); } return(results); }