Ejemplo n.º 1
0
 ///// <summary>
 ///// 获取大转盘列表ID
 ///// </summary>
 ///// <param name="userID"></param>
 ///// <returns></returns>
 //public static int DialGroupID(string userID)
 //{
 //    int groupID = 0;
 //    int postion = 0;
 //    var dialFreeList = new ConfigCacheSet<DialInfo>().FindAll(m => m.DialType == 1);
 //    var dialGoldList = new ConfigCacheSet<DialInfo>().FindAll(m => m.DialType == 2);
 //    if (dialFreeList.Count == 0 || dialGoldList.Count == 0)
 //    {
 //        return groupID;
 //    }
 //    UserDial userDial = new GameDataCacheSet<UserDial>().FindKey(userID);
 //    if (userDial != null)
 //    {
 //        int freeNum = GameConfigSet.FreeSweepstakes;
 //        if (userDial.RefreshDate.Date == DateTime.Now.Date)
 //        {
 //            freeNum = MathUtils.Subtraction(freeNum, userDial.DialNum);
 //            if (userDial.GroupID > 0)
 //            {
 //                groupID = userDial.GroupID;
 //            }
 //            else if (freeNum > 0 && userDial.GroupID == 0)
 //            {
 //                postion = RandomUtils.GetRandom(0, dialFreeList.Count);
 //                var dialpostion = dialFreeList[postion];
 //                if (dialpostion != null)
 //                {
 //                    groupID = dialpostion.GroupID;
 //                }
 //            }
 //            else
 //            {
 //                postion = RandomUtils.GetRandom(0, dialGoldList.Count);
 //                var dialpostion = dialGoldList[postion];
 //                if (dialpostion != null)
 //                {
 //                    groupID = dialpostion.GroupID;
 //                }
 //            }
 //        }
 //        else
 //        {
 //            userDial.RefreshDate = DateTime.Now;
 //            postion = RandomUtils.GetRandom(0, dialFreeList.Count);
 //            var dialpostion = dialFreeList[postion];
 //            if (dialpostion != null)
 //            {
 //                groupID = dialpostion.GroupID;
 //            }
 //        }
 //        userDial.GroupID = groupID;
 //    }
 //    else
 //    {
 //        var cacheSet = new GameDataCacheSet<UserDial>();
 //        postion = RandomUtils.GetRandom(0, dialFreeList.Count);
 //        var dialpostion = dialFreeList[postion];
 //        if (dialpostion != null)
 //        {
 //            groupID = dialpostion.GroupID;
 //        }
 //        userDial = new UserDial();
 //        userDial.UserID = userID;
 //        userDial.HeadID = string.Empty;
 //        userDial.ReturnRatio = 0;
 //        userDial.DialNum = 0;
 //        cacheSet.Add(userDial, GameEnvironment.CacheUserPeriod);
 //    }
 //    userDial.GroupID = groupID;
 //    userDial.RefreshDate = DateTime.Now;
 //    return groupID;
 //}
 ///// <summary>
 ///// 奖励物品
 ///// </summary>
 ///// <param name="prize"></param>
 ///// <returns></returns>
 //public static void GainTreasureInfo(string userID, DialInfo dialInfo, int count)
 //{
 //    var treasure = new TreasureInfo();
 //    treasure.UserID = userID;
 //    treasure.Type = dialInfo.RewardType;
 //    treasure.ItemID = dialInfo.ItemID;
 //    treasure.Num = dialInfo.ItemNum;
 //    treasure.ItemLv = 1;
 //    UserDial userDial = new GameDataCacheSet<UserDial>().FindKey(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))
 //    {
 //        GameUser user = new GameDataCacheSet<GameUser>().FindKey(userID);
 //        if (user != null)
 //        {
 //            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;
 //    }
 //    var cachePrize = new ShareCacheStruct<UserTakePrize>();
 //    var takePrize = GetUserTake(treasure, userID);
 //    cachePrize.Add(takePrize, GameEnvironment.CacheGlobalPeriod);
 //}
 private static List<TreasureInfo> ServerEnvSetTreasure(TreasureInfo treasure)
 {
     List<TreasureInfo> treasureList = new List<TreasureInfo>();
     var cacheSet = new ShareCacheStruct<ServerEnvSet>();
     var serverEnvSet = cacheSet.FindKey(ServerEnvKey.UserTreasure);
     if (serverEnvSet != null && !string.IsNullOrEmpty(serverEnvSet.EnvValue))
     {
         treasureList = JsonUtils.Deserialize<List<TreasureInfo>>(serverEnvSet.EnvValue);
     }
     treasureList.Add(treasure);
     if (GameConfigSet.UserTreasureNum > 0 && treasureList.Count > GameConfigSet.UserTreasureNum)
     {
         for (int i = 0; i < treasureList.Count - GameConfigSet.UserTreasureNum; i++)
         {
             treasureList.Remove(treasureList[i]);
         }
     }
     return treasureList;
 }
