コード例 #1
0
        /// <summary>
        /// 技能升级
        /// </summary>
        /// <param name="mid"></param>
        /// <param name="cid"></param>
        /// <returns></returns>
        public static RootResponse <DTOSkillSetView> UseSkillExp(Guid mid, string cid)
        {
            if (string.IsNullOrEmpty(cid) || !FrameUtil.CheckChar22Id(cid))
            {
                return(ResponseHelper.CreateRoot <DTOSkillSetView>(MessageCode.SkillInvalidCid));
            }

            //var package = ItemCore.Instance.GetPackage(mid, EnumTransactionType.MixSkillExpCard);
            //if (package == null)
            //    return ResponseHelper.CreateRoot<DTOSkillSetView>(MessageCode.NbParameterError);

            //var item = package.GetByItemCode(310110);
            //if (item == null)
            //    return ResponseHelper.CreateRoot<DTOSkillSetView>(MessageCode.SkillExpNotFind);

            var bag     = SkillCardConvert.GetSkillBagWrap(mid);
            var onlib   = bag.SetList;
            var dstItem = onlib.Values.FirstOrDefault(i => i.ItemId == cid);

            if (null == dstItem)
            {
                return(ResponseHelper.CreateRoot <DTOSkillSetView>(MessageCode.SkillMissCard));
            }
            string rawCode = dstItem.ItemCode;

            if (dstItem.Cfg.SkillLevel <= 0)
            {
                dstItem.Cfg.SkillLevel = 1;
            }
            if (dstItem.Cfg.SkillLevel >= SkillCardConfig.SKILLCardMaxCardLevel)
            {
                return(ResponseHelper.CreateRoot <DTOSkillSetView>(MessageCode.SkillMixOverCardLevel));
            }
            var config = SkillCardConfig.GetSkillUpgrade(dstItem.Cfg.SkillLevel + 1, dstItem.Cfg.SkillClass);

            if (config == null)
            {
                return(ResponseHelper.CreateRoot <DTOSkillSetView>(MessageCode.SkillMissConfig));
            }

            var manager = ManagerCore.Instance.GetManager(mid);

            if (manager == null)
            {
                return(ResponseHelper.CreateRoot <DTOSkillSetView>(MessageCode.AdMissManager));
            }
            if (manager.Coin < config.Coin)
            {
                return(ResponseHelper.CreateRoot <DTOSkillSetView>(MessageCode.LackofCoin));
            }
            int newLevel = 1;

            if (InnerDealMix(dstItem, out newLevel))
            {
                string setSkills = string.Empty;
                if (dstItem.ItemCode != rawCode)//升级了
                {
                    setSkills = bag.SetSkillsTextFromLib();
                    MemcachedFactory.SolutionClient.Delete(mid);
                }
                var errCode = InnerSaveMixNew(manager, mid, bag, config.Coin, setSkills);
                if (errCode == MessageCode.Success)
                {
                    var response = GetSkillSetInfo(mid);
                    response.Data.Coin = manager.Coin;
                    return(response);
                }
            }

            return(ResponseHelper.CreateRoot <DTOSkillSetView>(MessageCode.FailUpdate));
        }