/// <summary> /// 把抽奖信息汇总到字典中 /// </summary> /// <param name="ListText">待汇总的抽奖信息</param> /// <param name="RandomInfo">加入的字典</param> public void MoHeAddInfo(string ListText, Dictionary <int, MoHe> RandomInfo, List <List <string> > LstNameInfo) { Regex_new regex = new Regex_new(); string AwName = ""; int AwId; int AwSl; int AwGg; ListText = ListText.Substring(ListText.IndexOf("\t") + 1); AwId = Convert.ToInt32(ListText.Remove(ListText.IndexOf("\t"))); ListText = ListText.Substring(ListText.IndexOf("\t") + 1); AwSl = Convert.ToInt32(ListText.Remove(ListText.IndexOf("\t"))); ListText = ListText.Substring(ListText.IndexOf("\t") + 1); AwGg = Convert.ToInt32(ListText.Remove(ListText.IndexOf("\t"))); ListText = ListText.Substring(ListText.IndexOf("\t") + 1); int Pos = LstNameInfo[0].IndexOf(AwId.ToString()); if (Pos != -1) { AwName = LstNameInfo[1][Pos]; } int AddCount = 0; RandomInfo.Add(AddCount, new MoHe( AwName, AwId, 0, AwSl, AwGg, 0 )); AddCount++; regex.创建(ListText, "([\x20-\x7f]+)\t([\x20-\x7f]+)\t([\x20-\x7f]+)\t([\x20-\x7f]+)\t", 0); foreach (Match item in regex.正则返回集合()) { string Id = item.Groups[1].Value; string Name = ""; int Poss = LstNameInfo[0].IndexOf(Id); if (Poss != -1) { Name = LstNameInfo[1][Poss]; } RandomInfo.Add(AddCount, new MoHe( Name, Convert.ToInt32(Id), Convert.ToInt32(item.Groups[2].Value), Convert.ToInt32(item.Groups[3].Value), Convert.ToInt32(item.Groups[4].Value), 0 )); AddCount++; } }
/// <summary> /// 获得抽奖列表内的总概率 /// </summary> /// <param name="ListText">待获取概率的文本</param> /// <param name="MoShi">0:魔盒/1:袖珍罐/2:礼包/3:抽奖机</param> /// <param name="FenZu">魔盒:4/袖珍罐:3/礼包:3|5/抽奖机:4</param> /// <returns>总概率</returns> public int ZongGaiLv(string ListText, int MoShi, int FenZu) { int Count = 0; Regex_new regex = new Regex_new(); switch (MoShi) { case 0: regex.创建(ListText.Substring( ListText.IndexOf("\t", ListText.IndexOf("\t", ListText.IndexOf("\t", ListText.IndexOf("\t") + 1) + 1) + 1) + 1), "[\x20-\x7f]+\t([\x20-\x7f]+)\t[\x20-\x7f]+\t[\x20-\x7f]+\t", 0); foreach (Match item in regex.正则返回集合()) { Count += Convert.ToInt32(item.Groups[1].Value); } break; case 1: regex.创建(ListText.Substring( ListText.IndexOf("\t", ListText.IndexOf("\t") + 1) + 1), "[\x20-\x7f]+\t([\x20-\x7f]+)\t[\x20-\x7f]+\t", 0); foreach (Match item in regex.正则返回集合()) { Count += Convert.ToInt32(item.Groups[1].Value); } break; case 2: switch (FenZu) { case 3: regex.创建(ListText.Substring(ListText.IndexOf("\t") + 1), "[\x20-\x7f]+\t([\x20-\x7f]+)\t[\x20-\x7f]+\t", 0); break; case 5: regex.创建(ListText.Substring(ListText.IndexOf("\t") + 1), "[\x20-\x7f]+\t([\x20-\x7f]+)\t[\x20-\x7f]+\t[\x20-\x7f]+\t[\x20-\x7f]+\t", 0); break; } foreach (Match item in regex.正则返回集合()) { Count += Convert.ToInt32(item.Groups[1].Value); } break; case 3: regex.创建(ListText, "[\x20-\x7f]+\t([\x20-\x7f]+)\t[\x20-\x7f]+\t[\x20-\x7f]+\t", 0); foreach (Match item in regex.正则返回集合()) { Count += Convert.ToInt32(item.Groups[1].Value); } break; } return(Count); }