Ejemplo n.º 2
0
 ///// <summary>
 ///// 当日是否有免费次数
 ///// </summary>
 ///// <param name="userID"></param>
 ///// <returns></returns>
 //public static bool IsDialFree(string userID)
 //{
 //    UserDial userDial = new GameDataCacheSet<UserDial>().FindKey(userID);
 //    int freeNum = GameConfigSet.FreeSweepstakes;
 //    if (userDial != null && userDial.RefreshDate.Date == DateTime.Now.Date && userDial.DialNum >= freeNum)
 //    {
 //        return false;
 //    }
 //    return true;
 //}
 /// <summary>
 /// 奖励物品名称
 /// </summary>
 /// <param name="prize"></param>
 /// <returns></returns>
 public static string PrizeItemName(TreasureInfo treasure)
 {
     string name = string.Empty;
     switch (treasure.Type)
     {
         case RewardType.GameGoin:
             name = string.Format(LanguageManager.GetLang().St_GameCoin, (int)treasure.Num);
             break;
         case RewardType.Obtion:
             name = string.Format(LanguageManager.GetLang().St_ObtionNum, (int)treasure.Num);
             break;
         case RewardType.ExpNum:
             name = string.Format(LanguageManager.GetLang().St_ExpNum, (int)treasure.Num);
             break;
         case RewardType.EnergyNum:
             name = string.Format(LanguageManager.GetLang().St_EnergyNum, (int)treasure.Num);
             break;
         case RewardType.Experience:
             name = string.Format(LanguageManager.GetLang().St_Experience, (int)treasure.Num);
             break;
         case RewardType.Gold:
             name = string.Format(LanguageManager.GetLang().St_GiftGoldNum, (int)treasure.Num);
             break;
         case RewardType.CrystalId:
             CrystalInfo crystal = new ConfigCacheSet<CrystalInfo>().FindKey(treasure.ItemID);
             name = crystal == null ? string.Empty : crystal.CrystalName;
             break;
         case RewardType.Item:
             ItemBaseInfo itemInfo = new ConfigCacheSet<ItemBaseInfo>().FindKey(treasure.ItemID);
             name = itemInfo == null ? string.Empty : itemInfo.ItemName;
             break;
         case RewardType.Spare:
             SparePartInfo sparePartInfo = new ConfigCacheSet<SparePartInfo>().FindKey(treasure.ItemID);
             name = sparePartInfo == null ? string.Empty : sparePartInfo.Name;
             break;
         case RewardType.Enchant:
             EnchantInfo enchantInfo = new ConfigCacheSet<EnchantInfo>().FindKey(treasure.ItemID);
             name = enchantInfo == null ? string.Empty : enchantInfo.EnchantName;
             break;
         case RewardType.Again:
             name = LanguageManager.GetLang().St12004_RewardSweepstakes;
             break;
         case RewardType.Mood:
             name = LanguageManager.GetLang().St12004_DidNotAnyReward;
             break;
         case RewardType.Recharge:
             name = string.Format(LanguageManager.GetLang().St12004_RechargeReturn, GetTransformData(treasure.Num));
             break;
     }
     return name;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 奖励配置
 /// </summary>
 /// <param name="user"></param>
 public static void ChestGetUserTake(TreasureInfo prize, GameUser user)
 {
     switch (prize.Type)
     {
         case RewardType.GameGoin:
             user.GameCoin = MathUtils.Addition(user.GameCoin, prize.Num.ToInt());
             break;
         case RewardType.Obtion:
             user.ObtainNum = MathUtils.Addition(user.ObtainNum, prize.Num.ToInt());
             break;
         case RewardType.ExpNum:
             user.ExpNum = MathUtils.Addition(user.ExpNum, prize.Num.ToInt());
             break;
         case RewardType.EnergyNum:
             user.EnergyNum = MathUtils.Addition(user.EnergyNum, prize.Num.ToShort());
             break;
         case RewardType.Experience:
             break;
         case RewardType.Gold:
             user.GiftGold = MathUtils.Addition(user.GiftGold, prize.Num.ToInt());
             break;
         case RewardType.Item:
             if (!UserAbilityHelper.UseUserItem(user.UserID, prize.ItemID))
             {
                 UserItemHelper.AddUserItem(user.UserID, prize.ItemID, prize.Num.ToInt());
             }
             break;
         case RewardType.CrystalId:
             short crystalLv = prize.ItemLv > 0 ? prize.ItemLv : 1.ToShort();
             CrystalHelper.AppendCrystal(user.UserID, prize.ItemID, crystalLv);
             break;
         case RewardType.Spare:
             AppendSpare(user, prize.ItemID);
             break;
         case RewardType.Enchant:
             short enchantLv = prize.ItemLv > 0 ? prize.ItemLv : 1.ToShort();
             EnchantHelper.AppendEnchat(user.UserID, prize.ItemID, enchantLv);
             break;
         default:
             break;
     }
 }
Ejemplo n.º 4
0
        /// <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);
        }
