Пример #1
0
        private void AppenUserItem(ItemSynthesisInfo synthesisInfo, int ugeneralID, ItemStatus istatus, short itemLv)
        {
            //原因:合成黄色装备,物品存放为0
            if (istatus != ItemStatus.YongBing)
            {
                istatus = ItemStatus.BeiBao;
            }
            var package = UserItemPackage.Get(Uid);

            string       uitemID  = Guid.NewGuid().ToString();
            UserItemInfo userItem = new UserItemInfo()
            {
                UserItemID = uitemID,
                ItemID     = synthesisInfo.ItemID,
                ItemLv     = MathUtils.Subtraction(itemLv, (short)5, (short)1),
                ItemStatus = istatus,
                ItemType   = ItemType.ZhuangBei,
                GeneralID  = ugeneralID,
                Num        = 1
            };

            package.SaveItem(userItem);
            //package.DelayChange();
            UserItemHelper.AddItemLog(ContextUser.UserID, synthesisInfo.ItemID, 1, MathUtils.Subtraction(itemLv, (short)5, (short)1), 5, uitemID);
        }
Пример #2
0
        /// <summary>
        /// 合成后装备
        /// </summary>
        /// <param name="itemID"></param>
        /// <param name="info"></param>
        private void UpdateUserItem(int itemID, UserItemInfo info)
        {
            //原因:合成黄色装备,物品存放为0
            info.ItemID = itemID;
            info.ItemLv = MathUtils.Subtraction(info.ItemLv, (short)5, (short)1);
            var package = UserItemPackage.Get(Uid);

            info.ItemType = ItemType.ZhuangBei;
            package.SaveItem(info);
            //package.DelayChange();
            UserItemHelper.AddItemLog(ContextUser.UserID, itemID, 1, info.ItemLv, 5, info.UserItemID);
        }
Пример #3
0
        public override bool TakeAction()
        {
            var          package  = UserItemPackage.Get(Uid);
            UserItemInfo userItem = package.ItemPackage.Find(m => !m.IsRemove && m.UserItemID.Equals(userItemID));

            if (userItem != null)
            {
                package.UpdateNotify(obj =>
                {
                    package.RemoveItem(userItem);
                    return(true);
                });
                UserItemHelper.AddItemLog(ContextUser.UserID, userItem.ItemID, userItem.Num, userItem.ItemLv, 8, userItem.UserItemID);
            }
            else
            {
                this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                this.ErrorInfo = LanguageManager.GetLang().ServerBusy;
                return(false);
            }
            return(true);
        }
Пример #4
0
        public override bool TakeAction()
        {
            int intervalDate      = ConfigEnvSet.GetInt("UserItemSold.IntervalDate");
            int totalIntervalDate = (intervalDate * 60 * 60);

            var package  = UserItemPackage.Get(Uid);
            var sellItem = package.ItemPackage.FindAll(m => !m.IsRemove && m.ItemStatus == ItemStatus.Sell);

            foreach (var item in sellItem)
            {
                if ((DateTime.Now - item.SoldDate).TotalSeconds > totalIntervalDate)
                {
                    UserItemHelper.AddItemLog(ContextUser.UserID, item.ItemID, item.Num, item.ItemLv, 4, item.UserItemID);

                    package.RemoveItem(item);
                }
            }

            var tempList = package.ItemPackage.FindAll(m => !m.IsRemove && m.ItemStatus == ItemStatus.Sell);

            userItemArray = tempList.GetPaging(pageIndex, pageSize, out pageCount);
            return(true);
        }
