HongKongHelper.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. using Models;
  2. using System;
  3. using System.Collections.Generic;
  4. namespace Common
  5. {
  6. /// <summary>
  7. /// 香港彩帮助类
  8. /// </summary>
  9. public static class HongKongHelper
  10. {
  11. /// <summary>
  12. /// 获取香港彩开奖号特征
  13. /// </summary>
  14. /// <param name="opencode"></param>
  15. /// <returns></returns>
  16. public static List<HongKongLottery> GetHongKongLotteryAttr(List<string> opencode)
  17. {
  18. try
  19. {
  20. List<HongKongLottery> res = new List<HongKongLottery>();
  21. foreach (string codestring in opencode)
  22. {
  23. int code = Convert.ToInt32(codestring);
  24. //确定波色
  25. BoSeType boSeType = GetBoSeTypeByOpenCode(code);
  26. //确定生肖
  27. ShengXiaoType shengXiaoType = GetShengXiaoTypeByOpenCode(code);
  28. //确定五行
  29. WuXingType wuXingType = GetWuXingTypeByOpenCode(code);
  30. HongKongLottery lottery = new HongKongLottery
  31. {
  32. OpenCode = code,
  33. LotteryAttrItem = new LotteryAttrItem
  34. {
  35. BoSeType = boSeType,
  36. ShengXiao= EnumHelper.GetLotteryText(shengXiaoType),
  37. WuXing = EnumHelper.GetLotteryText(wuXingType)
  38. }
  39. };
  40. res.Add(lottery);
  41. }
  42. return res;
  43. }
  44. catch (Exception e)
  45. {
  46. return null;
  47. }
  48. }
  49. #region 常量值
  50. #region 外部使用
  51. /// <summary>
  52. /// 波色基础数据字典
  53. /// </summary>
  54. public static readonly Dictionary<BoSeType, List<int>> BoSeDict = new Dictionary<BoSeType, List<int>>
  55. {
  56. { BoSeType.Red, new List<int>{1,2,7,8,12,13,18,19,23,24,29,30,34,35,40,45,46}},
  57. { BoSeType.Blue,new List<int>{3,4,9,10,14,15,20,25,26,31,36,37,41,42,47,48}},
  58. { BoSeType.Green,new List<int>{5,6,11,16,17,21,22,27,28,32,33,38,39,43,44,49}}
  59. };
  60. /// <summary>
  61. /// 生肖基础数据字典,以2018年为基准。此数据由于每年都在变化,因此数据有变化时,请及时修改
  62. /// </summary>
  63. public static readonly Dictionary<ShengXiaoType, List<int>> ShengXiaoDict = new Dictionary<ShengXiaoType, List<int>>
  64. {
  65. { ShengXiaoType.Shu,new List<int>{11,23,35,47}},
  66. { ShengXiaoType.Niu,new List<int>{10,22,34,46}},
  67. { ShengXiaoType.Hu,new List<int>{9,21,33,45}},
  68. { ShengXiaoType.Tu,new List<int>{8,20,32,44}},
  69. { ShengXiaoType.Long,new List<int>{7,19,31,43}},
  70. { ShengXiaoType.She,new List<int>{6,18,30,42}},
  71. { ShengXiaoType.Ma,new List<int>{5,17,29,41}},
  72. { ShengXiaoType.Yang,new List<int>{4,16,28,40}},
  73. { ShengXiaoType.Hou,new List<int>{3,15,27,39}},
  74. { ShengXiaoType.Ji,new List<int>{2,14,26,38}},
  75. { ShengXiaoType.Gou,new List<int>{1,13,25,37,49}},
  76. { ShengXiaoType.Zhu,new List<int>{12,24,36,48}},
  77. };
  78. /// <summary>
  79. /// 五行基础数据字典
  80. /// </summary>
  81. public static readonly Dictionary<WuXingType, List<int>> WuXingDict = new Dictionary<WuXingType, List<int>>
  82. {
  83. { WuXingType.Jin,new List<int>{4,5,18,19,26,27,34,35,48,49}},
  84. { WuXingType.Mu,new List<int>{1,8,9,16,17,47,30,31,38,39,46}},
  85. { WuXingType.Shui,new List<int>{6,7,14,15,22,23,36,37,44,45}},
  86. { WuXingType.Huo,new List<int>{2,3,10,11,24,25,32,33,40,41}},
  87. { WuXingType.Tu,new List<int>{12,13,20,21,28,29,42,43}}
  88. };
  89. #endregion
  90. #region 内部使用
  91. /// <summary>
  92. /// 波色基础数据字典
  93. /// </summary>
  94. private static readonly Dictionary<List<int>, BoSeType> BoSeDictionary = new Dictionary<List<int>, BoSeType>
  95. {
  96. { new List<int>{1,2,7,8,12,13,18,19,23,24,29,30,34,35,40,45,46},BoSeType.Red},
  97. { new List<int>{3,4,9,10,14,15,20,25,26,31,36,37,41,42,47,48},BoSeType.Blue},
  98. { new List<int>{5,6,11,16,17,21,22,27,28,32,33,38,39,43,44,49},BoSeType.Green}
  99. };
  100. /// <summary>
  101. /// 生肖基础数据字典,以2018年为基准。此数据由于每年都在变化,因此数据有变化时,请及时修改
  102. /// </summary>
  103. private static readonly Dictionary<List<int>, ShengXiaoType> ShengXiaoDictionary = new Dictionary<List<int>, ShengXiaoType>
  104. {
  105. { new List<int>{1,13,25,37,49},ShengXiaoType.Gou},
  106. { new List<int>{12,24,36,48},ShengXiaoType.Zhu},
  107. { new List<int>{11,23,35,47},ShengXiaoType.Shu},
  108. { new List<int>{10,22,34,46},ShengXiaoType.Niu},
  109. { new List<int>{9,21,33,45},ShengXiaoType.Hu},
  110. { new List<int>{8,20,32,44},ShengXiaoType.Tu},
  111. { new List<int>{7,19,31,43},ShengXiaoType.Long},
  112. { new List<int>{6,18,30,42},ShengXiaoType.She},
  113. { new List<int>{5,17,29,41},ShengXiaoType.Ma},
  114. { new List<int>{4,16,28,40},ShengXiaoType.Yang},
  115. { new List<int>{3,15,27,39},ShengXiaoType.Hou},
  116. { new List<int>{2,14,26,38},ShengXiaoType.Ji}
  117. };
  118. /// <summary>
  119. /// 五行基础数据字典
  120. /// </summary>
  121. private static readonly Dictionary<List<int>, WuXingType> WuXingDictionary = new Dictionary<List<int>, WuXingType>
  122. {
  123. { new List<int>{4,5,18,19,26,27,34,35,48,49},WuXingType.Jin},
  124. { new List<int>{1,8,9,16,17,47,30,31,38,39,46},WuXingType.Mu},
  125. { new List<int>{6,7,14,15,22,23,36,37,44,45},WuXingType.Shui},
  126. { new List<int>{2,3,10,11,24,25,32,33,40,41},WuXingType.Huo},
  127. { new List<int>{12,13,20,21,28,29,42,43},WuXingType.Tu}
  128. };
  129. #endregion 常量值
  130. #endregion
  131. #region 枚举
  132. /// <summary>
  133. /// 波色类型
  134. /// </summary>
  135. public enum BoSeType
  136. {
  137. /// <summary>
  138. /// 红波
  139. /// </summary>
  140. Red = 0,
  141. /// <summary>
  142. /// 蓝波
  143. /// </summary>
  144. Blue,
  145. /// <summary>
  146. /// 绿波
  147. /// </summary>
  148. Green
  149. }
  150. /// <summary>
  151. /// 生肖类型
  152. /// </summary>
  153. public enum ShengXiaoType
  154. {
  155. /// <summary>
  156. /// 鼠
  157. /// </summary>
  158. [Text("鼠")]
  159. Shu = 0,
  160. /// <summary>
  161. /// 牛
  162. /// </summary>
  163. [Text("牛")]
  164. Niu,
  165. /// <summary>
  166. /// 虎
  167. /// </summary>
  168. [Text("虎")]
  169. Hu,
  170. /// <summary>
  171. /// 兔
  172. /// </summary>
  173. [Text("兔")]
  174. Tu,
  175. /// <summary>
  176. /// 龙
  177. /// </summary>
  178. [Text("龙")]
  179. Long,
  180. /// <summary>
  181. /// 蛇
  182. /// </summary>
  183. [Text("蛇")]
  184. She,
  185. /// <summary>
  186. /// 马
  187. /// </summary>
  188. [Text("马")]
  189. Ma,
  190. /// <summary>
  191. /// 羊
  192. /// </summary>
  193. [Text("羊")]
  194. Yang,
  195. /// <summary>
  196. /// 猴
  197. /// </summary>
  198. [Text("猴")]
  199. Hou,
  200. /// <summary>
  201. /// 鸡
  202. /// </summary>
  203. [Text("鸡")]
  204. Ji,
  205. /// <summary>
  206. /// 狗
  207. /// </summary>
  208. [Text("狗")]
  209. Gou,
  210. /// <summary>
  211. /// 猪
  212. /// </summary>
  213. [Text("猪")]
  214. Zhu
  215. }
  216. /// <summary>
  217. /// 五行类型
  218. /// </summary>
  219. public enum WuXingType
  220. {
  221. /// <summary>
  222. /// 金
  223. /// </summary>
  224. [Text("金")]
  225. Jin = 0,
  226. /// <summary>
  227. /// 木
  228. /// </summary>
  229. [Text("木")]
  230. Mu,
  231. /// <summary>
  232. /// 水
  233. /// </summary>
  234. [Text("水")]
  235. Shui,
  236. /// <summary>
  237. /// 火
  238. /// </summary>
  239. [Text("火")]
  240. Huo,
  241. /// <summary>
  242. /// 土
  243. /// </summary>
  244. [Text("土")]
  245. Tu
  246. }
  247. #endregion 枚举
  248. #region 私有方法
  249. /// <summary>
  250. /// 获取某个开奖号的波色
  251. /// </summary>
  252. /// <param name="opencode"></param>
  253. /// <returns></returns>
  254. private static BoSeType GetBoSeTypeByOpenCode(int opencode)
  255. {
  256. if (opencode < 0) return BoSeType.Red;
  257. foreach (KeyValuePair<List<int>, BoSeType> pair in BoSeDictionary)
  258. {
  259. List<int> dictCodes = pair.Key;
  260. if (dictCodes.Contains(opencode))
  261. {
  262. return pair.Value;
  263. }
  264. }
  265. return BoSeType.Red;
  266. }
  267. /// <summary>
  268. /// 获取某个开奖号的生肖
  269. /// </summary>
  270. /// <param name="opencode"></param>
  271. /// <returns></returns>
  272. private static ShengXiaoType GetShengXiaoTypeByOpenCode(int opencode)
  273. {
  274. if (opencode < 0) return ShengXiaoType.Shu;
  275. foreach (KeyValuePair<List<int>, ShengXiaoType> pair in ShengXiaoDictionary)
  276. {
  277. List<int> dictCodes = pair.Key;
  278. if (dictCodes.Contains(opencode))
  279. {
  280. return pair.Value;
  281. }
  282. }
  283. return ShengXiaoType.Shu;
  284. }
  285. /// <summary>
  286. /// 获取某个开奖号的五行
  287. /// </summary>
  288. /// <param name="opencode"></param>
  289. /// <returns></returns>
  290. private static WuXingType GetWuXingTypeByOpenCode(int opencode)
  291. {
  292. if (opencode < 0) return WuXingType.Jin;
  293. foreach (KeyValuePair<List<int>, WuXingType> pair in WuXingDictionary)
  294. {
  295. List<int> dictCodes = pair.Key;
  296. if (dictCodes.Contains(opencode))
  297. {
  298. return pair.Value;
  299. }
  300. }
  301. return WuXingType.Jin;
  302. }
  303. #endregion
  304. #region 实体
  305. /// <summary>
  306. /// 香港彩开奖号特性
  307. /// </summary>
  308. public class HongKongLottery
  309. {
  310. public int OpenCode { get; set; }
  311. public LotteryAttrItem LotteryAttrItem { get; set; }
  312. }
  313. public class LotteryAttrItem
  314. {
  315. /// <summary>
  316. /// 波色
  317. /// </summary>
  318. public BoSeType BoSeType { get; set; }
  319. /// <summary>
  320. /// 生肖
  321. /// </summary>
  322. public string ShengXiao { get; set; }
  323. /// <summary>
  324. /// 五行
  325. /// </summary>
  326. public string WuXing { get; set; }
  327. }
  328. #endregion
  329. }
  330. }