ConfigLotteryEntity GetLotteryEntity(int lotteryType, int subType) { var key = BuildLotteryKey(lotteryType, subType); ConfigLotteryEntity lotteryEntity = null; if (_lotteryDic.ContainsKey(key)) { var list = _lotteryDic[key]; if (list.Count == 1) { lotteryEntity = list[0]; } else if (list.Count > 1) { var curTime = DateTime.Now; lotteryEntity = list.Find(d => d.MinTime <= curTime && d.MaxTime >= curTime); if (lotteryEntity == null) { lotteryEntity = list[0]; } } } return(lotteryEntity); }
public LotteryEntity Lottery(int lotteryType, int subType, int cardCount, List <int> prizeEquipments) { ConfigLotteryEntity configLotteryEntity = GetLotteryEntity(lotteryType, subType); if (configLotteryEntity == null) { SystemlogMgr.Error("LotteryCache", "no config lottery entity,lotteryType:" + lotteryType + ",subType:" + subType); return(null); } else { var list = LotteryItem(configLotteryEntity, cardCount, prizeEquipments); if (list != null && list.Count > 0) { var lotteryEntity = new LotteryEntity(); var index = RandomHelper.GetInt32WithoutMax(0, list.Count); lotteryEntity.PrizeItemCode = list[index]; lotteryEntity.ItemString = string.Join(",", list); lotteryEntity.Strength = configLotteryEntity.Strength; lotteryEntity.IsBinding = configLotteryEntity.IsBinding; return(lotteryEntity); } return(null); } }
public LotteryEntity ScoutingNew(int scoutingType, int orangeLib, int lowLib, out List <int> cardList, int giftCode = 0) { cardList = null; ConfigLotteryEntity configLotteryEntity = GetLotteryEntity((int)EnumLotteryType.Lottery, scoutingType); if (configLotteryEntity == null) { SystemlogMgr.Error("ScoutingNew", "no config lottery entity:" + ",subType:" + scoutingType); return(null); } else { int cardCount = 5; int orangeCount = 0; int contractCount = 0; int scoutingorangeCount = _scoutingTenOrangeCount; cardList = LotteryItemNew(configLotteryEntity, cardCount, scoutingorangeCount, orangeLib, lowLib, ref orangeCount, ref contractCount); } if (cardList != null && cardList.Count > 0) { var lotteryEntity = new LotteryEntity(); lotteryEntity.ItemString = string.Join(",", cardList); lotteryEntity.Strength = configLotteryEntity.Strength; lotteryEntity.IsBinding = configLotteryEntity.IsBinding; return(lotteryEntity); } return(null); }
/// <summary> /// 带事务的Update /// </summary> /// <param name="entity"></param> /// <param name="trans">The trans.</param> /// <returns></returns> /// <remarks>2015/10/19 10:46:21</remarks> public bool Update(ConfigLotteryEntity entity, DbTransaction trans) { var database = new SqlDatabase(this.ConnectionString); DbCommand commandWrapper = database.GetStoredProcCommand("dbo.P_ConfigLottery_Update"); database.AddInParameter(commandWrapper, "@Idx", DbType.Int32, entity.Idx); database.AddInParameter(commandWrapper, "@Name", DbType.String, entity.Name); database.AddInParameter(commandWrapper, "@Type", DbType.Int32, entity.Type); database.AddInParameter(commandWrapper, "@SubType", DbType.Int32, entity.SubType); database.AddInParameter(commandWrapper, "@MinLevel", DbType.Int32, entity.MinLevel); database.AddInParameter(commandWrapper, "@MaxLevel", DbType.Int32, entity.MaxLevel); database.AddInParameter(commandWrapper, "@MinVip", DbType.Int32, entity.MinVip); database.AddInParameter(commandWrapper, "@MaxVip", DbType.Int32, entity.MaxVip); database.AddInParameter(commandWrapper, "@MinTime", DbType.DateTime, entity.MinTime); database.AddInParameter(commandWrapper, "@MaxTime", DbType.DateTime, entity.MaxTime); database.AddInParameter(commandWrapper, "@Strength", DbType.Int32, entity.Strength); database.AddInParameter(commandWrapper, "@IsBinding", DbType.Boolean, entity.IsBinding); int results = 0; if (trans != null) { results = database.ExecuteNonQuery(commandWrapper, trans); } else { results = database.ExecuteNonQuery(commandWrapper); } return(Convert.ToBoolean(results)); }
List <int> LotteryItem(ConfigLotteryEntity lotteryEntity, int cardCount, int orangeMax, int orangeLib, int lowLib, ref int orangeCount, int limitedOrangeCount, out List <int> limitedCardList) { var list = new List <int>(cardCount); orangeCount = 0; limitedCardList = new List <int>(); var orangeIndex = RandomHelper.GetInt32WithoutMax(0, cardCount); for (int i = 0; i < cardCount; i++) { int itemCode = 0; if (i == orangeIndex && orangeCount == 0 && orangeLib > 0) { itemCode = LotteryByLib(orangeLib); orangeCount++; } else if (orangeCount >= orangeMax) { itemCode = LotteryByLib(lowLib); } else { itemCode = LotteryItem(lotteryEntity); while (list.Exists(d => d == itemCode)) //排除重复 { itemCode = LotteryItem(lotteryEntity); } var itemDic = CacheFactory.ItemsdicCache.GetItem(itemCode); if (limitedOrangeCount >= 3)//已经有3个89以上了 { while (list.Exists(d => d == itemCode) || (itemDic.ItemType == (int)EnumItemType.PlayerCard && itemDic.PlayerKpi > 89 && (itemDic.LinkId != 30001 || itemDic.LinkId != 30002))) { itemCode = LotteryItem(lotteryEntity); itemDic = CacheFactory.ItemsdicCache.GetItem(itemCode); } } if (itemDic.ItemType == (int)EnumItemType.PlayerCard && itemDic.PlayerKpi > 89 && (itemDic.LinkId != 30001 || itemDic.LinkId != 30002)) { limitedCardList.Add(itemDic.ItemCode); limitedOrangeCount++; } if (itemDic.ItemType == (int)EnumItemType.PlayerCard && itemDic.PlayerCardLevel == (int)EnumPlayerCardLevel.Orange) { orangeCount++; } } list.Add(itemCode); } return(list); }
List <int> LotteryItem(ConfigLotteryEntity lotteryEntity, int cardCount, List <int> prizeEquipments) { var list = new List <int>(cardCount); for (int i = 0; i < cardCount; i++) { var item = LotteryItem(lotteryEntity, prizeEquipments); while (list.Exists(d => d == item)) //排除重复 { item = LotteryItem(lotteryEntity); } list.Add(item); } return(list); }
public LotteryEntity ScoutingTen(int scoutingType, int orangeLib, int lowLib, out List <int> cardList, int limitedOrangeCount, out List <int> limitedCardList, int giftCode = 0) { //orangeLib = 0; cardList = null; limitedCardList = new List <int>(); ConfigLotteryEntity configLotteryEntity = GetLotteryEntity((int)EnumLotteryType.Scouting, scoutingType); if (configLotteryEntity == null) { SystemlogMgr.Error("ScoutingTen", "no config lottery entity,scoutingType:" + scoutingType); return(null); } else { int cardCount = 10; int orangeCount = 0; if (scoutingType == 1) { cardList = LotteryItem(configLotteryEntity, cardCount, null); } else { var scoutingorangeCount = _scoutingTenOrangeCount; if (giftCode > 0) { var item = CacheFactory.ItemsdicCache.GetItem(giftCode); if (item != null && item.ItemType == (int)EnumItemType.PlayerCard && item.PlayerCardLevel == (int)EnumPlayerCardLevel.Orange) { scoutingorangeCount--; } } cardList = LotteryItem(configLotteryEntity, cardCount, scoutingorangeCount, orangeLib, lowLib, ref orangeCount, limitedOrangeCount, out limitedCardList); } if (cardList != null && cardList.Count > 0) { var lotteryEntity = new LotteryEntity(); lotteryEntity.ItemString = string.Join(",", cardList); lotteryEntity.Strength = configLotteryEntity.Strength; lotteryEntity.IsBinding = configLotteryEntity.IsBinding; return(lotteryEntity); } return(null); } }
int LotteryItem(ConfigLotteryEntity lotteryEntity, List <int> prizeEquipments) { int itemCode = 0; if (_lotteryRelationDic.ContainsKey(lotteryEntity.Idx)) { var relation = _lotteryRelationDic[lotteryEntity.Idx]; var libraryId = relation.RandomLinkId; if (lotteryEntity.Type == 1 && prizeEquipments != null && prizeEquipments.Count > 0 && libraryId > 106 && libraryId < 110) { itemCode = prizeEquipments[RandomHelper.GetInt32WithoutMax(0, prizeEquipments.Count)]; if (libraryId == 108) { itemCode = itemCode - 1000; } else if (libraryId == 109) { itemCode = itemCode - 2000; } } else { //特殊处理抽到87-88橙卡, 5%抽金靴卡 if (lotteryEntity.Idx == 10 && libraryId == 137 && RandomHelper.GetInt32(0, 100) <= 5) { itemCode = 180001; } else { itemCode = GetItemFromLib(libraryId); } } } else if (lotteryEntity.Idx == 0) { return(0); } else { SystemlogMgr.Error("LotteryItem", "no relation,lottery id:" + lotteryEntity.Idx); } return(itemCode); }
/// <summary> /// 将IDataReader的当前记录读取到ConfigLotteryEntity 对象 /// </summary> /// <param name="reader"></param> /// <returns></returns> public ConfigLotteryEntity LoadSingleRow(IDataReader reader) { var obj = new ConfigLotteryEntity(); obj.Idx = (System.Int32)reader["Idx"]; obj.Name = (System.String)reader["Name"]; obj.Type = (System.Int32)reader["Type"]; obj.SubType = (System.Int32)reader["SubType"]; obj.MinLevel = (System.Int32)reader["MinLevel"]; obj.MaxLevel = (System.Int32)reader["MaxLevel"]; obj.MinVip = (System.Int32)reader["MinVip"]; obj.MaxVip = (System.Int32)reader["MaxVip"]; obj.MinTime = (System.DateTime)reader["MinTime"]; obj.MaxTime = (System.DateTime)reader["MaxTime"]; obj.Strength = (System.Int32)reader["Strength"]; obj.IsBinding = (System.Boolean)reader["IsBinding"]; return(obj); }
List <int> LotteryItemNew(ConfigLotteryEntity lotteryEntity, int cardCount, int orangeMax, int orangeLib, int lowLib, ref int orangeCount, ref int contractCount) { var list = new List <int>(cardCount); orangeCount = 0; contractCount = 0; //var orangeIndex = RandomHelper.GetInt32WithoutMax(0, cardCount); for (int i = 0; i < cardCount; i++) { int itemCode = 0; //if (i==orangeIndex && orangeCount==0 && orangeLib>0) //{ // itemCode = LotteryByLib(orangeLib); // orangeCount++; //} //else if (orangeCount >= orangeMax || contractCount >= 1) { itemCode = LotteryByLib(lowLib); } else { itemCode = LotteryItem(lotteryEntity); while (list.Exists(d => d == itemCode)) //排除重复 { itemCode = LotteryItem(lotteryEntity); } var itemDic = CacheFactory.ItemsdicCache.GetItem(itemCode); if (itemDic.ItemType == (int)EnumItemType.PlayerCard && itemDic.PlayerCardLevel == (int)EnumPlayerCardLevel.Orange) { orangeCount++; } //是否是合同页 if (itemDic.ItemType == (int)EnumItemType.MallItem && itemDic.FourthType == 56) { contractCount++; } } list.Add(itemCode); } return(list); }
/// <summary> /// GetById /// </summary> /// <param name="idx">idx</param> /// <returns>ConfigLotteryEntity</returns> /// <remarks>2015/10/19 10:46:20</remarks> public ConfigLotteryEntity GetById(System.Int32 idx) { var database = new SqlDatabase(this.ConnectionString); DbCommand commandWrapper = database.GetStoredProcCommand("P_ConfigLottery_GetById"); database.AddInParameter(commandWrapper, "@Idx", DbType.Int32, idx); ConfigLotteryEntity obj = null; using (IDataReader reader = database.ExecuteReader(commandWrapper)) { if (reader.Read()) { obj = LoadSingleRow(reader); } } return(obj); }
private int LotteryItem(ConfigLotteryEntity lotteryEntity) { return(LotteryItem(lotteryEntity, null)); }
/// <summary> /// Update /// </summary> /// <param name="entity"></param> /// <returns></returns> /// <remarks>2015/10/19 10:46:21</remarks> public bool Update(ConfigLotteryEntity entity) { return(Update(entity, null)); }
/// <summary> /// Insert /// </summary> /// <param name="entity"></param> /// <param name="trans">The trans.</param> /// <returns></returns> /// <remarks>2015/10/19 10:46:21</remarks> public bool Insert(ConfigLotteryEntity entity) { return(Insert(entity, null)); }
public static bool Update(ConfigLotteryEntity configLotteryEntity, DbTransaction trans = null, string zoneId = "") { var provider = new ConfigLotteryProvider(zoneId); return(provider.Update(configLotteryEntity, trans)); }