Пример #5
0
        public override bool TakeAction()
        {
            short        opType            = 0;
            UserItemInfo synthesisUserItem = null;
            var          package           = UserItemPackage.Get(Uid);
            UserItemInfo userItem          = null;

            if (!string.IsNullOrEmpty(_userItemID))
            {
                var userItemList = package.ItemPackage.FindAll(m => !m.IsRemove && m.UserItemID.Equals(_userItemID));
                foreach (var item in userItemList)
                {
                    if (item.ItemStatus == ItemStatus.Sell)
                    {
                        package.RemoveItem(userItem);
                        continue;
                    }
                    else if (item.SoldDate > MathUtils.SqlMinDate)
                    {
                        item.SoldDate = MathUtils.SqlMinDate;
                        //package.Update();
                        userItem = item;
                    }
                    else
                    {
                        userItem = item;
                    }
                }
                if (userItem == null)
                {
                    return(false);
                }
                ItemBaseInfo itemBaseOpType = new ConfigCacheSet <ItemBaseInfo>().FindKey(userItem.ItemID);
                if (itemBaseOpType == null)
                {
                    return(false);
                }
                if (itemBaseOpType.ItemType == ItemType.TuZhi)
                {
                    opType = 1;
                }
                else
                {
                    opType = 2;
                }
            }
            else if (!string.IsNullOrEmpty(_userEquID))
            {
                opType   = 1;
                userItem = package.ItemPackage.Find(m => !m.IsRemove && m.UserItemID.Equals(_userEquID));
            }
            if (userItem == null)
            {
                return(false);
            }
            int genlv = ContextUser.UserLv;
            CacheList <SynthesisInfo> synthesisInfoList = new CacheList <SynthesisInfo>();
            short itemLv = 0;
            List <ItemSynthesisInfo> itemSynthesisArray = new ConfigCacheSet <ItemSynthesisInfo>().FindAll(m => m.SynthesisID == userItem.ItemID); //图纸ID

            if (itemSynthesisArray.Count > 0)
            {
                ItemSynthesisInfo synthesisInfo = itemSynthesisArray[0];
                if (synthesisInfo == null)
                {
                    return(false);
                }
                ItemBaseInfo itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(synthesisInfo.ItemID);
                if (itemInfo != null && itemInfo.ItemType == ItemType.ZhuangBei && itemInfo.DemandLv > genlv)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_LevelNotEnough;
                    return(false);
                }
                List <ItemSynthesisInfo> synthesisArray = new ConfigCacheSet <ItemSynthesisInfo>().FindAll(m => m.ItemID == synthesisInfo.ItemID);//合成物品的材料数组
                if (synthesisArray.Count == 0)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().LoadDataError;
                    return(false);
                }
                int useGold = GetSytnthesisGold(ContextUser.UserID, synthesisInfo.ItemID);
                if (_ops == 1)
                {
                    #region 普通合成
                    if (!GetMaterialsNum(ContextUser.UserID, synthesisInfo.ItemID) && ContextUser.VipLv < 4)
                    {
                        ErrorCode = 3;
                        ErrorInfo = LanguageManager.GetLang().St1603_MaterialsNotEnough;
                        return(false);
                    }
                    if (!GetMaterialsNum(ContextUser.UserID, synthesisInfo.ItemID) && ContextUser.VipLv >= 4)
                    {
                        ErrorCode = 2;
                        ErrorInfo = LanguageManager.GetLang().St1603_MaterialsNotEnough + "," + string.Format(LanguageManager.GetLang().St1603_SynthesisEnergyNum, useGold);
                        return(false);
                    }
                    foreach (ItemSynthesisInfo synthesis in synthesisArray)
                    {
                        ItemBaseInfo itemsInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(synthesis.SynthesisID);
                        if (itemInfo == null)
                        {
                            return(false);
                        }
                        if (!string.IsNullOrEmpty(_userEquID) && synthesis.SynthesisID == userItem.ItemID && itemsInfo != null && itemInfo.ItemType == ItemType.ZhuangBei)
                        {
                            if (userItem.ItemStatus == ItemStatus.YongBing)
                            {
                                //if (UserHelper.IsItemEquSpare(ContextUser, userItem.UserItemID))
                                //{
                                //    ErrorCode = LanguageManager.GetLang().ErrorCode;
                                //    ErrorInfo = LanguageManager.GetLang().St_ItemEquIndexOfSpare;
                                //    return false;
                                //}
                                if (IsLevelNotEnough(ContextUser, userItem.GeneralID, synthesisInfo.ItemID))
                                {
                                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                                    ErrorInfo = LanguageManager.GetLang().St_LevelNotEnough;
                                    return(false);
                                }
                                UserItemHelper.AddItemLog(ContextUser.UserID, userItem.ItemID, userItem.Num, userItem.ItemLv, 9, userItem.UserItemID);
                                synthesisInfoList.Add(new SynthesisInfo()
                                {
                                    DemandID = userItem.ItemID, Num = 1
                                });
                                //package.SyncCache(() =>
                                //{
                                //    userItem.IsRemove = true;
                                //    package.ItemPackage.Remove(userItem);
                                //    package.DelayChange();
                                //});
                            }
                        }
                        else
                        {
                            if (itemsInfo != null && itemsInfo.ItemType == ItemType.ZhuangBei)
                            {
                                synthesisUserItem = GetUserItemInfo(ContextUser.UserID, itemsInfo.ItemID);
                                if (IsLevelNotEnough(ContextUser, synthesisUserItem.GeneralID, synthesisInfo.ItemID))
                                {
                                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                                    ErrorInfo = LanguageManager.GetLang().St_LevelNotEnough;
                                    return(false);
                                }
                                //synthesisUserItem = GetUserItemInfo(ContextUser.UserID, itemsInfo.ItemID);
                            }
                            else
                            {
                                synthesisInfoList.Add(new SynthesisInfo()
                                {
                                    DemandID = synthesis.SynthesisID, Num = synthesis.DemandNum
                                });
                                UserItemHelper.UseUserItem(ContextUser.UserID, synthesis.SynthesisID, synthesis.DemandNum);
                            }
                        }
                    }
                    if (!string.IsNullOrEmpty(_userEquID))
                    {
                        itemLv = MathUtils.Subtraction(userItem.ItemLv, (short)5, (short)1);
                        UpdateUserItem(synthesisInfo.ItemID, userItem);
                        UserLogHelper.AppenItemSynthesisLog(ContextUser.UserID, opType, synthesisInfo.ItemID, 1, synthesisInfoList, null, 0, itemLv, userItem.ItemLv);
                    }
                    else
                    {
                        if (synthesisUserItem != null)
                        {
                            itemLv = MathUtils.Subtraction(synthesisUserItem.ItemLv, (short)5, (short)1);
                            UpdateUserItem(synthesisInfo.ItemID, synthesisUserItem);
                            UserLogHelper.AppenItemSynthesisLog(ContextUser.UserID, opType, synthesisInfo.ItemID, 1, synthesisInfoList, null, 0, itemLv, userItem.ItemLv);
                        }
                        else
                        {
                            UserItemHelper.AddUserItem(ContextUser.UserID, synthesisInfo.ItemID, synthesisArray[0].SynthesisNum);
                            UserLogHelper.AppenItemSynthesisLog(ContextUser.UserID, opType, synthesisInfo.ItemID, 1, synthesisInfoList, null, 0, itemLv, userItem.ItemLv);
                        }
                    }
                    #endregion
                }
                else if (_ops == 2)
                {
                    #region 晶石合成
                    if (!VipHelper.GetVipOpenFun(ContextUser.VipLv, ExpandType.JuanZouZhiJieWanCheng))
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St_VipNotEnoughNotFuntion;
                        return(false);
                    }
                    ErrorCode = 1;
                    ErrorInfo = string.Format(LanguageManager.GetLang().St1603_SynthesisEnergyNum, useGold);
                    return(false);

                    #endregion
                }
                else if (_ops == 3)
                {
                    #region 确认晶石合成
                    if (ContextUser.GoldNum < useGold)
                    {
                        ErrorCode = 1;
                        ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                        return(false);
                    }
                    //原因:配置材料不使用晶石合成时提示
                    string userItemName = UseritemGoldName(ContextUser.UserID, synthesisArray);
                    if (!string.IsNullOrEmpty(userItemName))
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = string.Format(LanguageManager.GetLang().St_ItemIsGold, userItemName);
                        return(false);
                    }

                    foreach (ItemSynthesisInfo synthesis in synthesisArray)
                    {
                        int          curNum    = 0;
                        ItemBaseInfo itemsInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(synthesis.SynthesisID);
                        if (!string.IsNullOrEmpty(_userEquID) && synthesis.SynthesisID == userItem.ItemID)
                        {
                            if (userItem.ItemStatus == ItemStatus.YongBing)
                            {
                                if (IsLevelNotEnough(ContextUser, userItem.GeneralID, synthesisInfo.ItemID))
                                {
                                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                                    ErrorInfo = LanguageManager.GetLang().St_LevelNotEnough;
                                    return(false);
                                }

                                UserItemHelper.AddItemLog(ContextUser.UserID, userItem.ItemID, userItem.Num, userItem.ItemLv, 9, userItem.UserItemID);
                                synthesisInfoList.Add(new SynthesisInfo()
                                {
                                    DemandID = userItem.ItemID, Num = 1
                                });
                            }
                        }
                        else
                        {
                            if (itemsInfo != null && itemsInfo.ItemType == ItemType.ZhuangBei)
                            {
                                synthesisUserItem = GetUserItemInfo(ContextUser.UserID, itemsInfo.ItemID);
                                if (IsLevelNotEnough(ContextUser, synthesisUserItem.GeneralID, synthesisInfo.ItemID))
                                {
                                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                                    ErrorInfo = LanguageManager.GetLang().St_LevelNotEnough;
                                    return(false);
                                }
                            }
                            else
                            {
                                var itemArray = UserItemHelper.GetItems(Uid).FindAll(u => u.ItemID.Equals(synthesis.SynthesisID) && (u.ItemStatus == ItemStatus.BeiBao || u.ItemStatus == ItemStatus.CangKu));
                                if (itemArray.Count > 0)
                                {
                                    foreach (var item in itemArray)
                                    {
                                        curNum += item.Num;
                                    }
                                    if (synthesis.DemandNum < curNum)
                                    {
                                        UserItemHelper.UseUserItem(ContextUser.UserID, synthesis.SynthesisID, synthesis.DemandNum);
                                        synthesisInfoList.Add(new SynthesisInfo()
                                        {
                                            DemandID = synthesis.SynthesisID, Num = synthesis.DemandNum
                                        });
                                    }
                                    else
                                    {
                                        UserItemHelper.UseUserItem(ContextUser.UserID, synthesis.SynthesisID, curNum);
                                        synthesisInfoList.Add(new SynthesisInfo()
                                        {
                                            DemandID = synthesis.SynthesisID, Num = curNum
                                        });
                                    }
                                }
                            }
                        }
                    }
                    if (!string.IsNullOrEmpty(_userEquID))
                    {
                        itemLv = MathUtils.Subtraction(userItem.ItemLv, (short)5, (short)1);
                        UpdateUserItem(synthesisInfo.ItemID, userItem);
                        UserLogHelper.AppenItemSynthesisLog(ContextUser.UserID, opType, synthesisInfo.ItemID, 1, synthesisInfoList, null, 0, itemLv, userItem.ItemLv);
                    }
                    else
                    {
                        if (synthesisUserItem != null)
                        {
                            itemLv = MathUtils.Subtraction(synthesisUserItem.ItemLv, (short)5, (short)1);
                            UpdateUserItem(synthesisInfo.ItemID, synthesisUserItem);
                            UserLogHelper.AppenItemSynthesisLog(ContextUser.UserID, opType, synthesisInfo.ItemID, 1, synthesisInfoList, null, 0, itemLv, userItem.ItemLv);
                        }
                        else
                        {
                            UserItemHelper.AddUserItem(ContextUser.UserID, synthesisInfo.ItemID, synthesisArray[0].SynthesisNum);
                            UserLogHelper.AppenItemSynthesisLog(ContextUser.UserID, opType, synthesisInfo.ItemID, 1, synthesisInfoList, null, 0, itemLv, userItem.ItemLv);
                        }
                    }

                    ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, useGold, int.MaxValue);
                    // ContextUser.Update();

                    #endregion
                }
            }
            return(true);
        }
