コード例 #1
0
ファイル: Action1466.cs プロジェクト: dongliang/Scut
        public override bool TakeAction()
        {
            if (!TrumpHelper.IsLearnProperty(ContextUser))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1466_WorshipPropertyNotEnough;
                return(false);
            }
            UserTrump userTrump = new GameDataCacheSet <UserTrump>().FindKey(ContextUser.UserID, TrumpInfo.CurrTrumpID);

            if (userTrump == null)
            {
                return(false);
            }
            UserItemInfo userItem = null;
            var          package  = UserItemPackage.Get(ContextUser.UserID);

            if (package != null)
            {
                userItem = package.ItemPackage.Find(m => !m.IsRemove && m.UserItemID == userItemID);
                if (userItem == null || (userItem.ItemType != ItemType.DaoJu && userItem.PropType == 13))
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St1466_ItemPropertyNotEnough;
                    return(false);
                }
                ItemBaseInfo itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(userItem.ItemID);
                if (itemInfo != null)
                {
                    GeneralProperty property = null;
                    if (userTrump.PropertyInfo.Count > 0)
                    {
                        property = userTrump.PropertyInfo.Find(m => m.AbilityType == itemInfo.AbilityType);
                        if (property != null)
                        {
                            ErrorCode = LanguageManager.GetLang().ErrorCode;
                            ErrorInfo = LanguageManager.GetLang().St1466_ItemPropertyExite;
                            return(false);
                        }
                    }
                    else
                    {
                        userTrump.PropertyInfo.Clear();
                    }
                    short             baseLv        = 1;
                    TrumpPropertyInfo trumpProperty =
                        new ConfigCacheSet <TrumpPropertyInfo>().FindKey(itemInfo.AbilityType, baseLv);
                    if (trumpProperty != null)
                    {
                        property              = new GeneralProperty();
                        property.AbilityType  = itemInfo.AbilityType;
                        property.AbilityLv    = 1;
                        property.AbilityValue = trumpProperty.PropertyNum;
                        userTrump.PropertyInfo.Add(property);
                        TraceProperty(userTrump);
                        UserItemHelper.UseUserItem(ContextUser.UserID, userItem.ItemID, trumpProperty.ItemNum);

                        var usergeneral = UserGeneral.GetMainGeneral(ContextUser.UserID);
                        if (usergeneral != null)
                        {
                            usergeneral.RefreshMaxLife();
                        }

                        ErrorCode = 0;
                        ErrorInfo = LanguageManager.GetLang().St1466_LearningSuccess;
                    }
                }
            }

            return(true);
        }