/// <summary> /// 检查每日抽奖次数 /// </summary> /// <param name="userID"></param> public static void CheckDialNum(string userID) { UserDial userDial = new GameDataCacheSet<UserDial>().FindKey(userID); if (userDial != null && userDial.RefreshDate.Date != DateTime.Now.Date) { userDial.DialNum = 0; userDial.RefreshDate = DateTime.Now; } if (userDial == null) { var cacheSet = new GameDataCacheSet<UserDial>(); userDial = new UserDial(); userDial.UserID = userID; userDial.HeadID = string.Empty; userDial.ReturnRatio = 0; userDial.DialNum = 0; cacheSet.Add(userDial); } }
/// <summary> /// 奖励物品 /// </summary> /// <param name="prize"></param> /// <returns></returns> public static void ChestGainTreasureInfo(GameUser user, DialInfo dialInfo, int count) { var treasure = new TreasureInfo(); treasure.UserID = user.UserID; treasure.Type = dialInfo.RewardType; treasure.ItemID = dialInfo.ItemID; treasure.Num = dialInfo.ItemNum; treasure.ItemLv = 1; UserDial userDial = new GameDataCacheSet<UserDial>().FindKey(user.UserID); if (userDial == null) { userDial = new UserDial(); } userDial.GroupID = 0; userDial.RefreshDate = DateTime.Now; userDial.Treasure.Add(treasure); if (count == 0) { userDial.PrizeInfo = treasure; userDial.HeadID = dialInfo.HeadID; } if (GameConfigSet.Treasure > 0 && userDial.Treasure.Count > GameConfigSet.Treasure) { for (int i = 0; i < userDial.Treasure.Count - GameConfigSet.Treasure; i++) { userDial.Treasure.Remove(userDial.Treasure[i]); } } if (dialInfo.IsShow) { var cacheSet = new ShareCacheStruct<ServerEnvSet>(); var serverEnvSet = cacheSet.FindKey(ServerEnvKey.UserTreasure); if (serverEnvSet == null) { serverEnvSet = new ServerEnvSet(); serverEnvSet.EnvKey = ServerEnvKey.UserTreasure; cacheSet.Add(serverEnvSet, GameEnvironment.CacheGlobalPeriod); } var treasureInfoList = ServerEnvSetTreasure(treasure); serverEnvSet.EnvValue = JsonUtils.Serialize(treasureInfoList); } if (dialInfo.IsBroadcast && !string.IsNullOrEmpty(dialInfo.BroadContent)) { TjxChatService chatService = new TjxChatService(); chatService.SystemSend(ChatType.World, string.Format(dialInfo.BroadContent, user.NickName)); } if (dialInfo.RewardType == RewardType.Again || dialInfo.RewardType == RewardType.Mood || dialInfo.RewardType == RewardType.Recharge) { if (dialInfo.RewardType == RewardType.Recharge) { userDial.ReturnRatio = treasure.Num; } return; } ChestGetUserTake(treasure, user); }
/// <summary> /// 获取大转盘列表ID /// </summary> /// <param name="userID"></param> /// <returns></returns> public static int ChestDialGroupID(string userID, int itemID) { int groupID = 0; var dialFreeList = new ConfigCacheSet<DialInfo>().FindAll(m => m.DialType == itemID.ToShort()); if (dialFreeList.Count == 0) { return groupID; } UserDial userDial = new GameDataCacheSet<UserDial>().FindKey(userID); if (userDial == null) { userDial = new UserDial(); userDial.UserID = userID; var cacheSet = new GameDataCacheSet<UserDial>(); cacheSet.Add(userDial, GameEnvironment.CacheUserPeriod); } int postion = RandomUtils.GetRandom(0, dialFreeList.Count); var dialpostion = dialFreeList[postion]; if (dialpostion != null) { groupID = dialpostion.GroupID; userDial.GroupID = groupID; } userDial.HeadID = string.Empty; userDial.ReturnRatio = 0; userDial.DialNum = 0; userDial.RefreshDate = DateTime.Now; return groupID; }