Пример #6
0
        public override bool TakeAction()
        {
            var package      = UserItemPackage.Get(Uid);
            var userItemList = package.ItemPackage.FindAll(m => !m.IsRemove && m.UserItemID.Equals(_userItemId));

            if (userItemList.Count == 0)
            {
                return(false);
            }
            //原因:卖出装备,装备上有灵件时提示
            int currNum = ContextUser.SparePartList.FindAll(m => m.UserItemID.Equals(_userItemId)).Count;

            if (currNum > 0)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St7006_UserItemHaveSpare;
                return(false);
            }
            foreach (var userItem in userItemList)
            {
                if (ItemCheck.check(_userItemId))
                {
                    continue;
                }
                if (userItem.ItemStatus == ItemStatus.Sell)
                {
                    package.RemoveItem(userItem);
                    continue;
                }
                if (userItem.ItemStatus != ItemStatus.Sell && userItem.SoldDate > MathUtils.SqlMinDate)
                {
                    userItem.SoldDate = MathUtils.SqlMinDate;
                    //package.Update();
                    continue;
                }
                ItemBaseInfo itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(userItem.ItemID);
                if (itemInfo != null)
                {
                    int salePrice;
                    if (itemInfo.ItemType == ItemType.ZhuangBei)
                    {
                        salePrice = UserHelper.StrongEquPayPrice(Uid, userItem.UserItemID);
                    }
                    else
                    {
                        salePrice = (itemInfo.SalePrice * userItem.Num);
                    }
                    _salePrice = salePrice;
                    if (userItem.ItemStatus != ItemStatus.Sell)
                    {
                        ItemCheck.add(_userItemId);
                        UserItemHelper.AddItemLog(ContextUser.UserID, userItem.ItemID, userItem.Num, userItem.ItemLv, 3, userItem.UserItemID);
                        //package.RemoveItem(userItem);
                        package.ItemPackage.Remove(userItem);
                        ContextUser.GameCoin = MathUtils.Addition(ContextUser.GameCoin, salePrice, int.MaxValue);
                        //ContextUser.Update();
                    }
                }
            }
            return(true);
        }
