123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376 |
- using Models;
- using System;
- using System.Collections.Generic;
- namespace Common
- {
- /// <summary>
- /// 香港彩帮助类
- /// </summary>
- public static class HongKongHelper
- {
- /// <summary>
- /// 获取香港彩开奖号特征
- /// </summary>
- /// <param name="opencode"></param>
- /// <returns></returns>
- public static List<HongKongLottery> GetHongKongLotteryAttr(List<string> opencode)
- {
- try
- {
- List<HongKongLottery> res = new List<HongKongLottery>();
- foreach (string codestring in opencode)
- {
- int code = Convert.ToInt32(codestring);
- //确定波色
- BoSeType boSeType = GetBoSeTypeByOpenCode(code);
- //确定生肖
- ShengXiaoType shengXiaoType = GetShengXiaoTypeByOpenCode(code);
- //确定五行
- WuXingType wuXingType = GetWuXingTypeByOpenCode(code);
- HongKongLottery lottery = new HongKongLottery
- {
- OpenCode = code,
- LotteryAttrItem = new LotteryAttrItem
- {
- BoSeType = boSeType,
- ShengXiao= EnumHelper.GetLotteryText(shengXiaoType),
- WuXing = EnumHelper.GetLotteryText(wuXingType)
- }
- };
- res.Add(lottery);
- }
- return res;
- }
- catch (Exception e)
- {
- return null;
- }
-
- }
- #region 常量值
- #region 外部使用
- /// <summary>
- /// 波色基础数据字典
- /// </summary>
- public static readonly Dictionary<BoSeType, List<int>> BoSeDict = new Dictionary<BoSeType, List<int>>
- {
- { BoSeType.Red, new List<int>{1,2,7,8,12,13,18,19,23,24,29,30,34,35,40,45,46}},
- { BoSeType.Blue,new List<int>{3,4,9,10,14,15,20,25,26,31,36,37,41,42,47,48}},
- { BoSeType.Green,new List<int>{5,6,11,16,17,21,22,27,28,32,33,38,39,43,44,49}}
- };
- /// <summary>
- /// 生肖基础数据字典,以2018年为基准。此数据由于每年都在变化,因此数据有变化时,请及时修改
- /// </summary>
- public static readonly Dictionary<ShengXiaoType, List<int>> ShengXiaoDict = new Dictionary<ShengXiaoType, List<int>>
- {
- { ShengXiaoType.Shu,new List<int>{11,23,35,47}},
- { ShengXiaoType.Niu,new List<int>{10,22,34,46}},
- { ShengXiaoType.Hu,new List<int>{9,21,33,45}},
- { ShengXiaoType.Tu,new List<int>{8,20,32,44}},
- { ShengXiaoType.Long,new List<int>{7,19,31,43}},
- { ShengXiaoType.She,new List<int>{6,18,30,42}},
- { ShengXiaoType.Ma,new List<int>{5,17,29,41}},
- { ShengXiaoType.Yang,new List<int>{4,16,28,40}},
- { ShengXiaoType.Hou,new List<int>{3,15,27,39}},
- { ShengXiaoType.Ji,new List<int>{2,14,26,38}},
- { ShengXiaoType.Gou,new List<int>{1,13,25,37,49}},
- { ShengXiaoType.Zhu,new List<int>{12,24,36,48}},
- };
- /// <summary>
- /// 五行基础数据字典
- /// </summary>
- public static readonly Dictionary<WuXingType, List<int>> WuXingDict = new Dictionary<WuXingType, List<int>>
- {
- { WuXingType.Jin,new List<int>{4,5,18,19,26,27,34,35,48,49}},
- { WuXingType.Mu,new List<int>{1,8,9,16,17,47,30,31,38,39,46}},
- { WuXingType.Shui,new List<int>{6,7,14,15,22,23,36,37,44,45}},
- { WuXingType.Huo,new List<int>{2,3,10,11,24,25,32,33,40,41}},
- { WuXingType.Tu,new List<int>{12,13,20,21,28,29,42,43}}
- };
- #endregion
- #region 内部使用
- /// <summary>
- /// 波色基础数据字典
- /// </summary>
- private static readonly Dictionary<List<int>, BoSeType> BoSeDictionary = new Dictionary<List<int>, BoSeType>
- {
- { new List<int>{1,2,7,8,12,13,18,19,23,24,29,30,34,35,40,45,46},BoSeType.Red},
- { new List<int>{3,4,9,10,14,15,20,25,26,31,36,37,41,42,47,48},BoSeType.Blue},
- { new List<int>{5,6,11,16,17,21,22,27,28,32,33,38,39,43,44,49},BoSeType.Green}
- };
- /// <summary>
- /// 生肖基础数据字典,以2018年为基准。此数据由于每年都在变化,因此数据有变化时,请及时修改
- /// </summary>
- private static readonly Dictionary<List<int>, ShengXiaoType> ShengXiaoDictionary = new Dictionary<List<int>, ShengXiaoType>
- {
- { new List<int>{1,13,25,37,49},ShengXiaoType.Gou},
- { new List<int>{12,24,36,48},ShengXiaoType.Zhu},
- { new List<int>{11,23,35,47},ShengXiaoType.Shu},
- { new List<int>{10,22,34,46},ShengXiaoType.Niu},
- { new List<int>{9,21,33,45},ShengXiaoType.Hu},
- { new List<int>{8,20,32,44},ShengXiaoType.Tu},
- { new List<int>{7,19,31,43},ShengXiaoType.Long},
- { new List<int>{6,18,30,42},ShengXiaoType.She},
- { new List<int>{5,17,29,41},ShengXiaoType.Ma},
- { new List<int>{4,16,28,40},ShengXiaoType.Yang},
- { new List<int>{3,15,27,39},ShengXiaoType.Hou},
- { new List<int>{2,14,26,38},ShengXiaoType.Ji}
- };
- /// <summary>
- /// 五行基础数据字典
- /// </summary>
- private static readonly Dictionary<List<int>, WuXingType> WuXingDictionary = new Dictionary<List<int>, WuXingType>
- {
- { new List<int>{4,5,18,19,26,27,34,35,48,49},WuXingType.Jin},
- { new List<int>{1,8,9,16,17,47,30,31,38,39,46},WuXingType.Mu},
- { new List<int>{6,7,14,15,22,23,36,37,44,45},WuXingType.Shui},
- { new List<int>{2,3,10,11,24,25,32,33,40,41},WuXingType.Huo},
- { new List<int>{12,13,20,21,28,29,42,43},WuXingType.Tu}
- };
- #endregion 常量值
- #endregion
- #region 枚举
- /// <summary>
- /// 波色类型
- /// </summary>
- public enum BoSeType
- {
- /// <summary>
- /// 红波
- /// </summary>
- Red = 0,
- /// <summary>
- /// 蓝波
- /// </summary>
- Blue,
- /// <summary>
- /// 绿波
- /// </summary>
- Green
- }
- /// <summary>
- /// 生肖类型
- /// </summary>
- public enum ShengXiaoType
- {
- /// <summary>
- /// 鼠
- /// </summary>
- [Text("鼠")]
- Shu = 0,
- /// <summary>
- /// 牛
- /// </summary>
- [Text("牛")]
- Niu,
- /// <summary>
- /// 虎
- /// </summary>
- [Text("虎")]
- Hu,
- /// <summary>
- /// 兔
- /// </summary>
- [Text("兔")]
- Tu,
- /// <summary>
- /// 龙
- /// </summary>
- [Text("龙")]
- Long,
- /// <summary>
- /// 蛇
- /// </summary>
- [Text("蛇")]
- She,
- /// <summary>
- /// 马
- /// </summary>
- [Text("马")]
- Ma,
- /// <summary>
- /// 羊
- /// </summary>
- [Text("羊")]
- Yang,
- /// <summary>
- /// 猴
- /// </summary>
- [Text("猴")]
- Hou,
- /// <summary>
- /// 鸡
- /// </summary>
- [Text("鸡")]
- Ji,
- /// <summary>
- /// 狗
- /// </summary>
- [Text("狗")]
- Gou,
- /// <summary>
- /// 猪
- /// </summary>
- [Text("猪")]
- Zhu
- }
- /// <summary>
- /// 五行类型
- /// </summary>
- public enum WuXingType
- {
- /// <summary>
- /// 金
- /// </summary>
- [Text("金")]
- Jin = 0,
- /// <summary>
- /// 木
- /// </summary>
- [Text("木")]
- Mu,
- /// <summary>
- /// 水
- /// </summary>
- [Text("水")]
- Shui,
- /// <summary>
- /// 火
- /// </summary>
- [Text("火")]
- Huo,
- /// <summary>
- /// 土
- /// </summary>
- [Text("土")]
- Tu
- }
- #endregion 枚举
- #region 私有方法
- /// <summary>
- /// 获取某个开奖号的波色
- /// </summary>
- /// <param name="opencode"></param>
- /// <returns></returns>
- private static BoSeType GetBoSeTypeByOpenCode(int opencode)
- {
- if (opencode < 0) return BoSeType.Red;
- foreach (KeyValuePair<List<int>, BoSeType> pair in BoSeDictionary)
- {
- List<int> dictCodes = pair.Key;
- if (dictCodes.Contains(opencode))
- {
- return pair.Value;
- }
- }
- return BoSeType.Red;
- }
- /// <summary>
- /// 获取某个开奖号的生肖
- /// </summary>
- /// <param name="opencode"></param>
- /// <returns></returns>
- private static ShengXiaoType GetShengXiaoTypeByOpenCode(int opencode)
- {
- if (opencode < 0) return ShengXiaoType.Shu;
- foreach (KeyValuePair<List<int>, ShengXiaoType> pair in ShengXiaoDictionary)
- {
- List<int> dictCodes = pair.Key;
- if (dictCodes.Contains(opencode))
- {
- return pair.Value;
- }
- }
- return ShengXiaoType.Shu;
- }
- /// <summary>
- /// 获取某个开奖号的五行
- /// </summary>
- /// <param name="opencode"></param>
- /// <returns></returns>
- private static WuXingType GetWuXingTypeByOpenCode(int opencode)
- {
- if (opencode < 0) return WuXingType.Jin;
- foreach (KeyValuePair<List<int>, WuXingType> pair in WuXingDictionary)
- {
- List<int> dictCodes = pair.Key;
- if (dictCodes.Contains(opencode))
- {
- return pair.Value;
- }
- }
- return WuXingType.Jin;
- }
- #endregion
- #region 实体
- /// <summary>
- /// 香港彩开奖号特性
- /// </summary>
- public class HongKongLottery
- {
- public int OpenCode { get; set; }
- public LotteryAttrItem LotteryAttrItem { get; set; }
- }
- public class LotteryAttrItem
- {
- /// <summary>
- /// 波色
- /// </summary>
- public BoSeType BoSeType { get; set; }
- /// <summary>
- /// 生肖
- /// </summary>
- public string ShengXiao { get; set; }
- /// <summary>
- /// 五行
- /// </summary>
- public string WuXing { get; set; }
- }
- #endregion
- }
- }
|