/// <summary> /// 检查投注号码格式是否正确 /// </summary> /// <param name="antecode">投注号码</param> /// <param name="errMsg">错误消息</param> /// <returns>格式是否正确</returns> public bool CheckAntecode(string antecode, out string errMsg) { // 前置验证 - 彩种、玩法、投注号码 PreconditionAssert.IsNotEmptyString(GameCode, "检查投注号码格式前,必须设置彩种"); PreconditionAssert.IsNotEmptyString(GameType, "检查投注号码格式前,必须设置玩法"); PreconditionAssert.IsNotEmptyString(antecode, "必须传入非空的投注号码"); AnteCodeNumbers = antecode.Split(Spliter); if (AnteCodeNumbers.Length < BallNumber || AnteCodeNumbers.Length > AllNumber) { errMsg = string.Format("投注号码必须是由\"{0}\"连接的 {1} - {2}个数字组成", Spliter, BallNumber, AllNumber); return(false); } var orderAnalyzer = AnalyzerFactory.GetOrderAnalyzer(GameCode, GameType); // 检查每一个号码 if (!orderAnalyzer.CheckComboAntecodeNumber(antecode, Spliter, out errMsg)) { return(false); } var groupCount = AnteCodeNumbers.GroupBy(a => a).Count(); if (groupCount != AnteCodeNumbers.Length) { errMsg = string.Format("投注号码有重复数字出现:{0}", antecode); return(false); } errMsg = ""; return(true); }
/// <summary> /// 检查投注号码格式是否正确 /// </summary> /// <param name="antecode">投注号码</param> /// <param name="errMsg">错误消息</param> /// <returns>格式是否正确</returns> public bool CheckAntecode(string antecode, out string errMsg) { // 前置验证 - 彩种、玩法、投注号码 PreconditionAssert.IsNotEmptyString(GameCode, "检查投注号码格式前,必须设置彩种"); PreconditionAssert.IsNotEmptyString(GameType, "检查投注号码格式前,必须设置玩法"); PreconditionAssert.IsNotEmptyString(antecode, "必须传入非空的投注号码"); AnteCodeNumbers = antecode.Split(Spliter); if (AnteCodeNumbers.Length != BallNumber) { errMsg = string.Format("投注号码必须是被\"{0}\"切分成 {1}个部分的字符串", Spliter, BallNumber); return(false); } var orderAnalyzer = AnalyzerFactory.GetOrderAnalyzer(GameCode, GameType); for (var i = 0; i < BallNumber; i++) { // 检查每一个号码 if (!orderAnalyzer.CheckComboAntecodeNumber(AnteCodeNumbers[i], null, out errMsg)) { return(false); } } errMsg = ""; return(true); }
/// <summary> /// 检查投注号码格式是否正确 /// </summary> /// <param name="antecode">投注号码</param> /// <param name="errMsg">错误消息</param> /// <returns>格式是否正确</returns> public bool CheckAntecode(string antecode, out string errMsg) { // 前置验证 - 彩种、玩法、投注号码 PreconditionAssert.IsNotEmptyString(GameCode, "检查投注号码格式前,必须设置彩种"); PreconditionAssert.IsNotEmptyString(GameType, "检查投注号码格式前,必须设置玩法"); PreconditionAssert.IsNotEmptyString(antecode, "必须传入非空的投注号码"); AnteCodeNumbers = antecode.Split(Spliter); if (AnteCodeNumbers.Length != BallNumber) { errMsg = string.Format("投注号码必须是被\"{0}\"切分成 {1}个部分的字符串", Spliter, TotalNumber); return(false); } var orderAnalyzer = AnalyzerFactory.GetOrderAnalyzer(GameCode, GameType); for (var i = 0; i < BallNumber; i++) { // 检查每一个号码 if (!orderAnalyzer.CheckOneAntecodeNumber(AnteCodeNumbers[i], out errMsg)) { return(false); } } var groupCount = AnteCodeNumbers.GroupBy(a => a).Count(); if (groupCount == 1) { errMsg = string.Format("投注号码不能是三个数字都相同的豹子:", antecode); return(false); } else if (groupCount == 3) { errMsg = string.Format("投注号码不能是三个数字都不相同的组六:", antecode); return(false); } else if (groupCount == 2) { errMsg = ""; return(true); } else { errMsg = string.Format("分析投注号码未知错误:", antecode); return(false); } }
/// <summary> /// 检查投注号码格式是否正确 /// </summary> /// <param name="antecode">投注号码</param> /// <param name="errMsg">错误消息</param> /// <returns>格式是否正确</returns> public bool CheckAntecode(string antecode, out string errMsg) { // 前置验证 - 彩种、玩法、投注号码 PreconditionAssert.IsNotEmptyString(GameCode, "检查投注号码格式前,必须设置彩种"); PreconditionAssert.IsNotEmptyString(GameType, "检查投注号码格式前,必须设置玩法"); PreconditionAssert.IsNotEmptyString(antecode, "必须传入非空的投注号码"); AnteCodeNumbers = antecode.Split(Spliter); if (AnteCodeNumbers.Length != TotalNumber) { errMsg = string.Format("投注号码必须是被\"{0}\"切分成 {1}个部分的字符串", Spliter, TotalNumber); return(false); } var orderAnalyzer = AnalyzerFactory.GetOrderAnalyzer(GameCode, GameType); var i = 0; for (; i < TotalNumber - BallNumber; i++) { // 检查空位占位符 if (!orderAnalyzer.CheckSpaceNumber(AnteCodeNumbers[i], out errMsg)) { return(false); } } for (; i < TotalNumber; i++) { // 检查每一个号码 if (!orderAnalyzer.CheckComboAntecodeNumber(AnteCodeNumbers[i], null, out errMsg)) { return(false); } // 分组,以去除号码中的重复项 var group = AnteCodeNumbers[i].GroupBy(c => c); if (group.Count() != AnteCodeNumbers[i].Length) { errMsg = "号码中有重复的数字 - " + antecode; return(false); } } errMsg = ""; return(true); }
/// <summary> /// 检查投注号码格式是否正确 /// </summary> /// <param name="antecode">投注号码</param> /// <param name="errMsg">错误消息</param> /// <returns>格式是否正确</returns> public bool CheckAntecode(string antecode, out string errMsg) { // 前置验证 - 彩种、玩法、投注号码 PreconditionAssert.IsNotEmptyString(GameCode, "检查投注号码格式前,必须设置彩种"); PreconditionAssert.IsNotEmptyString(GameType, "检查投注号码格式前,必须设置玩法"); PreconditionAssert.IsNotEmptyString(antecode, "必须传入非空的投注号码"); AnteCodeNumbers = antecode.Split(Spliter); if (MinCount == -1 && MaxCount == -1) { if (AnteCodeNumbers.Length < BallNumber) { errMsg = string.Format("投注号码必须至少包含 {0}个数字", BallNumber); return(false); } } else { if (AnteCodeNumbers.Length < MinCount || AnteCodeNumbers.Length > MaxCount) { if (MinCount == MaxCount) { errMsg = string.Format("投注号码必须包含 {0}个数字", MinCount); } else { errMsg = string.Format("投注号码必须至少包含 {0} - {1}个数字", MinCount, MaxCount); } return(false); } } var orderAnalyzer = AnalyzerFactory.GetOrderAnalyzer(GameCode, GameType); if (!orderAnalyzer.CheckComboAntecodeNumber(antecode, ',', out errMsg)) { return(false); } errMsg = ""; return(true); }
/// <summary> /// 检查投注号码格式是否正确 /// </summary> /// <param name="antecode">投注号码</param> /// <param name="errMsg">错误消息</param> /// <returns>格式是否正确</returns> public bool CheckAntecode(string antecode, out string errMsg) { // 前置验证 - 彩种、玩法、投注号码 PreconditionAssert.IsNotEmptyString(GameCode, "检查投注号码格式前,必须设置彩种"); PreconditionAssert.IsNotEmptyString(GameType, "检查投注号码格式前,必须设置玩法"); PreconditionAssert.IsNotEmptyString(antecode, "必须传入非空的投注号码"); AnteCodeNumbers = antecode.Split(Spliter); if (AnteCodeNumbers.Length != TotalNumber) { errMsg = string.Format("投注号码必须是被\"{0}\"切分成 {1}个部分的字符串", Spliter, TotalNumber); return(false); } var orderAnalyzer = AnalyzerFactory.GetOrderAnalyzer(GameCode, GameType); int c = 0; foreach (string code in AnteCodeNumbers) { if (code == "-") { c++; } else { if (!orderAnalyzer.CheckOneAntecodeNumber(code, out errMsg)) { throw new AntecodeFormatException(GameCode, GameType, antecode, errMsg); } } } if (c + BallNumber != TotalNumber) { throw new AntecodeFormatException(GameCode, GameType, antecode, "号码格式错误 - " + antecode); } errMsg = ""; return(true); }
/// <summary> /// 检查投注号码格式是否正确 /// </summary> /// <param name="antecode">投注号码</param> /// <param name="errMsg">错误消息</param> /// <returns>格式是否正确</returns> public bool CheckAntecode(string antecode, out string errMsg) { // 前置验证 - 彩种、玩法、投注号码 PreconditionAssert.IsNotEmptyString(GameCode, "检查投注号码格式前,必须设置彩种"); PreconditionAssert.IsNotEmptyString(GameType, "检查投注号码格式前,必须设置玩法"); PreconditionAssert.IsNotEmptyString(antecode, "必须传入非空的投注号码"); AnteCodeNumbers = antecode.Split(Spliter); if (AnteCodeNumbers.Length < BallNumber) { errMsg = string.Format("投注号码必须至少包含 {0}个数字", BallNumber); return(false); } if (MaxBallNumber != 0 && AnteCodeNumbers.Length > MaxBallNumber) { errMsg = string.Format("投注号码必须最多包含 {0}个数字", MaxBallNumber); return(false); } var orderAnalyzer = AnalyzerFactory.GetOrderAnalyzer(GameCode, GameType); if (!orderAnalyzer.CheckComboAntecodeNumber(antecode, ',', out errMsg)) { return(false); } foreach (var item in AnteCodeNumbers) { var num = int.Parse(item); if (num < MinNumber || num > MaxNumber) { errMsg = string.Format("号码必须是 {0,2:D2} - {1,2:D2} 之间的数字", MinNumber, MaxNumber); return(false); } } errMsg = ""; return(true); }
/// <summary> /// 检查投注号码格式是否正确 /// </summary> /// <param name="antecode">投注号码</param> /// <param name="errMsg">错误消息</param> /// <returns>格式是否正确</returns> public bool CheckAntecode(string antecode, out string errMsg) { // 前置验证 - 彩种、玩法、投注号码 PreconditionAssert.IsNotEmptyString(GameCode, "检查投注号码格式前,必须设置彩种"); PreconditionAssert.IsNotEmptyString(GameType, "检查投注号码格式前,必须设置玩法"); PreconditionAssert.IsNotEmptyString(antecode, "必须传入非空的投注号码"); var list = antecode.Split('|'); if (list.Length > 1) { var dans = list[1].Split(new char[] { Spliter }, StringSplitOptions.RemoveEmptyEntries); DanNumbers = new int[dans.Length]; for (int i = 0; i < dans.Length; i++) { DanNumbers[i] = int.Parse(dans[i]); } if (DanNumbers.GroupBy(i => i).Count() != DanNumbers.Length) { errMsg = "胆码重复"; return(false); } } else { DanNumbers = new int[0]; } AnteCodeNumbers = list[0].Split(Spliter); if (AnteCodeNumbers.Length != TotalNumber) { errMsg = string.Format("投注号码必须是被\"{0}\"切分成 {1}个部分的字符串", Spliter, TotalNumber); return(false); } var orderAnalyzer = AnalyzerFactory.GetOrderAnalyzer(GameCode, GameType); var tmp = AnteCodeNumbers.Clone() as string[]; if (IsEnableWildcard) { tmp = AnteCodeNumbers.Where(a => { return(!a.Equals(Wildcard.ToString())); }).ToArray(); if (tmp.Length < BallNumber || tmp.Length > TotalNumber) { errMsg = string.Format("有效投注号码必须是\"{0} - {1}\"个号码", BallNumber, TotalNumber); return(false); } } if (tmp.Length == BallNumber && DanNumbers.Length > 0) { errMsg = "胆码设置错误 - " + antecode; return(false); } if (DanNumbers.Length >= BallNumber) { errMsg = "胆码设置错误,胆码必须小于 " + BallNumber + "个 - " + antecode; return(false); } foreach (var danIndex in DanNumbers) { var dan = AnteCodeNumbers[danIndex]; if (dan == Wildcard.ToString()) { errMsg = "胆码设置错误,对应胆码为通配符 - " + antecode; return(false); } } foreach (var item in tmp) { if (!orderAnalyzer.CheckOneAntecodeNumber(item, out errMsg)) { return(false); } } errMsg = ""; return(true); }
/// <summary> /// 检查投注号码格式是否正确 /// </summary> /// <param name="antecode">投注号码</param> /// <param name="errMsg">错误消息</param> /// <returns>格式是否正确</returns> public bool CheckAntecode(string antecode, out string errMsg) { // 前置验证 - 彩种、玩法、投注号码 PreconditionAssert.IsNotEmptyString(GameCode, "检查投注号码格式前,必须设置彩种"); PreconditionAssert.IsNotEmptyString(GameType, "检查投注号码格式前,必须设置玩法"); PreconditionAssert.IsNotEmptyString(antecode, "必须传入非空的投注号码"); AnteCodeNumbers = antecode.Split(Spliter_Level1); if (NeedLastDan) { if (AnteCodeNumbers.Length != 4) { errMsg = string.Format("投注号码必须是被\"{0}\"切分成 4个部分的字符串", Spliter_Level1); return(false); } } else { if (AnteCodeNumbers.Length != 3) { errMsg = string.Format("投注号码必须是被\"{0}\"切分成 3个部分的字符串", Spliter_Level1); return(false); } } var orderAnalyzer = AnalyzerFactory.GetOrderAnalyzer(GameCode, GameType); var arr_first_dan = AnteCodeNumbers[0].Split(new char[] { Spliter_Level2 }, StringSplitOptions.RemoveEmptyEntries); var arr_first_tuo = AnteCodeNumbers[1].Split(new char[] { Spliter_Level2 }, StringSplitOptions.RemoveEmptyEntries); string[] arr_last_dan, arr_last_tuo; if (NeedLastDan) { arr_last_dan = AnteCodeNumbers[2].Split(new char[] { Spliter_Level2 }, StringSplitOptions.RemoveEmptyEntries); arr_last_tuo = AnteCodeNumbers[3].Split(new char[] { Spliter_Level2 }, StringSplitOptions.RemoveEmptyEntries); } else { arr_last_dan = new string[0]; arr_last_tuo = AnteCodeNumbers[2].Split(Spliter_Level2); } if (arr_first_dan.Length < MinTotalNumber_First_Dan || arr_first_dan.Length > MaxTotalNumber_First_Dan) { if (MinTotalNumber_First_Dan == MaxTotalNumber_First_Dan) { errMsg = string.Format("前区胆码必须是\"{0}\"分隔的 {1}个号码", Spliter_Level2, MinTotalNumber_First_Dan); } else { errMsg = string.Format("前区胆码必须是\"{0}\"分隔的 {1} - {2}个号码", Spliter_Level2, MinTotalNumber_First_Dan, MaxTotalNumber_First_Dan); } return(false); } if (arr_first_tuo.Length < MinTotalNumber_First_Tuo || arr_first_tuo.Length > MaxTotalNumber_First_Tuo) { if (MinTotalNumber_First_Tuo == MaxTotalNumber_First_Tuo) { errMsg = string.Format("前区拖码必须是\"{0}\"分隔的 {1}个号码", Spliter_Level2, MinTotalNumber_First_Dan); } else { errMsg = string.Format("前区拖码必须是\"{0}\"分隔的 {1} - {2}个号码", Spliter_Level2, MinTotalNumber_First_Dan, MaxTotalNumber_First_Dan); } return(false); } if (NeedLastDan) { if (arr_last_dan.Length < MinTotalNumber_Last_Dan || arr_last_dan.Length > MaxTotalNumber_Last_Dan) { if (MinTotalNumber_Last_Dan == MaxTotalNumber_Last_Dan) { errMsg = string.Format("后区拖码必须是\"{0}\"分隔的 {1}个号码", Spliter_Level2, MinTotalNumber_Last_Dan); } else { errMsg = string.Format("后区拖码必须是\"{0}\"分隔的 {1} - {2}个号码", Spliter_Level2, MinTotalNumber_Last_Dan, MaxTotalNumber_Last_Dan); } return(false); } } if (arr_last_tuo.Length < MinTotalNumber_Last_Tuo || arr_last_tuo.Length > MaxTotalNumber_Last_Tuo) { if (MinTotalNumber_Last_Tuo == MaxTotalNumber_Last_Tuo) { errMsg = string.Format("后区号码必须是\"{0}\"分隔的 {1}个号码", Spliter_Level2, MinTotalNumber_Last_Tuo); } else { errMsg = string.Format("后区号码必须是\"{0}\"分隔的 {1} - {2}个号码", Spliter_Level2, MinTotalNumber_Last_Tuo, MaxTotalNumber_Last_Tuo); } return(false); } foreach (var item in arr_first_dan) { if (!orderAnalyzer.CheckOneAntecodeNumber(item, out errMsg, "F")) { return(false); } } foreach (var item in arr_first_tuo) { if (!orderAnalyzer.CheckOneAntecodeNumber(item, out errMsg, "F")) { return(false); } } foreach (var item in arr_last_dan) { if (!orderAnalyzer.CheckOneAntecodeNumber(item, out errMsg, "L")) { return(false); } } foreach (var item in arr_last_tuo) { if (!orderAnalyzer.CheckOneAntecodeNumber(item, out errMsg, "L")) { return(false); } } // 分组,以去除号码中的重复项 var arr_first = arr_first_dan.Union(arr_first_tuo); if (arr_first.Count() != arr_first_dan.Length + arr_first_tuo.Length) { errMsg = "前区胆码与拖码有重复的数字 - " + antecode; return(false); } if (arr_first.Count() < MinLength_First) { errMsg = "前区胆码与拖码个数必须大于 - " + (MinLength_First - 1); return(false); } if (arr_first.Count() > MaxLength_First) { errMsg = "前区胆码与拖码个数必须小于 - " + (MaxLength_First + 1); return(false); } var group_first = arr_first.GroupBy(c => c); if (group_first.Count() != arr_first.Count()) { errMsg = "前区号码中有重复的数字 - " + antecode; return(false); } // 分组,以去除号码中的重复项 var arr_last = arr_last_dan.Union(arr_last_tuo); if (arr_last.Count() != arr_last_dan.Length + arr_last_tuo.Length) { errMsg = "前区胆码与拖码有重复的数字 - " + antecode; return(false); } if (arr_last.Count() < MinLength_Last) { errMsg = "后区胆码与拖码个数必须大于 - " + (MinLength_Last - 1); return(false); } if (arr_last.Count() > MaxLength_Last) { errMsg = "后区胆码与拖码个数必须小于 - " + (MaxLength_Last + 1); return(false); } var group_last = arr_last.GroupBy(c => c); if (group_last.Count() != arr_last.Count()) { errMsg = "后区号码中有重复的数字 - " + antecode; return(false); } errMsg = ""; return(true); }
/// <summary> /// 检查投注号码格式是否正确 /// </summary> /// <param name="antecode">投注号码</param> /// <param name="errMsg">错误消息</param> /// <returns>格式是否正确</returns> public bool CheckAntecode(string antecode, out string errMsg) { // 前置验证 - 彩种、玩法、投注号码 PreconditionAssert.IsNotEmptyString(GameCode, "检查投注号码格式前,必须设置彩种"); PreconditionAssert.IsNotEmptyString(GameType, "检查投注号码格式前,必须设置玩法"); PreconditionAssert.IsNotEmptyString(antecode, "必须传入非空的投注号码"); AnteCodeNumbers = antecode.Split(Spliter_Level1); if (AnteCodeNumbers.Length != 2) { errMsg = string.Format("投注号码必须是被\"{0}\"切分成 2个部分的字符串", Spliter_Level1); return(false); } var orderAnalyzer = AnalyzerFactory.GetOrderAnalyzer(GameCode, GameType); var arr_first = AnteCodeNumbers[0].Split(Spliter_Level2); var arr_last = AnteCodeNumbers[1].Split(Spliter_Level2); if (arr_first.Length < MinTotalNumber_First || arr_first.Length > MaxTotalNumber_First) { if (MinTotalNumber_First == MaxTotalNumber_First) { errMsg = string.Format("前区号码必须是\"{0}\"分隔的 {1}个号码", Spliter_Level2, MinTotalNumber_First); } else { errMsg = string.Format("前区号码必须是\"{0}\"分隔的 {1} - {2}个号码", Spliter_Level2, MinTotalNumber_First, MaxTotalNumber_First); } return(false); } if (arr_last.Length < MinTotalNumber_Last || arr_last.Length > MaxTotalNumber_Last) { if (MinTotalNumber_Last == MaxTotalNumber_Last) { errMsg = string.Format("后区号码必须是\"{0}\"分隔的 {1}个号码", Spliter_Level2, MinTotalNumber_Last); } else { errMsg = string.Format("后区号码必须是\"{0}\"分隔的 {1} - {2}个号码", Spliter_Level2, MinTotalNumber_Last, MaxTotalNumber_Last); } return(false); } if (arr_first.Length + arr_last.Length < MinBallTotalLenght || arr_first.Length + arr_last.Length > MaxBallTotalLenght) { if (MinBallTotalLenght == MaxBallTotalLenght) { errMsg = string.Format("号码总长度必须是 {0}个号码", MinBallTotalLenght); } else { errMsg = string.Format("号码总长度必须是 {0} - {1}个号码", MinBallTotalLenght, MaxBallTotalLenght); } return(false); } foreach (var item in arr_first) { // 检查空位占位符 if (!orderAnalyzer.CheckOneAntecodeNumber(item, out errMsg, "F")) { return(false); } } foreach (var item in arr_last) { // 检查空位占位符 if (!orderAnalyzer.CheckOneAntecodeNumber(item, out errMsg, "L")) { return(false); } } // 分组,以去除号码中的重复项 var group_first = arr_first.GroupBy(c => c); if (group_first.Count() != arr_first.Length) { errMsg = "前区号码中有重复的数字 - " + antecode; return(false); } // 分组,以去除号码中的重复项 var group_last = arr_last.GroupBy(c => c); if (group_last.Count() != arr_last.Length) { errMsg = "后区号码中有重复的数字 - " + antecode; return(false); } errMsg = ""; return(true); }