Пример #7
0
        public override bool TakeAction()
        {
            var cacheSetPack = new PersonalCacheStruct <UserPack>();
            var userPack     = cacheSetPack.FindKey(UserId.ToString());
            var pack         = userPack != null && userPack.PackTypeList != null?userPack.PackTypeList.Find(s => s.BackpackType == BackpackType.BeiBao) : null;

            _gridNum = pack != null ? pack.Position : 0;
            //int sellDate = (ConfigEnvSet.GetInt("UserItemSold.IntervalDate") * 60 * 60);

            var package  = UserItemPackage.Get(Uid);
            var sellItem = package.ItemPackage.FindAll(m => !m.IsRemove && m.ItemStatus == ItemStatus.Sell && m.ItemType.ToInt() == _packType);

            _itemCount = package != null && package.ItemPackage != null
                            ? package.ItemPackage.FindAll(s => s.ItemType != ItemType.ZhuangBei).Count
                            : 0;

            foreach (var item in sellItem)
            {
                UserItemHelper.AddItemLog(ContextUser.UserID, item.ItemID, item.Num, item.ItemLv, 4, item.UserItemID);
                package.RemoveItem(item);
            }

            var itemSortArray = package.ItemPackage.FindAll(m => !m.IsRemove && m.ItemStatus == ItemStatus.BeiBao && m.ItemType.ToInt() == _packType);

            itemSortArray.QuickSort((x, y) =>
            {
                int result = 0;
                if (x == null && y == null)
                {
                    return(0);
                }
                if (x != null && y == null)
                {
                    return(1);
                }
                if (x == null)
                {
                    return(-1);
                }

                result = (y.CanUse).CompareTo(x.CanUse);
                if (result == 0)
                {
                    result = ((int)x.ItemType).CompareTo((int)y.ItemType);
                    if (result == 0)
                    {
                        result = x.ItemID.CompareTo(y.ItemID);
                        if (result == 0)
                        {
                            if (x.ItemType == ItemType.ZhuangBei)
                            {
                                UserItemHelper h1 = new UserItemHelper(y);
                                UserItemHelper h2 = new UserItemHelper(x);
                                result            = ((int)h2.QualityType).CompareTo((int)h1.QualityType);
                                if (result == 0)
                                {
                                    result = ((int)y.ItemLv).CompareTo(x.ItemLv);
                                }
                            }
                            else
                            {
                                result = ((int)y.ItemLv).CompareTo(x.ItemLv);
                            }
                        }
                    }
                }
                return(result);
            });

            mlist = itemSortArray.GetPaging(pageIndex, pageSize, out pageCount);
            return(true);
        }