Ejemplo n.º 5
0
 public UserDial()
     : base(AccessLevel.ReadWrite)
 {
     PrizeInfo = new TreasureInfo();
     Treasure = new CacheList<TreasureInfo>();
 }
Ejemplo n.º 6
0
 protected override object this[string index]
 {
     get
     {
         #region
         switch (index)
         {
             case "UserID": return UserID;
             case "PrizeInfo": return PrizeInfo;
             case "ReturnRatio": return ReturnRatio;
             case "HeadID": return HeadID;
             case "DialNum": return DialNum;
             case "RefreshDate": return RefreshDate;
             case "Treasure": return Treasure;
             case "GroupID": return GroupID;
             default: throw new ArgumentException(string.Format("UserDial index[{0}] isn't exist.", index));
         }
         #endregion
     }
     set
     {
         #region
         switch (index)
         {
             case "UserID":
                 _UserID = value.ToNotNullString();
                 break;
             case "PrizeInfo":
                 _PrizeInfo = ConvertCustomField<TreasureInfo>(value, index);
                 break;
             case "ReturnRatio": _ReturnRatio = value.ToDecimal();
                 break;
             case "HeadID": _HeadID = value.ToNotNullString();
                 break;
             case "DialNum":
                 _DialNum = value.ToShort();
                 break;
             case "RefreshDate":
                 _RefreshDate = value.ToDateTime();
                 break;
             case "Treasure": _Treasure = ConvertCustomField<CacheList<TreasureInfo>>(value, index);
                 break;
             case "GroupID":
                 _GroupID = value.ToInt();
                 break;
             default: throw new ArgumentException(string.Format("UserDial index[{0}] isn't exist.", index));
         }
         #endregion
     }
 }