From 1e8c7d6350e5d69823b0c01fc9d8c50980e86e54 Mon Sep 17 00:00:00 2001
From: client_Wu Xijin <364452445@qq.com>
Date: 星期一, 25 二月 2019 12:25:21 +0800
Subject: [PATCH] 3335 物品相关类型重构

---
 System/KnapSack/Logic/ItemLogicUtility.cs | 3298 +++++++++++++++++++++++++++++------------------------------
 1 files changed, 1,647 insertions(+), 1,651 deletions(-)

diff --git a/System/KnapSack/Logic/PackModelInterface.cs b/System/KnapSack/Logic/ItemLogicUtility.cs
similarity index 99%
rename from System/KnapSack/Logic/PackModelInterface.cs
rename to System/KnapSack/Logic/ItemLogicUtility.cs
index 4a298ff..5efc59a 100644
--- a/System/KnapSack/Logic/PackModelInterface.cs
+++ b/System/KnapSack/Logic/ItemLogicUtility.cs
@@ -1,1651 +1,1647 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Linq;
-using LitJson;
-using UnityEngine;
-
-namespace Snxxz.UI
-{
-    [XLua.LuaCallCSharp]
-    public class PackModelInterface : Model, IBeforePlayerDataInitialize
-    {
-        private string jadeDynastyGSFormula;
-        private string dogzGSFormula;
-        private string normalGSFormula;
-
-        private int[] preciousItemTypes;
-        private int[] drugIDs;
-        private int[] onekeySellTypes;
-        private int[] pushItemIds;
-        private int[] pushBuffTypeIds;
-
-        private List<int> equipBaseProperties = new List<int>();
-        private Dictionary<int, int> promptUseLimitDict;
-        private Dictionary<int, List<int>> betterEquipExceptDungeonDict;
-
-        PlayerPackModel playerPack { get { return ModelCenter.Instance.GetModel<PlayerPackModel>(); } }
-        ItemTipsModel itemTipsModel { get { return ModelCenter.Instance.GetModel<ItemTipsModel>(); } }
-        PlayerBuffDatas buffDatas { get { return ModelCenter.Instance.GetModel<PlayerBuffDatas>(); } }
-        PlayerMountDatas mountDatas { get { return ModelCenter.Instance.GetModel<PlayerMountDatas>(); } }
-        PlayerPetDatas petDatas { get { return ModelCenter.Instance.GetModel<PlayerPetDatas>(); } }
-        PlayerStrengthengDatas strengthDatas { get { return ModelCenter.Instance.GetModel<PlayerStrengthengDatas>(); } }
-        MagicianModel magicianModel { get { return ModelCenter.Instance.GetModel<MagicianModel>(); } }
-        TrialDungeonModel trialModel { get { return ModelCenter.Instance.GetModel<TrialDungeonModel>(); } }
-        ComposeWinModel composeModel { get { return ModelCenter.Instance.GetModel<ComposeWinModel>(); } }
-
-        public override void Init()
-        {
-            var GSFormulaConfig = FuncConfigConfig.Get("EquipGSFormula");
-            jadeDynastyGSFormula = GSFormulaConfig.Numerical4;
-            dogzGSFormula = GSFormulaConfig.Numerical3;
-            normalGSFormula = GSFormulaConfig.Numerical1;
-
-            var baseAttr = JsonMapper.ToObject(GSFormulaConfig.Numerical2);
-            if (baseAttr.IsArray)
-            {
-                for (int i = 0; i < baseAttr.Count; i++)
-                {
-                    equipBaseProperties.Add(int.Parse(baseAttr[i].ToString()));
-                }
-            }
-
-            preciousItemTypes = ConfigParse.GetMultipleStr<int>(FuncConfigConfig.Get("ItemPush").Numerical1);
-            promptUseLimitDict = ConfigParse.GetDic<int, int>(FuncConfigConfig.Get("NoPromptUsetItem").Numerical1);
-
-            drugIDs = ConfigParse.GetMultipleStr<int>(FuncConfigConfig.Get("LifePotionlist").Numerical1);
-            onekeySellTypes = ConfigParse.GetMultipleStr<int>(FuncConfigConfig.Get("OneKeySellItemType").Numerical1);
-
-            pushItemIds = ConfigParse.GetMultipleStr<int>(FuncConfigConfig.Get("IntroductionItem").Numerical1);
-            pushBuffTypeIds = ConfigParse.GetMultipleStr<int>(FuncConfigConfig.Get("IntroductionItem").Numerical2);
-
-            betterEquipExceptDungeonDict = new Dictionary<int, List<int>>();
-            var excEquipData = JsonMapper.ToObject(FuncConfigConfig.Get("GoodItemDungeon").Numerical1);
-            foreach (var dungeonId in excEquipData.Keys)
-            {
-                var itemIds = new List<int>();
-                betterEquipExceptDungeonDict.Add(int.Parse(dungeonId), itemIds);
-                for (var i = 0; i < excEquipData[dungeonId].Count; i++)
-                {
-                    var itemId = int.Parse(excEquipData[dungeonId][i].ToString());
-                    itemIds.Add(itemId);
-                }
-            }
-
-        }
-
-        public void OnBeforePlayerDataInitialize()
-        {
-            isPackResetOk = true;
-            ClearSortedBetterEquip();
-        }
-
-        public override void UnInit()
-        {
-
-        }
-
-        #region 璁$畻瑁呭璇勫垎
-
-        class EquipSorceProperties
-        {
-            Dictionary<int, int> properties = new Dictionary<int, int>();
-
-            public int this[int id] { get { return properties[id]; } }
-
-            public List<int> Keys { get { return new List<int>(properties.Keys); } }
-
-            void Add(int id, int value)
-            {
-                if (properties.ContainsKey(id))
-                {
-                    properties[id] += value;
-                }
-                else
-                {
-                    properties[id] = value;
-                }
-            }
-
-            public void AddRange(List<int> ids, List<int> values)
-            {
-                if (ids == null || values == null)
-                {
-                    return;
-                }
-
-                var count = Mathf.Min(ids.Count, values.Count);
-                for (int i = 0; i < count; i++)
-                {
-                    Add(ids[i], values[i]);
-                }
-            }
-
-            public void AddRange(int[] ids, int[] values)
-            {
-                if (ids == null || values == null)
-                {
-                    return;
-                }
-
-                var length = Mathf.Min(ids.Length, values.Length);
-                for (int i = 0; i < length; i++)
-                {
-                    Add(ids[i], values[i]);
-                }
-            }
-
-            public void AddRange(Dictionary<int, int> keyValues)
-            {
-                if (keyValues == null)
-                {
-                    return;
-                }
-
-                foreach (var item in keyValues)
-                {
-                    properties.Add(item.Key, item.Value);
-                }
-            }
-
-            public void AddBaseProperties(int itemId, List<int> reference)
-            {
-                var config = ItemConfig.Get(itemId);
-                if (config.Effect1 != 0 && reference.Contains(config.Effect1))
-                {
-                    properties.Add(config.Effect1, config.EffectValueA1);
-                }
-
-                if (config.Effect2 != 0 && reference.Contains(config.Effect2))
-                {
-                    properties.Add(config.Effect2, config.EffectValueA2);
-                }
-
-                if (config.Effect3 != 0 && reference.Contains(config.Effect3))
-                {
-                    properties.Add(config.Effect3, config.EffectValueA3);
-                }
-
-                if (config.Effect4 != 0 && reference.Contains(config.Effect4))
-                {
-                    properties.Add(config.Effect4, config.EffectValueA4);
-                }
-
-                if (config.Effect5 != 0 && reference.Contains(config.Effect5))
-                {
-                    properties.Add(config.Effect5, config.EffectValueA5);
-                }
-            }
-
-            public void AddCustomProperties(int itemId)
-            {
-                if (AppointItemConfig.Has(itemId))
-                {
-                    return;
-                }
-
-                var config = AppointItemConfig.Get(itemId);
-                AddRange(config.LegendAttrID, config.LegendAttrValue);
-                AddRange(config.OutOfPrintAttr, config.OutOfPrintAttrValue);
-            }
-        }
-
-        public int GetEquipScore(PackType type, int itemId, Dictionary<int, List<int>> useDataDic = null, bool isPreview = false)
-        {
-            var config = ItemConfig.Get(itemId);
-            var properties = new EquipSorceProperties();
-
-            if (IsCustomItem(itemId))
-            {
-                properties.AddBaseProperties(config.EffectValueA1, equipBaseProperties);
-                properties.AddCustomProperties(itemId);
-                return CalculateEquipScore(type, config.EffectValueA1, properties);
-            }
-
-            properties.AddBaseProperties(itemId, equipBaseProperties);
-            if (isPreview)
-            {
-                switch (config.EquipPlace)
-                {
-                    case 11:
-                        properties.AddRange(GetWingsLegendProperties(itemId));
-                        break;
-                    case 1:
-                    case 2:
-                    case 3:
-                    case 4:
-                    case 5:
-                    case 6:
-                    case 7:
-                    case 8:
-                    case 9:
-                    case 10:
-                    case 12:
-                        properties.AddRange(GetEquipLegendProperties(itemId));
-                        break;
-                }
-
-                var packType = GeneralDefine.GetPackTypeByItemType(config.Type);
-                switch (packType)
-                {
-                    case PackType.JadeDynastyItem:
-                        properties.AddRange(CalculateJadeDynastyLegendAttr(itemId));
-                        break;
-                }
-
-                return CalculateEquipScore(type, itemId, properties);
-            }
-
-            if (useDataDic != null)
-            {
-                if (useDataDic.ContainsKey((int)ItemUseDataKey.legendAttrID))
-                {
-                    properties.AddRange(useDataDic[(int)ItemUseDataKey.legendAttrID], useDataDic[(int)ItemUseDataKey.legendAttrValue]);
-                }
-
-                if (useDataDic.ContainsKey((int)ItemUseDataKey.outOfPrintAttrID))
-                {
-                    properties.AddRange(useDataDic[(int)ItemUseDataKey.outOfPrintAttrID], useDataDic[(int)ItemUseDataKey.outOfPrintAttrValue]);
-                }
-            }
-
-            return CalculateEquipScore(type, itemId, properties);
-        }
-
-        private Dictionary<int, int> GetEquipLegendProperties(int itemId)
-        {
-            var config = ItemConfig.Get(itemId);
-            var legendIdlist = new List<int>();
-
-            if (LegendPropertyUtility.HasEquipPlace(config.EquipPlace))
-            {
-                for (var i = 0; i < 3; i++)
-                {
-                    var type = (LegendAttrType)i;
-                    var count = LegendPropertyUtility.GetEquipPropertyCount(config.ItemColor, config.StarLevel, type);
-                    if (count > 0)
-                    {
-                        var propertyIds = LegendPropertyUtility.GetEquipPlaceProperties(config.EquipPlace, type);
-                        legendIdlist.AddRange(propertyIds.GetRange(0, count));
-                    }
-                }
-            }
-
-            var properties = new Dictionary<int, int>();
-            for (int i = 0; i < legendIdlist.Count; i++)
-            {
-                var propertyId = legendIdlist[i];
-                var qualityPropertyValue = LegendPropertyUtility.GetEquipQualityPropertyValue(propertyId, config.ItemColor);
-                if (qualityPropertyValue != 0)
-                {
-                    properties[propertyId] = qualityPropertyValue;
-                }
-                else
-                {
-                    var levelPropertyValue = LegendPropertyUtility.GetEquipLevelPropertyValue(propertyId, config.LV);
-                    if (levelPropertyValue != 0)
-                    {
-                        properties[propertyId] = levelPropertyValue;
-                    }
-                }
-            }
-
-            return properties;
-        }
-
-        public Dictionary<int, int> GetWingsLegendProperties(int itemId)
-        {
-            var config = ItemConfig.Get(itemId);
-            var properties = new Dictionary<int, int>();
-            var level = config.LV;
-            var count = LegendPropertyUtility.GetWingPropertyCount(level);
-            var ids = LegendPropertyUtility.GetWingProperties(level);
-            if (ids != null)
-            {
-                for (var i = 0; properties.Count < count && i < properties.Count; i++)
-                {
-                    var propertyId = ids[i];
-                    properties[propertyId] = LegendPropertyUtility.GetWingPropertyValues(level, propertyId)[0];
-                }
-            }
-
-            return properties;
-        }
-
-        private Dictionary<int, int> CalculateJadeDynastyLegendAttr(int itemId)
-        {
-            Dictionary<int, int> attrDict = null;
-            itemTipsModel.TryGetJadeDynastyLegendAttr(itemId, out attrDict);
-            return attrDict;
-        }
-
-        bool IsCustomItem(int itemId)
-        {
-            if (!ItemConfig.Has(itemId))
-            {
-                return false;
-            }
-
-            return ItemConfig.Get(itemId).Effect1 == 220;
-        }
-
-        /// <summary>
-        /// 寰楀埌瑁呭鐨勮瘎鍒�
-        /// </summary>
-        /// <param name="itemId"></param>
-        /// <returns></returns>
-        private Dictionary<AttrEnum, float> curEquipAttrDict = new Dictionary<AttrEnum, float>(); //瀛樺偍褰撳墠瑁呭灞炴�у搴旂殑鏁板�� key 灞炴�� value 灞炴�у��
-        private int CalculateEquipScore(PackType type, int itemId, EquipSorceProperties properties)
-        {
-            var config = ItemConfig.Get(itemId);
-            if (config == null || !GeneralDefine.CompareEquipPlaces.Contains(config.EquipPlace))
-            {
-                return 0;
-            }
-
-            Equation.Instance.Clear();
-            curEquipAttrDict.Clear();
-
-            var GSProValueDict = EquipGSParamConfig.GetTagGsProValueDict(config.LV, config.ItemColor, config.StarLevel);
-            foreach (var key in properties.Keys)
-            {
-                var attrType = (AttrEnum)key;
-                switch (attrType)
-                {
-                    case AttrEnum.ATKSPEED:
-                    case AttrEnum.OnlyFinalHurt:
-                    case AttrEnum.PVPAtkBackHP:
-                        curEquipAttrDict.Add(attrType, properties[key]);
-                        break;
-                    default:
-                        if (GSProValueDict != null && GSProValueDict.ContainsKey(attrType))
-                        {
-                            var curProValue = properties[key] * GSProValueDict[attrType];
-                            curEquipAttrDict.Add(attrType, curProValue);
-                        }
-                        else
-                        {
-                            curEquipAttrDict.Add(attrType, properties[key]);
-                        }
-                        break;
-                }
-            }
-
-            foreach (var key in curEquipAttrDict.Keys)
-            {
-                var propertyConfig = PlayerPropertyConfig.Get((int)key);
-                if (propertyConfig != null)
-                {
-                    Equation.Instance.AddKeyValue(propertyConfig.Parameter, curEquipAttrDict[key]);
-                }
-            }
-
-            var gSParamModel = EquipGSParamConfig.GetGSModel(config.LV, config.ItemColor, config.StarLevel);
-            if (gSParamModel != null)
-            {
-                Equation.Instance.AddKeyValue("AtkSpeedC", gSParamModel.AtkSpeedC);
-            }
-            else
-            {
-                Equation.Instance.AddKeyValue("AtkSpeedC", 0);
-            }
-
-            if (type == PackType.Deleted)
-            {
-                type = GeneralDefine.GetPackTypeByItemType(config.Type);
-            }
-
-            switch (type)
-            {
-                case PackType.DogzEquip:
-                case PackType.DogzItem:
-                    return Equation.Instance.Eval<int>(dogzGSFormula);
-                case PackType.JadeDynastyItem:
-                case PackType.JadeDynastyEquip:
-                    return Equation.Instance.Eval<int>(jadeDynastyGSFormula);
-                default:
-                    return Equation.Instance.Eval<int>(normalGSFormula);
-            }
-        }
-
-        private void ConvertAttrId(int attrId, int attrValue, Dictionary<int, int> keyValues)
-        {
-            switch ((AttrEnum)attrId)
-            {
-                case AttrEnum.ATK:
-                    if (!keyValues.ContainsKey((int)AttrEnum.MinAtk))
-                    {
-                        keyValues.Add(((int)AttrEnum.MinAtk), attrValue);
-                    }
-                    else
-                    {
-                        keyValues[(int)AttrEnum.MinAtk] += attrValue;
-                    }
-
-                    if (!keyValues.ContainsKey((int)AttrEnum.MaxAtk))
-                    {
-                        keyValues.Add(((int)AttrEnum.MaxAtk), attrValue);
-                    }
-                    else
-                    {
-                        keyValues[(int)AttrEnum.MaxAtk] += attrValue;
-                    }
-                    break;
-                default:
-                    if (!keyValues.ContainsKey(attrId))
-                    {
-                        keyValues.Add(attrId, attrValue);
-                    }
-                    else
-                    {
-                        keyValues[attrId] += attrValue;
-                    }
-                    break;
-            }
-        }
-        #endregion
-
-        #region 涓荤晫闈㈢墿鍝佸脊妗嗗睍绀�
-        public event Action<PackType, string> GetPreciousItemEvent; //寰楀埌鐝嶅搧  value 鐗╁搧鐨勫疄渚婭D
-
-        public void RecommendItem(ItemModel item)
-        {
-            if (item.packType != PackType.Item)
-            {
-                return;
-            }
-
-            if (item.config.UseLV > PlayerDatas.Instance.baseData.LV)
-            {
-                return;
-            }
-
-            if (IsOverdue(item.guid, item.itemId, item.useDataDict))
-            {
-                return;
-            }
-
-            if (!preciousItemTypes.Contains(item.config.Type))
-            {
-                return;
-            }
-
-            if (!IsAbleToUse(item))
-            {
-                return;
-            }
-
-            if (GetPreciousItemEvent != null)
-            {
-                GetPreciousItemEvent(item.packType, item.guid);
-            }
-        }
-
-        bool IsAbleToUse(ItemModel item)
-        {
-            var windowSearch = WindowSearchConfig.Get(item.config.Jump);
-            if (windowSearch != null)
-            {
-                if (!FuncOpen.Instance.IsFuncOpen(windowSearch.Lv) && windowSearch.Lv != 0)
-                {
-                    return false;
-                }
-            }
-
-            if (pushItemIds.Contains(item.itemId))
-            {
-                var itemCnt = playerPack.GetItemCountByID(PackType.Item, item.itemId) - item.count;
-                if (itemCnt > 0)
-                {
-                    return false;
-                }
-                else
-                {
-                    if (item.preItemCount > 0)
-                    {
-                        return false;
-                    }
-                }
-            }
-
-            if (promptUseLimitDict.ContainsKey(item.itemId))
-            {
-                var playerLv = PlayerDatas.Instance.baseData.LV;
-                if (playerLv < promptUseLimitDict[item.itemId])
-                {
-                    return false;
-                }
-            }
-
-            ulong canUseCnt = 0;
-            if (playerPack.IsReachUseLimit(item.guid, out canUseCnt))
-            {
-                return false;
-            }
-
-            bool isBox = false;
-            bool isCanOpen = ModelCenter.Instance.GetModel<BoxGetItemModel>().CheckOpenBoxCondition(item.itemId, out isBox);
-            if (isBox)
-            {
-                if (!isCanOpen)
-                {
-                    return false;
-                }
-            }
-
-            if (trialModel.trialTokens.Contains(item.itemId))
-            {
-                if (!trialModel.IsAnySatisfyExchangeBetter(item.itemId))
-                {
-                    return false;
-                }
-            }
-
-            if (playerPack.CheckIsDrugById(item.itemId))
-            {
-                if (item.config.RealmLimit > PlayerDatas.Instance.baseData.realmLevel)
-                {
-                    return false;
-                }
-            }
-
-            switch (item.config.Type)
-            {
-                case 8:
-                    if (buffDatas.BastBuff(item.itemId))
-                    {
-                        return false;
-                    }
-                    break;
-                case 20:
-                    if (magicianModel.IsGodWeaponMaxLevelByItem(item.itemId))
-                    {
-                        return false;
-                    }
-                    break;
-                case 21:
-                    if (!mountDatas.IsHint(HorseEnum.HorseDan, item.itemId))
-                    {
-                        return false;
-                    }
-                    break;
-                case 22:
-                    if (!mountDatas.IsHint(HorseEnum.HorseStone, item.itemId))
-                    {
-                        return false;
-                    }
-                    break;
-                case 41:
-                    if (!mountDatas.IsHint(HorseEnum.HorseDebris, item.itemId))
-                    {
-                        return false;
-                    }
-                    break;
-                case 26:
-                    if (!petDatas.IsHint(PetEnum.PetDebris, item.itemId))
-                    {
-                        return false;
-                    }
-                    break;
-                case 27:
-                    if (!petDatas.IsHint(PetEnum.PetDan, item.itemId))
-                    {
-                        return false;
-                    }
-                    break;
-                case 28:
-                    if (!petDatas.IsHint(PetEnum.PetStone, item.itemId))
-                    {
-                        return false;
-                    }
-                    break;
-                case 25:
-                    if (!ModelCenter.Instance.GetModel<GemModel>().SatisfyBetter(item.itemId))
-                    {
-                        return false;
-                    }
-                    break;
-                case 39:
-                    if (!IsBetterWings(item))
-                    {
-                        return false;
-                    }
-                    break;
-                case 52:
-                    if (!strengthDatas.IsHint(item.itemId))
-                    {
-                        return false;
-                    }
-                    break;
-                case 127:
-                    var error = 0;
-                    bool isHaveMakeNum = ItemOperateUtility.Instance.CanUseItem(item.itemPlace, 1, out error);
-                    int remainNum = CrossServerOneVsOnePlayerInfo.Instance.GetDayRemainNum();
-                    if (!CrossServerOneVsOnePKSeason.Instance.isSatisfyMatch
-                        || remainNum > 0
-                        || !isHaveMakeNum)
-                    {
-                        return false;
-                    }
-                    break;
-                default:
-                    break;
-            }
-
-            switch (item.itemId)
-            {
-                case 951:
-                    if (!CheckIsExtendGrid(item.itemId))
-                    {
-                        return false;
-                    }
-                    break;
-                case 952:
-                    int willTime = HangUpSetModel.Instance.offlinePluginTime + item.config.EffectValueA1;
-                    if (HangUpSetModel.Instance.offlinePluginTime >= HangUpSetModel.Instance.maxOfflinePluginTime)
-                    {
-                        return false;
-                    }
-                    break;
-
-            }
-
-            return true;
-        }
-
-        private bool IsBetterWings(ItemModel item)
-        {
-            if (item == null)
-            {
-                return false;
-            }
-
-            var putModel = playerPack.GetItemByIndex(PackType.Equip, (int)RoleEquipType.Wing);
-            var singlePack = playerPack.GetSinglePack(PackType.Item);
-            if (singlePack == null)
-            {
-                return false;
-            }
-
-            int[] composeTypes = item.config.JumpComposeCondi;
-            bool isOpenCompose = false;
-            if (composeTypes != null && composeTypes.Length >= 3)
-            {
-                int first = composeTypes[0];
-                int second = composeTypes[1];
-                int third = composeTypes[2];
-                ComposeWinModel.ComposeThirdTypeData thirdTypeData = null;
-                composeModel.TryGetThirdTypeData(first, second, third, out thirdTypeData);
-                if (thirdTypeData != null)
-                {
-                    var itemCompound = thirdTypeData.itemCompound;
-                    if (itemCompound.levelNeed <= PlayerDatas.Instance.baseData.LV)
-                    {
-                        isOpenCompose = true;
-                    }
-                }
-            }
-
-            if (!isOpenCompose)
-            {
-                return false;
-            }
-
-            if (putModel != null && putModel.config.LV >= item.config.LV)
-            {
-                return false;
-            }
-
-            var itemModels = singlePack.GetItemsByType((int)ItemType.Wings);
-            if (itemModels != null)
-            {
-                for (int i = 0; i < itemModels.Count; i++)
-                {
-                    if (itemModels[i].config.JobLimit / 100 == PlayerDatas.Instance.baseData.Job)
-                    {
-                        if (itemModels[i].config.LV >= item.config.LV)
-                        {
-                            return false;
-                        }
-                    }
-                }
-            }
-
-            return true;
-        }
-
-        private bool CheckIsExtendGrid(int itemId)
-        {
-            SinglePack singlePack = playerPack.GetSinglePack(PackType.Item);
-            if (singlePack == null) return false;
-
-            int startLockIndex = singlePack.unlockedGridCount - GeneralDefine.initBagGridCount;
-            FuncConfigConfig _tagFuncModel = FuncConfigConfig.Get("OpenBagItem");
-            int haveCount = playerPack.GetItemCountByID(PackType.Item, itemId);
-            Equation.Instance.Clear();
-            Equation.Instance.AddKeyValue("index", startLockIndex + 1);
-            int needTool = Equation.Instance.Eval<int>(_tagFuncModel.Numerical2);
-            if (haveCount >= needTool)
-            {
-                return true;
-            }
-            else
-            {
-                return false;
-            }
-        }
-
-        public event Action<string> GetBetterEquipEvent; //寰楀埌鏇村ソ鐨勮澶� value 鐗╁搧鐨勫疄渚婭D
-
-        public void OnGetEquip(ItemModel item)
-        {
-            if (item == null)
-            {
-                return;
-            }
-
-            if (item.packType != PackType.Item && item.packType != PackType.JadeDynastyItem)
-            {
-                return;
-            }
-
-            if (!IsSameJob(item.config.JobLimit))
-            {
-                return;
-            }
-
-            int equipPlace = item.config.EquipPlace;
-            switch ((RoleEquipType)equipPlace)
-            {
-                case RoleEquipType.Weapon:
-                case RoleEquipType.Weapon2:
-                case RoleEquipType.Hat:
-                case RoleEquipType.Clothes:
-                case RoleEquipType.Belt:
-                case RoleEquipType.Trousers:
-                case RoleEquipType.Shoes:
-                case RoleEquipType.Neck:
-                case RoleEquipType.FairyCan:
-                case RoleEquipType.FairyCan2:
-                case RoleEquipType.Wing:
-                case RoleEquipType.SpiritAnimal:
-                case RoleEquipType.JadeDynasty_Cloak:
-                case RoleEquipType.JadeDynasty_FaceMask:
-                case RoleEquipType.JadeDynasty_Glove1:
-                case RoleEquipType.JadeDynasty_Glove2:
-                case RoleEquipType.JadeDynasty_Ruyi:
-                case RoleEquipType.JadeDynasty_Pendant:
-                case RoleEquipType.JadeDynasty_Ring1:
-                case RoleEquipType.JadeDynasty_Ring2:
-                case RoleEquipType.JadeDynasty_Sword1:
-                case RoleEquipType.JadeDynasty_Sword2:
-                case RoleEquipType.JadeDynasty_Sword3:
-                case RoleEquipType.JadeDynasty_Sword4:
-                    if (betterEquipExceptDungeonDict.ContainsKey(PlayerDatas.Instance.baseData.MapID))
-                    {
-                        if (betterEquipExceptDungeonDict[PlayerDatas.Instance.baseData.MapID].Contains(item.itemId))
-                        {
-                            return;
-                        }
-                    }
-                    SetGetBetterEquipEvent(item);
-                    break;
-            }
-        }
-
-        bool IsSameJob(int jobLimit)
-        {
-            return jobLimit == 0 || jobLimit / 100 == PlayerDatas.Instance.baseData.Job;
-        }
-
-        private void SetGetBetterEquipEvent(ItemModel model)
-        {
-            List<int> itemEffectTime = model.GetUseDataModel((int)ItemUseDataKey.createTime);
-            if (itemEffectTime != null)
-            {
-                if (itemEffectTime[0] != 0)
-                {
-                    ItemCDCool cool = KnapsackTimeCDMgr.Instance.GetItemCoolById(model.guid);
-                    double remainTime = 0;
-                    if (cool != null)
-                    {
-                        remainTime = cool.GetRemainTime();
-                    }
-
-                    if (remainTime >= 0 && remainTime < 120 && model.config.ExpireTime > 0)
-                    {
-                        return;
-                    }
-                }
-            }
-
-            int isFightUp = IsFightUp(model.itemId, model.equipScore);
-            int equipPlace = model.config.EquipPlace;
-            if (isFightUp == 1)
-            {
-                switch (equipPlace)
-                {
-                    case 9:
-                        break;
-                    default:
-                        if (model.packType == PackType.Item)
-                        {
-                            var equipItemModel = playerPack.GetItemByIndex(PackType.Equip, model.config.EquipPlace);
-                            if (PlayerDatas.Instance.baseData.LV >= 200)
-                            {
-                                if (model.equipPlace > (int)RoleEquipType.Weapon2 && model.equipPlace < (int)RoleEquipType.Neck)
-                                {
-                                    if (equipItemModel != null && equipItemModel.config.ItemColor > model.config.ItemColor)
-                                    {
-                                        return;
-                                    }
-                                }
-                            }
-                        }
-                        break;
-                }
-
-                if (GetBetterEquipEvent != null)
-                {
-                    GetBetterEquipEvent(model.guid);
-                }
-
-            }
-        }
-
-        public event Action<PackType, string> PickItemEvent; //鎹¤捣鐨勭墿鍝�
-
-        public void RefreshPickItem(PackType type, string guid)
-        {
-            if (type != PackType.Item) return;
-
-            if (PickItemEvent != null)
-            {
-                PickItemEvent(type, guid);
-            }
-        }
-
-        Dictionary<int, ItemModel> RealmBetterDict = new Dictionary<int, ItemModel>();
-        public Dictionary<int, ItemModel> CheckBetterEquipByRealm()
-        {
-            RealmBetterDict.Clear();
-            SinglePack singlePack = playerPack.GetSinglePack(PackType.Item);
-            if (singlePack == null) return RealmBetterDict;
-
-            int realmLv = PlayerDatas.Instance.baseData.realmLevel;
-            Dictionary<int, ItemModel> pairs = singlePack.GetAllItems();
-            foreach (var model in pairs.Values)
-            {
-                if (model.config.EquipPlace > 0
-                    && model.config.EquipPlace != (int)RoleEquipType.SpiritAnimal
-                    && model.config.RealmLimit <= realmLv
-                    && !IsOverdue(model.guid, model.itemId, model.useDataDict)
-                    && IsFightUp(model.itemId, model.equipScore) == 1)
-                {
-                    if (!RealmBetterDict.ContainsKey(model.equipPlace))
-                    {
-                        RealmBetterDict.Add(model.equipPlace, model);
-                    }
-                    else
-                    {
-                        if (model.equipScore > RealmBetterDict[model.equipPlace].equipScore)
-                        {
-                            RealmBetterDict[model.equipPlace] = model;
-                        }
-                    }
-                }
-            }
-            return RealmBetterDict;
-        }
-
-        List<ItemModel> RealmDruglist = new List<ItemModel>();
-        public List<ItemModel> GetDruglistByRealm()
-        {
-            RealmDruglist.Clear();
-            SinglePack singlePack = playerPack.GetSinglePack(PackType.Item);
-            if (singlePack == null) return RealmDruglist;
-
-            int realmLv = PlayerDatas.Instance.baseData.realmLevel;
-            Dictionary<int, ItemModel> pairs = singlePack.GetAllItems();
-            foreach (var model in pairs.Values)
-            {
-                if (playerPack.CheckIsDrugById(model.itemId))
-                {
-                    AttrFruitConfig fruitConfig = AttrFruitConfig.Get(model.itemId);
-                    if (!playerPack.IsReachMaxUseDrug(fruitConfig)
-                        && model.config.RealmLimit <= realmLv)
-                    {
-                        RealmDruglist.Add(model);
-                    }
-                }
-            }
-            return RealmDruglist;
-        }
-        #endregion
-
-        #region 鐗╁搧澶勪簬CD涓殑閫昏緫澶勭悊
-
-        private List<string> itemEffectTimelist = new List<string>(); //key 鐗╁搧瀹炰緥ID
-        /// <summary>
-        /// 鐗╁搧浣跨敤鏃堕棿闄愬埗
-        /// </summary>
-        public void SetItemEffectCDTime(string guid, int itemID, int getTime, int serverSurplusTime)
-        {
-            double time = GetTimeOffest(TimeUtility.GetTime((uint)getTime));
-            if (time < 0)
-            {
-                time = 0;
-            }
-
-            ItemConfig itemConfig = ItemConfig.Get(itemID);
-            if (time >= itemConfig.ExpireTime)
-            {
-                KnapsackTimeCDMgr.Instance.UnRegister(guid);
-                return;
-            }
-            double remainTime = (serverSurplusTime > 0 ? serverSurplusTime : itemConfig.ExpireTime) - time;
-            KnapsackTimeCDMgr.Instance.Register(guid, itemID, remainTime);
-        }
-
-        public double GetTimeOffest(DateTime getTime)
-        {
-            DebugEx.Log("鐜板湪鏃堕棿锛�" + TimeUtility.ServerNow + "鑾峰緱鏃堕棿:" + getTime);
-            //TimeUtility.SyncServerTime();
-            TimeSpan t = TimeUtility.ServerNow - getTime;
-            DebugEx.Log("鏃堕棿宸細" + t.TotalSeconds);
-            return t.TotalSeconds;
-        }
-
-        #endregion
-
-        #region 璁剧疆鍙互涓�閿嚭鍞殑鐗╁搧鏁版嵁
-
-        private int playerLv;
-        private Dictionary<int, List<ItemModel>> _lifePotionDict = new Dictionary<int, List<ItemModel>>(); //key 鑽按绛夌骇
-        private List<int> _sellItemScorelist = new List<int>();
-        private Dictionary<int, Dictionary<int, List<ItemModel>>> _sameIndexEquipDict = new Dictionary<int, Dictionary<int, List<ItemModel>>>();  //瀛樺偍鐩稿悓瑁呭浣嶇殑瑁呭
-                                                                                                                                                  // private  _sameEquipScoreDict = new Dictionary<int, List<ItemModel>>(); //瀛樺偍鐩稿悓ID涓浉鍚岃澶囪瘎鍒嗙殑瑁呭
-        private Dictionary<int, ItemModel> _packModelDict;
-        private List<ItemModel> _sellItemlist = new List<ItemModel>();
-
-        public List<ItemModel> GetSellItemList()
-        {
-            GetOneKeySellModel();
-            _sellItemlist.Sort(SetSellItemOrder);
-            return _sellItemlist;
-        }
-
-        public int SetSellItemOrder(ItemModel startModel, ItemModel endModel)
-        {
-            bool startIsEquip = IsEquip(startModel);
-            bool endIsEquip = IsEquip(endModel);
-            if (startIsEquip.CompareTo(endIsEquip) != 0) return -startIsEquip.CompareTo(endIsEquip);
-            int order1 = startModel.config.Type;
-            int order2 = endModel.config.Type;
-            if (order1.CompareTo(order2) != 0) return order1.CompareTo(order2);
-            int color1 = startModel.config.ItemColor;
-            int color2 = endModel.config.ItemColor;
-            if (color1.CompareTo(color2) != 0) return -color1.CompareTo(color2);
-            int code1 = startModel.itemId;
-            int code2 = endModel.itemId;
-            if (code1.CompareTo(code2) != 0) return -code1.CompareTo(code2);
-            return 0;
-        }
-
-        public bool IsEquip(ItemModel model)
-        {
-            return model.config.EquipPlace != 0;
-        }
-
-        public void GetOneKeySellModel()
-        {
-            SinglePack singlePack = playerPack.GetSinglePack(PackType.Item);
-            if (singlePack == null)
-                return;
-
-            _sellItemlist.Clear();
-            _lifePotionDict.Clear();
-            _sameIndexEquipDict.Clear();
-            _sellItemScorelist.Clear();
-            playerLv = PlayerDatas.Instance.baseData.LV;
-            _packModelDict = singlePack.GetAllItems();
-            foreach (var key in _packModelDict.Keys)
-            {
-                GetCanSellEquipList(_packModelDict[key]);
-                ItemModel itemModel = _packModelDict[key];
-                if (drugIDs.Contains(itemModel.itemId))
-                {
-                    if (!_lifePotionDict.ContainsKey(itemModel.config.LV))
-                    {
-                        List<ItemModel> modellist = new List<ItemModel>();
-                        modellist.Add(itemModel);
-                        _lifePotionDict.Add(itemModel.config.LV, modellist);
-                    }
-                    else
-                    {
-                        _lifePotionDict[itemModel.config.LV].Add(itemModel);
-                    }
-                }
-            }
-
-            #region 寰楀埌鍙互鍑哄敭鐨勮澶�
-            foreach (var key in _sameIndexEquipDict.Keys)
-            {
-                _sellItemScorelist = _sameIndexEquipDict[key].Keys.ToList();
-                _sellItemScorelist.Sort();
-                if (_sellItemScorelist.Count > 0)
-                {
-                    int score = 0;
-                    int curJob = PlayerDatas.Instance.baseData.Job;
-                    for (score = _sellItemScorelist.Count - 1; score > -1; score--)
-                    {
-                        SinglePack equipPack = playerPack.GetSinglePack(PackType.Equip);
-                        ItemModel model = null;
-                        if (equipPack != null)
-                        {
-                            model = equipPack.GetItemByIndex(key);
-                        }
-
-                        List<ItemModel> modellist = _sameIndexEquipDict[key][_sellItemScorelist[score]];
-                        int i = 0;
-                        bool remainBetter = true;
-                        for (i = 0; i < modellist.Count; i++)
-                        {
-                            double joblimit = Math.Floor((double)modellist[i].config.JobLimit / 100);
-                            if (model != null)
-                            {
-                                if (remainBetter)
-                                {
-                                    if (model.equipScore < _sellItemScorelist[score] && curJob == joblimit)
-                                    {
-                                        _sameIndexEquipDict[key].Remove(_sellItemScorelist[score]);
-                                        remainBetter = false;
-                                        break;
-                                    }
-                                }
-
-                            }
-                            else
-                            {
-                                if (curJob == joblimit)
-                                {
-                                    if (remainBetter)
-                                    {
-                                        _sameIndexEquipDict[key].Remove(_sellItemScorelist[score]);
-                                        remainBetter = false;
-                                        break;
-                                    }
-                                }
-                            }
-                        }
-
-                        if (!remainBetter)
-                        {
-                            break;
-                        }
-
-                    }
-                    int j = 0;
-                    for (j = 0; j < _sellItemScorelist.Count; j++)
-                    {
-
-                        if (_sameIndexEquipDict[key].ContainsKey(_sellItemScorelist[j]))
-                        {
-                            int k = 0;
-                            List<ItemModel> sellModlelist = _sameIndexEquipDict[key][_sellItemScorelist[j]];
-                            for (k = 0; k < sellModlelist.Count; k++)
-                            {
-                                _sellItemlist.Add(sellModlelist[k]);
-                            }
-                        }
-                    }
-
-                }
-
-            }
-            #endregion
-
-            List<int> drugLvlist = new List<int>();
-            drugLvlist.AddRange(_lifePotionDict.Keys.ToList());
-            drugLvlist.Sort();
-            for (int i = drugLvlist.Count - 1; i > -1; i--)
-            {
-                if (drugLvlist[i] > playerLv)
-                {
-                    _lifePotionDict.Remove(drugLvlist[i]);
-                }
-                else
-                {
-                    _lifePotionDict.Remove(drugLvlist[i]);
-                    break;
-                }
-            }
-
-            foreach (var list in _lifePotionDict.Values)
-            {
-                for (int i = 0; i < list.Count; i++)
-                {
-                    _sellItemlist.Add(list[i]);
-                }
-
-            }
-        }
-
-
-        //寰楀埌婊¤冻鍑哄敭鏉′欢鐨勮澶囧垪琛�
-        public void GetCanSellEquipList(ItemModel model)
-        {
-
-            if (model.config.EquipPlace == 0 || !onekeySellTypes.Contains(model.config.Type))
-                return;
-
-            Dictionary<int, List<ItemModel>> sameScoreDict;
-            List<ItemModel> sameScorelist;
-
-            if (model.config.ItemColor < 3)
-            {
-                if (!_sameIndexEquipDict.ContainsKey(model.config.EquipPlace))
-                {
-                    sameScoreDict = new Dictionary<int, List<ItemModel>>();
-                    sameScorelist = new List<ItemModel>();
-                    sameScorelist.Add(model);
-                    sameScoreDict.Add(model.equipScore, sameScorelist);
-                    _sameIndexEquipDict.Add(model.config.EquipPlace, sameScoreDict);
-
-                }
-                else
-                {
-                    if (_sameIndexEquipDict[model.config.EquipPlace].ContainsKey(model.equipScore))
-                    {
-                        _sameIndexEquipDict[model.config.EquipPlace][model.equipScore].Add(model);
-                    }
-                    else
-                    {
-                        sameScorelist = new List<ItemModel>();
-                        sameScorelist.Add(model);
-                        _sameIndexEquipDict[model.config.EquipPlace].Add(model.equipScore, sameScorelist);
-                    }
-
-                }
-            }
-
-
-        }
-
-        #endregion
-
-        #region 鍙戦�佽姹�
-        /// <summary>
-        /// 涓�閿嚭鍞墿鍝佺殑璇锋眰
-        /// </summary>
-        /// <param name="_oneKeySelllist"></param>
-        public void SendOneKeySellQuest(List<ItemModel> _oneKeySelllist)
-        {
-            if (!isPackResetOk || SettingEffectMgr.Instance.isStartOneKeySell) return;
-
-            SettingEffectMgr.Instance.isStartOneKeySell = true;
-            byte[] itemIndexs = new byte[_oneKeySelllist.Count];
-            int i = 0;
-            for (i = 0; i < _oneKeySelllist.Count; i++)
-            {
-                itemIndexs[i] = (byte)_oneKeySelllist[i].itemPlace;
-            }
-            CA311_tagCMSellItem sellItem = new CA311_tagCMSellItem();
-            sellItem.PackType = (int)PackType.Item;
-            sellItem.Count = (byte)_oneKeySelllist.Count;
-            sellItem.ItemIndex = itemIndexs;
-            GameNetSystem.Instance.SendInfo(sellItem);
-        }
-
-        /// <summary>
-        /// 鏁寸悊鍖呰9鐗╁搧
-        /// </summary>
-        /// <param name="type"></param>
-        public bool isPackResetOk { get; set; }
-        public void SendPackResetQuest(PackType type)
-        {
-            if (lookLineIndex > -1)
-            {
-                SetLookIndex(null);
-            }
-
-            if (KnapSackWin.titleType == KnapsackFuncTitle.bag)
-            {
-                playerPack.isPlayBetterEquipEffect = true;
-            }
-
-            SinglePack singlePack = playerPack.GetSinglePack(type);
-            if (singlePack != null)
-            {
-                C070F_tagCItemPackReset packReset = new C070F_tagCItemPackReset();
-                packReset.Type = (byte)type;
-                packReset.ItemBeginIndex = 0;
-                packReset.ItemEndIndex = (ushort)(singlePack.unlockedGridCount - 1);
-                GameNetSystem.Instance.SendInfo(packReset); //鏁寸悊鐗╁搧
-                if (type == PackType.Item)
-                {
-                    isPackResetOk = false;
-                }
-            }
-        }
-        #endregion
-
-        #region 鏌ョ湅鏌愪釜浣嶇疆鐨勭墿鍝�
-        public event Action lookEquipEvent;
-        private int _lookLineIndex = -1;
-        public int lookLineIndex { get { return _lookLineIndex; } private set { _lookLineIndex = value; } }
-
-        public string lookItemGUID { get; private set; }
-
-        public void SetLookIndex(string guid, int singleRowCount = 5)
-        {
-
-            if (string.IsNullOrEmpty(guid) || guid == "")
-            {
-                lookLineIndex = -1;
-            }
-            else
-            {
-                int index = playerPack.GetItemByGuid(guid).itemPlace;
-                lookLineIndex = index / singleRowCount;
-                lookItemGUID = guid;
-            }
-
-            if (lookEquipEvent != null)
-            {
-                lookEquipEvent();
-            }
-
-        }
-        #endregion
-
-        #region 鍒ゆ柇鏄惁鏈夋洿濂界殑瑁呭鏇挎崲
-        /// <summary>
-        /// 杩囨护瑁呭浣嶅垽鏂�
-        /// </summary>
-        /// <param name="ignoreType"></param>
-        /// <returns></returns>
-        public bool CheckBetterEquip(RoleEquipType ignoreType)
-        {
-            SinglePack singlePack = playerPack.GetSinglePack(PackType.Equip);
-            if (singlePack != null)
-            {
-                Dictionary<int, ItemModel> putOnDic = singlePack.GetAllItems();
-                foreach (var key in putOnDic.Keys)
-                {
-                    if ((RoleEquipType)key == ignoreType)
-                    {
-                        continue;
-                    }
-                    if (key < 13)
-                    {
-                        List<ItemModel> itemlist = GetSameEquipPlacelist(key);
-                        int i = 0;
-                        for (i = 0; i < itemlist.Count; i++)
-                        {
-                            bool isOverdue = IsOverdue(itemlist[i].guid, itemlist[i].itemId, itemlist[i].useDataDict);
-                            bool isRealm = PlayerDatas.Instance.baseData.realmLevel >= itemlist[i].config.RealmLimit ? true : false;
-                            if (itemlist[i].equipScore > putOnDic[key].equipScore && !isOverdue && isRealm)
-                            {
-                                return true;
-                            }
-                        }
-                    }
-                }
-            }
-            else
-            {
-                int i = 1;
-                for (i = 1; i < 13; i++)
-                {
-                    List<ItemModel> itemlist = GetSameEquipPlacelist(i);
-                    if (itemlist.Count > 0)
-                    {
-                        return true;
-                    }
-                }
-            }
-            return false;
-        }
-
-        private List<ItemModel> GetSameEquipPlacelist(int equipPlace)
-        {
-            List<ItemModel> modellist = new List<ItemModel>();
-            Dictionary<int, ItemModel> dic = null;
-            SinglePack singlePack = playerPack.GetSinglePack(PackType.Item);
-            if (singlePack != null)
-            {
-                dic = singlePack.GetAllItems();
-                foreach (var model in dic.Values)
-                {
-                    if (model.config.EquipPlace == equipPlace)
-                    {
-                        double equipJob = Math.Floor((double)model.config.JobLimit / 100);
-                        if (equipJob == 0 || equipJob == PlayerDatas.Instance.baseData.Job)
-                        {
-                            modellist.Add(model);
-                        }
-                    }
-                }
-            }
-            return modellist;
-        }
-
-        /// <summary>
-        /// 鑾峰彇瑁呭璇勫垎鏈�楂樺彲鎻愬崌鎴樺姏鐨勮澶�
-        /// </summary>
-        /// <param name="_places"></param>
-        /// <returns></returns>
-        public string GetHighestScoreEquipByPlace(int equipPlace)
-        {
-            var itemPackage = playerPack.GetSinglePack(PackType.Item);
-            var allItems = itemPackage.GetAllItems();
-            ItemModel putModel = playerPack.GetItemByIndex(PackType.Equip, equipPlace);
-            equipPlace = (equipPlace == 9 || equipPlace == 10) ? 9 : equipPlace;
-            var guid = string.Empty;
-            var equips = new List<string>();
-            var score = putModel == null ? 0 : putModel.equipScore;
-            var job = PlayerDatas.Instance.baseData.Job;
-            foreach (var item in allItems.Values)
-            {
-                if (item.config.EquipPlace == equipPlace)
-                {
-                    if (!IsOverdue(item.guid, item.itemId, item.useDataDict)
-                       && (item.config.JobLimit == 0 || (item.config.JobLimit / 100) == job) && item.equipScore > score)
-                    {
-                        guid = item.guid;
-                        score = item.equipScore;
-                    }
-                }
-            }
-
-            return guid;
-        }
-        #endregion
-
-        #region 鑳屽寘鏁寸悊鍚庡ソ鐨勫悓绫诲瀷鏈�濂界殑瑁呭
-        Dictionary<int, Dictionary<int, ItemModel>> itemModelDict = new Dictionary<int, Dictionary<int, ItemModel>>();  // key1 瑁呭浣嶇疆绱㈠紩 key2 鑳屽寘浣嶇疆绱㈠紩
-
-        public void ClearSortedBetterEquip()
-        {
-            itemModelDict.Clear();
-        }
-
-        public void SetBagSortBetterEquipList(ItemModel itemModel)
-        {
-            if (itemModel == null || itemModel.packType != PackType.Item) return;
-
-            if (!IsCanPutOn(itemModel)) return;
-
-            int equipPlace = itemModel.config.EquipPlace;
-            if (!itemModelDict.ContainsKey(equipPlace))
-            {
-                Dictionary<int, ItemModel> dict = new Dictionary<int, ItemModel>();
-                if (IsFightUp(itemModel.itemId, itemModel.equipScore) == 1)
-                {
-                    dict.Add(itemModel.itemPlace, itemModel);
-                    itemModelDict.Add(equipPlace, dict);
-                }
-            }
-            else
-            {
-                if (IsFightUp(itemModel.itemId, itemModel.equipScore) == 1)
-                {
-                    itemModelDict[equipPlace].Add(itemModel.itemPlace, itemModel);
-                }
-            }
-
-        }
-
-        public ItemModel GetBagSortBetterEquip(int equipPlace, int index)
-        {
-            ItemModel itemModel = null;
-            if (itemModelDict.ContainsKey(equipPlace))
-            {
-                itemModelDict[equipPlace].TryGetValue(index, out itemModel);
-            }
-            return itemModel;
-        }
-
-        public bool IsCanPutOn(ItemModel itemModel)
-        {
-            double equipJob = Math.Floor((double)itemModel.config.JobLimit / 100);
-            int playerJob = PlayerDatas.Instance.baseData.Job;
-            int equipPlace = itemModel.config.EquipPlace;
-            if (equipPlace == 0 || equipPlace > 12) return false;
-            if (equipJob != 0 && equipJob != playerJob) return false;
-
-            List<int> putOnlimitList = itemModel.GetUseDataModel((int)ItemUseDataKey.cancelUseLimit);
-            if (putOnlimitList != null)
-            {
-                if (putOnlimitList[0] == 1)
-                {
-                    return true;
-                }
-            }
-
-            return CheckPutOnRealm(itemModel.config);
-        }
-
-        private bool CheckPutOnRealm(ItemConfig config)
-        {
-            var _realmLv = config.RealmLimit;
-            if (PlayerDatas.Instance.baseData.realmLevel < _realmLv)
-            {
-                return false;
-            }
-            return true;
-        }
-        #endregion
-
-        #region 寰楀埌鐗╁搧鐨勫搧璐ㄩ鑹�
-        private Dictionary<int, int> wingRefineQualityDict;
-        private int[] wingsQualitys;
-        private int[] wingsRefineExps;
-        public int GetItemQuality(int itemId, Dictionary<int, List<int>> useDataDic = null)
-        {
-            wingsQualitys = null;
-            wingsRefineExps = null;
-            ItemConfig itemConfig = ItemConfig.Get(itemId);
-            wingRefineQualityDict = WingRefineAttrConfig.GetWingsQualityModel(itemConfig.LV);
-            if (useDataDic != null)
-            {
-                if (useDataDic.ContainsKey(42) && wingRefineQualityDict != null)
-                {
-                    wingsQualitys = wingRefineQualityDict.Keys.ToArray();
-                    wingsRefineExps = wingRefineQualityDict.Values.ToArray();
-                    int i = 0;
-                    for (i = wingsRefineExps.Length - 1; i > -1; i--)
-                    {
-                        if (useDataDic[42][0] >= wingsRefineExps[i])
-                        {
-                            return wingsQualitys[i];
-                        }
-                    }
-                }
-            }
-            return itemConfig.ItemColor;
-        }
-        #endregion
-
-        //璁剧疆鐜╁璐у竵鏄剧ず
-        public string OnChangeCoinsUnit(ulong value)
-        {
-
-            string strCoins = value.ToString();
-            if (strCoins.Length > 4 && strCoins.Length < 9)
-            {
-                double coins = Math.Floor((double)value / 10000);
-                strCoins = coins + Language.Get("KnapS114");
-            }
-            else if (strCoins.Length >= 9 && strCoins.Length < 13)
-            {
-                double coins = Math.Floor((double)value / 100000000);
-                strCoins = coins + Language.Get("KnapS115");
-            }
-            else if (strCoins.Length >= 13 && strCoins.Length < 19)
-            {
-                double coins = Math.Floor((double)value / 1000000000000);
-                strCoins = coins + Language.Get("KnapS126");
-            }
-            else if (strCoins.Length >= 19)
-            {
-                ServerTipDetails.DisplayNormalTip(Language.Get("KnapS127"));
-            }
-            return strCoins;
-        }
-
-        /// <summary>
-        /// 瑁呭鏄惁鍙互鎻愬崌鎴樺姏
-        /// </summary>
-        /// <param name="_itemID"></param>
-        /// <param name="_score"></param>
-        /// <returns></returns>
-        public int IsFightUp(int _itemID, int _score)//-1浣庣骇锛�0涓嶆槸鏈亴涓氾紝1鏇村ソ
-        {
-            ItemConfig chinItemModel = ItemConfig.Get(_itemID);
-            if (chinItemModel != null)
-            {
-                ItemModel putOnModel = null;
-                switch ((RoleEquipType)chinItemModel.EquipPlace)
-                {
-                    case RoleEquipType.Clothes:
-                    case RoleEquipType.FairyCan:
-                    case RoleEquipType.Belt:
-                    case RoleEquipType.Hat:
-                    case RoleEquipType.Neck:
-                    case RoleEquipType.Shoes:
-                    case RoleEquipType.SpiritAnimal:
-                    case RoleEquipType.Trousers:
-                    case RoleEquipType.Weapon:
-                    case RoleEquipType.Weapon2:
-                    case RoleEquipType.Wing:
-                        putOnModel = playerPack.GetItemByIndex(PackType.Equip, chinItemModel.EquipPlace);
-                        break;
-                    case RoleEquipType.JadeDynasty_Cloak:
-                    case RoleEquipType.JadeDynasty_FaceMask:
-                    case RoleEquipType.JadeDynasty_Glove1:
-                    case RoleEquipType.JadeDynasty_Pendant:
-                    case RoleEquipType.JadeDynasty_Ring1:
-                    case RoleEquipType.JadeDynasty_Ruyi:
-                    case RoleEquipType.JadeDynasty_Sword1:
-                    case RoleEquipType.JadeDynasty_Sword2:
-                    case RoleEquipType.JadeDynasty_Sword3:
-                    case RoleEquipType.JadeDynasty_Sword4:
-                        putOnModel = playerPack.GetItemByIndex(PackType.JadeDynastyEquip, chinItemModel.EquipPlace);
-                        break;
-                    default:
-                        return 0;
-                }
-
-                ItemModel putOnModel2 = null;
-                switch ((RoleEquipType)chinItemModel.EquipPlace)
-                {
-                    case RoleEquipType.FairyCan:
-                        putOnModel2 = playerPack.GetItemByIndex(PackType.Equip, (int)RoleEquipType.FairyCan2);
-                        break;
-                    case RoleEquipType.JadeDynasty_Glove1:
-                        putOnModel2 = playerPack.GetItemByIndex(PackType.JadeDynastyEquip, (int)RoleEquipType.JadeDynasty_Glove2);
-                        break;
-                    case RoleEquipType.JadeDynasty_Ring1:
-                        putOnModel2 = playerPack.GetItemByIndex(PackType.JadeDynastyEquip, (int)RoleEquipType.JadeDynasty_Ring2);
-                        break;
-                }
-
-                switch ((RoleEquipType)chinItemModel.EquipPlace)
-                {
-                    case RoleEquipType.FairyCan:
-                    case RoleEquipType.JadeDynasty_Glove1:
-                    case RoleEquipType.JadeDynasty_Ring1:
-                        if (putOnModel2 != null)
-                        {
-                            if (putOnModel != null)
-                            {
-                                if (putOnModel2.equipScore < putOnModel.equipScore)
-                                {
-                                    putOnModel = putOnModel2;
-                                }
-                            }
-                        }
-                        else
-                        {
-                            putOnModel = putOnModel2;
-                        }
-                        break;
-                }
-
-                int equipScore1 = 0;
-                if (putOnModel != null)
-                {
-                    equipScore1 = (int)putOnModel.equipScore;
-                }
-
-                int playerJob = PlayerDatas.Instance.baseData.Job;
-
-                if (playerJob == Math.Floor((double)chinItemModel.JobLimit / 100) || chinItemModel.JobLimit == 0)
-                {
-                    if (equipScore1 > _score)
-                        return -1;
-                    else if (equipScore1 < _score)
-                        return 1;
-                    else
-                        return 0;
-                }
-                else
-                {
-                    return 0;
-                }
-            }
-            return 0;
-        }
-
-        #region 鐗╁搧鏄惁杩囨湡
-        public bool IsOverdue(string guid, int itemId, Dictionary<int, List<int>> useDataDict = null)
-        {
-            ItemConfig itemConfig = ItemConfig.Get(itemId);
-            if (itemConfig == null) return false;
-
-            if (itemConfig.ExpireTime > 0)
-            {
-                ItemCDCool cool = KnapsackTimeCDMgr.Instance.GetItemCoolById(guid);
-                switch ((EquipReduceType)itemConfig.EndureReduceType)
-                {
-                    case EquipReduceType.Def_EquipReduceType_Time:
-                        if (guid != "")
-                        {
-                            List<int> itemEffectTime = null;
-                            if (useDataDict != null)
-                            {
-                                if (useDataDict.ContainsKey((int)ItemUseDataKey.createTime))
-                                {
-                                    itemEffectTime = useDataDict[(int)ItemUseDataKey.createTime];
-                                }
-                            }
-
-                            if (itemEffectTime != null && itemEffectTime[0] != 0)
-                            {
-                                if (cool == null || cool.GetRemainTime() <= 0)
-                                {
-                                    return true;
-                                }
-                            }
-                        }
-                        break;
-
-                    case EquipReduceType.Def_EquipReduceType_RTimeItem:
-                        if (guid != "")
-                        {
-                            if (cool == null || cool.GetRemainTime() <= 0)
-                            {
-                                return true;
-                            }
-                        }
-                        break;
-
-                }
-            }
-
-            return false;
-        }
-        #endregion
-    }
-}
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using LitJson;
+using UnityEngine;
+
+namespace Snxxz.UI
+{
+    [XLua.LuaCallCSharp]
+    public class ItemLogicUtility : Singleton<ItemLogicUtility>
+    {
+        private string jadeDynastyGSFormula;
+        private string dogzGSFormula;
+        private string normalGSFormula;
+
+        private int[] preciousItemTypes;
+        private int[] drugIDs;
+        private int[] onekeySellTypes;
+        private int[] pushItemIds;
+        private int[] pushBuffTypeIds;
+
+        private List<int> equipBaseProperties = new List<int>();
+        private Dictionary<int, int> promptUseLimitDict;
+        private Dictionary<int, List<int>> betterEquipExceptDungeonDict;
+
+        PlayerPackModel playerPack { get { return ModelCenter.Instance.GetModel<PlayerPackModel>(); } }
+        ItemTipsModel itemTipsModel { get { return ModelCenter.Instance.GetModel<ItemTipsModel>(); } }
+        PlayerBuffDatas buffDatas { get { return ModelCenter.Instance.GetModel<PlayerBuffDatas>(); } }
+        PlayerMountDatas mountDatas { get { return ModelCenter.Instance.GetModel<PlayerMountDatas>(); } }
+        PlayerPetDatas petDatas { get { return ModelCenter.Instance.GetModel<PlayerPetDatas>(); } }
+        PlayerStrengthengDatas strengthDatas { get { return ModelCenter.Instance.GetModel<PlayerStrengthengDatas>(); } }
+        MagicianModel magicianModel { get { return ModelCenter.Instance.GetModel<MagicianModel>(); } }
+        TrialDungeonModel trialModel { get { return ModelCenter.Instance.GetModel<TrialDungeonModel>(); } }
+        ComposeWinModel composeModel { get { return ModelCenter.Instance.GetModel<ComposeWinModel>(); } }
+
+        public void Init()
+        {
+            var GSFormulaConfig = FuncConfigConfig.Get("EquipGSFormula");
+            jadeDynastyGSFormula = GSFormulaConfig.Numerical4;
+            dogzGSFormula = GSFormulaConfig.Numerical3;
+            normalGSFormula = GSFormulaConfig.Numerical1;
+
+            var baseAttr = JsonMapper.ToObject(GSFormulaConfig.Numerical2);
+            if (baseAttr.IsArray)
+            {
+                for (int i = 0; i < baseAttr.Count; i++)
+                {
+                    equipBaseProperties.Add(int.Parse(baseAttr[i].ToString()));
+                }
+            }
+
+            preciousItemTypes = ConfigParse.GetMultipleStr<int>(FuncConfigConfig.Get("ItemPush").Numerical1);
+            promptUseLimitDict = ConfigParse.GetDic<int, int>(FuncConfigConfig.Get("NoPromptUsetItem").Numerical1);
+
+            drugIDs = ConfigParse.GetMultipleStr<int>(FuncConfigConfig.Get("LifePotionlist").Numerical1);
+            onekeySellTypes = ConfigParse.GetMultipleStr<int>(FuncConfigConfig.Get("OneKeySellItemType").Numerical1);
+
+            pushItemIds = ConfigParse.GetMultipleStr<int>(FuncConfigConfig.Get("IntroductionItem").Numerical1);
+            pushBuffTypeIds = ConfigParse.GetMultipleStr<int>(FuncConfigConfig.Get("IntroductionItem").Numerical2);
+
+            betterEquipExceptDungeonDict = new Dictionary<int, List<int>>();
+            var excEquipData = JsonMapper.ToObject(FuncConfigConfig.Get("GoodItemDungeon").Numerical1);
+            foreach (var dungeonId in excEquipData.Keys)
+            {
+                var itemIds = new List<int>();
+                betterEquipExceptDungeonDict.Add(int.Parse(dungeonId), itemIds);
+                for (var i = 0; i < excEquipData[dungeonId].Count; i++)
+                {
+                    var itemId = int.Parse(excEquipData[dungeonId][i].ToString());
+                    itemIds.Add(itemId);
+                }
+            }
+
+            DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize;
+        }
+
+        void OnBeforePlayerDataInitialize()
+        {
+            isPackResetOk = true;
+            ClearSortedBetterEquip();
+        }
+
+        #region 璁$畻瑁呭璇勫垎
+
+        class EquipSorceProperties
+        {
+            Dictionary<int, int> properties = new Dictionary<int, int>();
+
+            public int this[int id] { get { return properties[id]; } }
+
+            public List<int> Keys { get { return new List<int>(properties.Keys); } }
+
+            void Add(int id, int value)
+            {
+                if (properties.ContainsKey(id))
+                {
+                    properties[id] += value;
+                }
+                else
+                {
+                    properties[id] = value;
+                }
+            }
+
+            public void AddRange(List<int> ids, List<int> values)
+            {
+                if (ids == null || values == null)
+                {
+                    return;
+                }
+
+                var count = Mathf.Min(ids.Count, values.Count);
+                for (int i = 0; i < count; i++)
+                {
+                    Add(ids[i], values[i]);
+                }
+            }
+
+            public void AddRange(int[] ids, int[] values)
+            {
+                if (ids == null || values == null)
+                {
+                    return;
+                }
+
+                var length = Mathf.Min(ids.Length, values.Length);
+                for (int i = 0; i < length; i++)
+                {
+                    Add(ids[i], values[i]);
+                }
+            }
+
+            public void AddRange(Dictionary<int, int> keyValues)
+            {
+                if (keyValues == null)
+                {
+                    return;
+                }
+
+                foreach (var item in keyValues)
+                {
+                    properties.Add(item.Key, item.Value);
+                }
+            }
+
+            public void AddBaseProperties(int itemId, List<int> reference)
+            {
+                var config = ItemConfig.Get(itemId);
+                if (config.Effect1 != 0 && reference.Contains(config.Effect1))
+                {
+                    properties.Add(config.Effect1, config.EffectValueA1);
+                }
+
+                if (config.Effect2 != 0 && reference.Contains(config.Effect2))
+                {
+                    properties.Add(config.Effect2, config.EffectValueA2);
+                }
+
+                if (config.Effect3 != 0 && reference.Contains(config.Effect3))
+                {
+                    properties.Add(config.Effect3, config.EffectValueA3);
+                }
+
+                if (config.Effect4 != 0 && reference.Contains(config.Effect4))
+                {
+                    properties.Add(config.Effect4, config.EffectValueA4);
+                }
+
+                if (config.Effect5 != 0 && reference.Contains(config.Effect5))
+                {
+                    properties.Add(config.Effect5, config.EffectValueA5);
+                }
+            }
+
+            public void AddCustomProperties(int itemId)
+            {
+                if (AppointItemConfig.Has(itemId))
+                {
+                    return;
+                }
+
+                var config = AppointItemConfig.Get(itemId);
+                AddRange(config.LegendAttrID, config.LegendAttrValue);
+                AddRange(config.OutOfPrintAttr, config.OutOfPrintAttrValue);
+            }
+        }
+
+        public int GetEquipScore(PackType type, int itemId, Dictionary<int, List<int>> useDataDic = null, bool isPreview = false)
+        {
+            var config = ItemConfig.Get(itemId);
+            var properties = new EquipSorceProperties();
+
+            if (IsCustomItem(itemId))
+            {
+                properties.AddBaseProperties(config.EffectValueA1, equipBaseProperties);
+                properties.AddCustomProperties(itemId);
+                return CalculateEquipScore(type, config.EffectValueA1, properties);
+            }
+
+            properties.AddBaseProperties(itemId, equipBaseProperties);
+            if (isPreview)
+            {
+                switch (config.EquipPlace)
+                {
+                    case 11:
+                        properties.AddRange(GetWingsLegendProperties(itemId));
+                        break;
+                    case 1:
+                    case 2:
+                    case 3:
+                    case 4:
+                    case 5:
+                    case 6:
+                    case 7:
+                    case 8:
+                    case 9:
+                    case 10:
+                    case 12:
+                        properties.AddRange(GetEquipLegendProperties(itemId));
+                        break;
+                }
+
+                var packType = GeneralDefine.GetPackTypeByItemType(config.Type);
+                switch (packType)
+                {
+                    case PackType.JadeDynastyItem:
+                        properties.AddRange(CalculateJadeDynastyLegendAttr(itemId));
+                        break;
+                }
+
+                return CalculateEquipScore(type, itemId, properties);
+            }
+
+            if (useDataDic != null)
+            {
+                if (useDataDic.ContainsKey((int)ItemUseDataKey.legendAttrID))
+                {
+                    properties.AddRange(useDataDic[(int)ItemUseDataKey.legendAttrID], useDataDic[(int)ItemUseDataKey.legendAttrValue]);
+                }
+
+                if (useDataDic.ContainsKey((int)ItemUseDataKey.outOfPrintAttrID))
+                {
+                    properties.AddRange(useDataDic[(int)ItemUseDataKey.outOfPrintAttrID], useDataDic[(int)ItemUseDataKey.outOfPrintAttrValue]);
+                }
+            }
+
+            return CalculateEquipScore(type, itemId, properties);
+        }
+
+        private Dictionary<int, int> GetEquipLegendProperties(int itemId)
+        {
+            var config = ItemConfig.Get(itemId);
+            var legendIdlist = new List<int>();
+
+            if (LegendPropertyUtility.HasEquipPlace(config.EquipPlace))
+            {
+                for (var i = 0; i < 3; i++)
+                {
+                    var type = (LegendAttrType)i;
+                    var count = LegendPropertyUtility.GetEquipPropertyCount(config.ItemColor, config.StarLevel, type);
+                    if (count > 0)
+                    {
+                        var propertyIds = LegendPropertyUtility.GetEquipPlaceProperties(config.EquipPlace, type);
+                        legendIdlist.AddRange(propertyIds.GetRange(0, count));
+                    }
+                }
+            }
+
+            var properties = new Dictionary<int, int>();
+            for (int i = 0; i < legendIdlist.Count; i++)
+            {
+                var propertyId = legendIdlist[i];
+                var qualityPropertyValue = LegendPropertyUtility.GetEquipQualityPropertyValue(propertyId, config.ItemColor);
+                if (qualityPropertyValue != 0)
+                {
+                    properties[propertyId] = qualityPropertyValue;
+                }
+                else
+                {
+                    var levelPropertyValue = LegendPropertyUtility.GetEquipLevelPropertyValue(propertyId, config.LV);
+                    if (levelPropertyValue != 0)
+                    {
+                        properties[propertyId] = levelPropertyValue;
+                    }
+                }
+            }
+
+            return properties;
+        }
+
+        public Dictionary<int, int> GetWingsLegendProperties(int itemId)
+        {
+            var config = ItemConfig.Get(itemId);
+            var properties = new Dictionary<int, int>();
+            var level = config.LV;
+            var count = LegendPropertyUtility.GetWingPropertyCount(level);
+            var ids = LegendPropertyUtility.GetWingProperties(level);
+            if (ids != null)
+            {
+                for (var i = 0; properties.Count < count && i < properties.Count; i++)
+                {
+                    var propertyId = ids[i];
+                    properties[propertyId] = LegendPropertyUtility.GetWingPropertyValues(level, propertyId)[0];
+                }
+            }
+
+            return properties;
+        }
+
+        private Dictionary<int, int> CalculateJadeDynastyLegendAttr(int itemId)
+        {
+            Dictionary<int, int> attrDict = null;
+            itemTipsModel.TryGetJadeDynastyLegendAttr(itemId, out attrDict);
+            return attrDict;
+        }
+
+        bool IsCustomItem(int itemId)
+        {
+            if (!ItemConfig.Has(itemId))
+            {
+                return false;
+            }
+
+            return ItemConfig.Get(itemId).Effect1 == 220;
+        }
+
+        /// <summary>
+        /// 寰楀埌瑁呭鐨勮瘎鍒�
+        /// </summary>
+        /// <param name="itemId"></param>
+        /// <returns></returns>
+        private Dictionary<AttrEnum, float> curEquipAttrDict = new Dictionary<AttrEnum, float>(); //瀛樺偍褰撳墠瑁呭灞炴�у搴旂殑鏁板�� key 灞炴�� value 灞炴�у��
+        private int CalculateEquipScore(PackType type, int itemId, EquipSorceProperties properties)
+        {
+            var config = ItemConfig.Get(itemId);
+            if (config == null || !GeneralDefine.CompareEquipPlaces.Contains(config.EquipPlace))
+            {
+                return 0;
+            }
+
+            Equation.Instance.Clear();
+            curEquipAttrDict.Clear();
+
+            var GSProValueDict = EquipGSParamConfig.GetTagGsProValueDict(config.LV, config.ItemColor, config.StarLevel);
+            foreach (var key in properties.Keys)
+            {
+                var attrType = (AttrEnum)key;
+                switch (attrType)
+                {
+                    case AttrEnum.ATKSPEED:
+                    case AttrEnum.OnlyFinalHurt:
+                    case AttrEnum.PVPAtkBackHP:
+                        curEquipAttrDict.Add(attrType, properties[key]);
+                        break;
+                    default:
+                        if (GSProValueDict != null && GSProValueDict.ContainsKey(attrType))
+                        {
+                            var curProValue = properties[key] * GSProValueDict[attrType];
+                            curEquipAttrDict.Add(attrType, curProValue);
+                        }
+                        else
+                        {
+                            curEquipAttrDict.Add(attrType, properties[key]);
+                        }
+                        break;
+                }
+            }
+
+            foreach (var key in curEquipAttrDict.Keys)
+            {
+                var propertyConfig = PlayerPropertyConfig.Get((int)key);
+                if (propertyConfig != null)
+                {
+                    Equation.Instance.AddKeyValue(propertyConfig.Parameter, curEquipAttrDict[key]);
+                }
+            }
+
+            var gSParamModel = EquipGSParamConfig.GetGSModel(config.LV, config.ItemColor, config.StarLevel);
+            if (gSParamModel != null)
+            {
+                Equation.Instance.AddKeyValue("AtkSpeedC", gSParamModel.AtkSpeedC);
+            }
+            else
+            {
+                Equation.Instance.AddKeyValue("AtkSpeedC", 0);
+            }
+
+            if (type == PackType.Deleted)
+            {
+                type = GeneralDefine.GetPackTypeByItemType(config.Type);
+            }
+
+            switch (type)
+            {
+                case PackType.DogzEquip:
+                case PackType.DogzItem:
+                    return Equation.Instance.Eval<int>(dogzGSFormula);
+                case PackType.JadeDynastyItem:
+                case PackType.JadeDynastyEquip:
+                    return Equation.Instance.Eval<int>(jadeDynastyGSFormula);
+                default:
+                    return Equation.Instance.Eval<int>(normalGSFormula);
+            }
+        }
+
+        private void ConvertAttrId(int attrId, int attrValue, Dictionary<int, int> keyValues)
+        {
+            switch ((AttrEnum)attrId)
+            {
+                case AttrEnum.ATK:
+                    if (!keyValues.ContainsKey((int)AttrEnum.MinAtk))
+                    {
+                        keyValues.Add(((int)AttrEnum.MinAtk), attrValue);
+                    }
+                    else
+                    {
+                        keyValues[(int)AttrEnum.MinAtk] += attrValue;
+                    }
+
+                    if (!keyValues.ContainsKey((int)AttrEnum.MaxAtk))
+                    {
+                        keyValues.Add(((int)AttrEnum.MaxAtk), attrValue);
+                    }
+                    else
+                    {
+                        keyValues[(int)AttrEnum.MaxAtk] += attrValue;
+                    }
+                    break;
+                default:
+                    if (!keyValues.ContainsKey(attrId))
+                    {
+                        keyValues.Add(attrId, attrValue);
+                    }
+                    else
+                    {
+                        keyValues[attrId] += attrValue;
+                    }
+                    break;
+            }
+        }
+        #endregion
+
+        #region 涓荤晫闈㈢墿鍝佸脊妗嗗睍绀�
+        public event Action<PackType, string> GetPreciousItemEvent; //寰楀埌鐝嶅搧  value 鐗╁搧鐨勫疄渚婭D
+
+        public void RecommendItem(ItemModel item)
+        {
+            if (item.packType != PackType.Item)
+            {
+                return;
+            }
+
+            if (item.config.UseLV > PlayerDatas.Instance.baseData.LV)
+            {
+                return;
+            }
+
+            if (IsOverdue(item.guid, item.itemId, item.useDataDict))
+            {
+                return;
+            }
+
+            if (!preciousItemTypes.Contains(item.config.Type))
+            {
+                return;
+            }
+
+            if (!IsAbleToUse(item))
+            {
+                return;
+            }
+
+            if (GetPreciousItemEvent != null)
+            {
+                GetPreciousItemEvent(item.packType, item.guid);
+            }
+        }
+
+        bool IsAbleToUse(ItemModel item)
+        {
+            var windowSearch = WindowSearchConfig.Get(item.config.Jump);
+            if (windowSearch != null)
+            {
+                if (!FuncOpen.Instance.IsFuncOpen(windowSearch.Lv) && windowSearch.Lv != 0)
+                {
+                    return false;
+                }
+            }
+
+            if (pushItemIds.Contains(item.itemId))
+            {
+                var itemCnt = playerPack.GetItemCountByID(PackType.Item, item.itemId) - item.count;
+                if (itemCnt > 0)
+                {
+                    return false;
+                }
+                else
+                {
+                    if (item.preItemCount > 0)
+                    {
+                        return false;
+                    }
+                }
+            }
+
+            if (promptUseLimitDict.ContainsKey(item.itemId))
+            {
+                var playerLv = PlayerDatas.Instance.baseData.LV;
+                if (playerLv < promptUseLimitDict[item.itemId])
+                {
+                    return false;
+                }
+            }
+
+            ulong canUseCnt = 0;
+            if (playerPack.IsReachUseLimit(item.guid, out canUseCnt))
+            {
+                return false;
+            }
+
+            bool isBox = false;
+            bool isCanOpen = ModelCenter.Instance.GetModel<BoxGetItemModel>().CheckOpenBoxCondition(item.itemId, out isBox);
+            if (isBox)
+            {
+                if (!isCanOpen)
+                {
+                    return false;
+                }
+            }
+
+            if (trialModel.trialTokens.Contains(item.itemId))
+            {
+                if (!trialModel.IsAnySatisfyExchangeBetter(item.itemId))
+                {
+                    return false;
+                }
+            }
+
+            if (playerPack.CheckIsDrugById(item.itemId))
+            {
+                if (item.config.RealmLimit > PlayerDatas.Instance.baseData.realmLevel)
+                {
+                    return false;
+                }
+            }
+
+            switch (item.config.Type)
+            {
+                case 8:
+                    if (buffDatas.BastBuff(item.itemId))
+                    {
+                        return false;
+                    }
+                    break;
+                case 20:
+                    if (magicianModel.IsGodWeaponMaxLevelByItem(item.itemId))
+                    {
+                        return false;
+                    }
+                    break;
+                case 21:
+                    if (!mountDatas.IsHint(HorseEnum.HorseDan, item.itemId))
+                    {
+                        return false;
+                    }
+                    break;
+                case 22:
+                    if (!mountDatas.IsHint(HorseEnum.HorseStone, item.itemId))
+                    {
+                        return false;
+                    }
+                    break;
+                case 41:
+                    if (!mountDatas.IsHint(HorseEnum.HorseDebris, item.itemId))
+                    {
+                        return false;
+                    }
+                    break;
+                case 26:
+                    if (!petDatas.IsHint(PetEnum.PetDebris, item.itemId))
+                    {
+                        return false;
+                    }
+                    break;
+                case 27:
+                    if (!petDatas.IsHint(PetEnum.PetDan, item.itemId))
+                    {
+                        return false;
+                    }
+                    break;
+                case 28:
+                    if (!petDatas.IsHint(PetEnum.PetStone, item.itemId))
+                    {
+                        return false;
+                    }
+                    break;
+                case 25:
+                    if (!ModelCenter.Instance.GetModel<GemModel>().SatisfyBetter(item.itemId))
+                    {
+                        return false;
+                    }
+                    break;
+                case 39:
+                    if (!IsBetterWings(item))
+                    {
+                        return false;
+                    }
+                    break;
+                case 52:
+                    if (!strengthDatas.IsHint(item.itemId))
+                    {
+                        return false;
+                    }
+                    break;
+                case 127:
+                    var error = 0;
+                    bool isHaveMakeNum = ItemOperateUtility.Instance.CanUseItem(item.itemPlace, 1, out error);
+                    int remainNum = CrossServerOneVsOnePlayerInfo.Instance.GetDayRemainNum();
+                    if (!CrossServerOneVsOnePKSeason.Instance.isSatisfyMatch
+                        || remainNum > 0
+                        || !isHaveMakeNum)
+                    {
+                        return false;
+                    }
+                    break;
+                default:
+                    break;
+            }
+
+            switch (item.itemId)
+            {
+                case 951:
+                    if (!CheckIsExtendGrid(item.itemId))
+                    {
+                        return false;
+                    }
+                    break;
+                case 952:
+                    int willTime = HangUpSetModel.Instance.offlinePluginTime + item.config.EffectValueA1;
+                    if (HangUpSetModel.Instance.offlinePluginTime >= HangUpSetModel.Instance.maxOfflinePluginTime)
+                    {
+                        return false;
+                    }
+                    break;
+
+            }
+
+            return true;
+        }
+
+        private bool IsBetterWings(ItemModel item)
+        {
+            if (item == null)
+            {
+                return false;
+            }
+
+            var putModel = playerPack.GetItemByIndex(PackType.Equip, (int)RoleEquipType.Wing);
+            var singlePack = playerPack.GetSinglePack(PackType.Item);
+            if (singlePack == null)
+            {
+                return false;
+            }
+
+            int[] composeTypes = item.config.JumpComposeCondi;
+            bool isOpenCompose = false;
+            if (composeTypes != null && composeTypes.Length >= 3)
+            {
+                int first = composeTypes[0];
+                int second = composeTypes[1];
+                int third = composeTypes[2];
+                ComposeWinModel.ComposeThirdTypeData thirdTypeData = null;
+                composeModel.TryGetThirdTypeData(first, second, third, out thirdTypeData);
+                if (thirdTypeData != null)
+                {
+                    var itemCompound = thirdTypeData.itemCompound;
+                    if (itemCompound.levelNeed <= PlayerDatas.Instance.baseData.LV)
+                    {
+                        isOpenCompose = true;
+                    }
+                }
+            }
+
+            if (!isOpenCompose)
+            {
+                return false;
+            }
+
+            if (putModel != null && putModel.config.LV >= item.config.LV)
+            {
+                return false;
+            }
+
+            var itemModels = singlePack.GetItemsByType((int)ItemType.Wings);
+            if (itemModels != null)
+            {
+                for (int i = 0; i < itemModels.Count; i++)
+                {
+                    if (itemModels[i].config.JobLimit / 100 == PlayerDatas.Instance.baseData.Job)
+                    {
+                        if (itemModels[i].config.LV >= item.config.LV)
+                        {
+                            return false;
+                        }
+                    }
+                }
+            }
+
+            return true;
+        }
+
+        private bool CheckIsExtendGrid(int itemId)
+        {
+            SinglePack singlePack = playerPack.GetSinglePack(PackType.Item);
+            if (singlePack == null) return false;
+
+            int startLockIndex = singlePack.unlockedGridCount - GeneralDefine.initBagGridCount;
+            FuncConfigConfig _tagFuncModel = FuncConfigConfig.Get("OpenBagItem");
+            int haveCount = playerPack.GetItemCountByID(PackType.Item, itemId);
+            Equation.Instance.Clear();
+            Equation.Instance.AddKeyValue("index", startLockIndex + 1);
+            int needTool = Equation.Instance.Eval<int>(_tagFuncModel.Numerical2);
+            if (haveCount >= needTool)
+            {
+                return true;
+            }
+            else
+            {
+                return false;
+            }
+        }
+
+        public event Action<string> GetBetterEquipEvent; //寰楀埌鏇村ソ鐨勮澶� value 鐗╁搧鐨勫疄渚婭D
+
+        public void OnGetEquip(ItemModel item)
+        {
+            if (item == null)
+            {
+                return;
+            }
+
+            if (item.packType != PackType.Item && item.packType != PackType.JadeDynastyItem)
+            {
+                return;
+            }
+
+            if (!IsSameJob(item.config.JobLimit))
+            {
+                return;
+            }
+
+            int equipPlace = item.config.EquipPlace;
+            switch ((RoleEquipType)equipPlace)
+            {
+                case RoleEquipType.Weapon:
+                case RoleEquipType.Weapon2:
+                case RoleEquipType.Hat:
+                case RoleEquipType.Clothes:
+                case RoleEquipType.Belt:
+                case RoleEquipType.Trousers:
+                case RoleEquipType.Shoes:
+                case RoleEquipType.Neck:
+                case RoleEquipType.FairyCan:
+                case RoleEquipType.FairyCan2:
+                case RoleEquipType.Wing:
+                case RoleEquipType.SpiritAnimal:
+                case RoleEquipType.JadeDynasty_Cloak:
+                case RoleEquipType.JadeDynasty_FaceMask:
+                case RoleEquipType.JadeDynasty_Glove1:
+                case RoleEquipType.JadeDynasty_Glove2:
+                case RoleEquipType.JadeDynasty_Ruyi:
+                case RoleEquipType.JadeDynasty_Pendant:
+                case RoleEquipType.JadeDynasty_Ring1:
+                case RoleEquipType.JadeDynasty_Ring2:
+                case RoleEquipType.JadeDynasty_Sword1:
+                case RoleEquipType.JadeDynasty_Sword2:
+                case RoleEquipType.JadeDynasty_Sword3:
+                case RoleEquipType.JadeDynasty_Sword4:
+                    if (betterEquipExceptDungeonDict.ContainsKey(PlayerDatas.Instance.baseData.MapID))
+                    {
+                        if (betterEquipExceptDungeonDict[PlayerDatas.Instance.baseData.MapID].Contains(item.itemId))
+                        {
+                            return;
+                        }
+                    }
+                    SetGetBetterEquipEvent(item);
+                    break;
+            }
+        }
+
+        bool IsSameJob(int jobLimit)
+        {
+            return jobLimit == 0 || jobLimit / 100 == PlayerDatas.Instance.baseData.Job;
+        }
+
+        private void SetGetBetterEquipEvent(ItemModel model)
+        {
+            List<int> itemEffectTime = model.GetUseDataModel((int)ItemUseDataKey.createTime);
+            if (itemEffectTime != null)
+            {
+                if (itemEffectTime[0] != 0)
+                {
+                    ItemCDCool cool = KnapsackTimeCDMgr.Instance.GetItemCoolById(model.guid);
+                    double remainTime = 0;
+                    if (cool != null)
+                    {
+                        remainTime = cool.GetRemainTime();
+                    }
+
+                    if (remainTime >= 0 && remainTime < 120 && model.config.ExpireTime > 0)
+                    {
+                        return;
+                    }
+                }
+            }
+
+            int isFightUp = IsFightUp(model.itemId, model.equipScore);
+            int equipPlace = model.config.EquipPlace;
+            if (isFightUp == 1)
+            {
+                switch (equipPlace)
+                {
+                    case 9:
+                        break;
+                    default:
+                        if (model.packType == PackType.Item)
+                        {
+                            var equipItemModel = playerPack.GetItemByIndex(PackType.Equip, model.config.EquipPlace);
+                            if (PlayerDatas.Instance.baseData.LV >= 200)
+                            {
+                                if (model.equipPlace > (int)RoleEquipType.Weapon2 && model.equipPlace < (int)RoleEquipType.Neck)
+                                {
+                                    if (equipItemModel != null && equipItemModel.config.ItemColor > model.config.ItemColor)
+                                    {
+                                        return;
+                                    }
+                                }
+                            }
+                        }
+                        break;
+                }
+
+                if (GetBetterEquipEvent != null)
+                {
+                    GetBetterEquipEvent(model.guid);
+                }
+
+            }
+        }
+
+        public event Action<PackType, string> PickItemEvent; //鎹¤捣鐨勭墿鍝�
+
+        public void RefreshPickItem(PackType type, string guid)
+        {
+            if (type != PackType.Item) return;
+
+            if (PickItemEvent != null)
+            {
+                PickItemEvent(type, guid);
+            }
+        }
+
+        Dictionary<int, ItemModel> RealmBetterDict = new Dictionary<int, ItemModel>();
+        public Dictionary<int, ItemModel> CheckBetterEquipByRealm()
+        {
+            RealmBetterDict.Clear();
+            SinglePack singlePack = playerPack.GetSinglePack(PackType.Item);
+            if (singlePack == null) return RealmBetterDict;
+
+            int realmLv = PlayerDatas.Instance.baseData.realmLevel;
+            Dictionary<int, ItemModel> pairs = singlePack.GetAllItems();
+            foreach (var model in pairs.Values)
+            {
+                if (model.config.EquipPlace > 0
+                    && model.config.EquipPlace != (int)RoleEquipType.SpiritAnimal
+                    && model.config.RealmLimit <= realmLv
+                    && !IsOverdue(model.guid, model.itemId, model.useDataDict)
+                    && IsFightUp(model.itemId, model.equipScore) == 1)
+                {
+                    if (!RealmBetterDict.ContainsKey(model.equipPlace))
+                    {
+                        RealmBetterDict.Add(model.equipPlace, model);
+                    }
+                    else
+                    {
+                        if (model.equipScore > RealmBetterDict[model.equipPlace].equipScore)
+                        {
+                            RealmBetterDict[model.equipPlace] = model;
+                        }
+                    }
+                }
+            }
+            return RealmBetterDict;
+        }
+
+        List<ItemModel> RealmDruglist = new List<ItemModel>();
+        public List<ItemModel> GetDruglistByRealm()
+        {
+            RealmDruglist.Clear();
+            SinglePack singlePack = playerPack.GetSinglePack(PackType.Item);
+            if (singlePack == null) return RealmDruglist;
+
+            int realmLv = PlayerDatas.Instance.baseData.realmLevel;
+            Dictionary<int, ItemModel> pairs = singlePack.GetAllItems();
+            foreach (var model in pairs.Values)
+            {
+                if (playerPack.CheckIsDrugById(model.itemId))
+                {
+                    AttrFruitConfig fruitConfig = AttrFruitConfig.Get(model.itemId);
+                    if (!playerPack.IsReachMaxUseDrug(fruitConfig)
+                        && model.config.RealmLimit <= realmLv)
+                    {
+                        RealmDruglist.Add(model);
+                    }
+                }
+            }
+            return RealmDruglist;
+        }
+        #endregion
+
+        #region 鐗╁搧澶勪簬CD涓殑閫昏緫澶勭悊
+
+        private List<string> itemEffectTimelist = new List<string>(); //key 鐗╁搧瀹炰緥ID
+        /// <summary>
+        /// 鐗╁搧浣跨敤鏃堕棿闄愬埗
+        /// </summary>
+        public void SetItemEffectCDTime(string guid, int itemID, int getTime, int serverSurplusTime)
+        {
+            double time = GetTimeOffest(TimeUtility.GetTime((uint)getTime));
+            if (time < 0)
+            {
+                time = 0;
+            }
+
+            ItemConfig itemConfig = ItemConfig.Get(itemID);
+            if (time >= itemConfig.ExpireTime)
+            {
+                KnapsackTimeCDMgr.Instance.UnRegister(guid);
+                return;
+            }
+            double remainTime = (serverSurplusTime > 0 ? serverSurplusTime : itemConfig.ExpireTime) - time;
+            KnapsackTimeCDMgr.Instance.Register(guid, itemID, remainTime);
+        }
+
+        public double GetTimeOffest(DateTime getTime)
+        {
+            DebugEx.Log("鐜板湪鏃堕棿锛�" + TimeUtility.ServerNow + "鑾峰緱鏃堕棿:" + getTime);
+            //TimeUtility.SyncServerTime();
+            TimeSpan t = TimeUtility.ServerNow - getTime;
+            DebugEx.Log("鏃堕棿宸細" + t.TotalSeconds);
+            return t.TotalSeconds;
+        }
+
+        #endregion
+
+        #region 璁剧疆鍙互涓�閿嚭鍞殑鐗╁搧鏁版嵁
+
+        private int playerLv;
+        private Dictionary<int, List<ItemModel>> _lifePotionDict = new Dictionary<int, List<ItemModel>>(); //key 鑽按绛夌骇
+        private List<int> _sellItemScorelist = new List<int>();
+        private Dictionary<int, Dictionary<int, List<ItemModel>>> _sameIndexEquipDict = new Dictionary<int, Dictionary<int, List<ItemModel>>>();  //瀛樺偍鐩稿悓瑁呭浣嶇殑瑁呭
+                                                                                                                                                  // private  _sameEquipScoreDict = new Dictionary<int, List<ItemModel>>(); //瀛樺偍鐩稿悓ID涓浉鍚岃澶囪瘎鍒嗙殑瑁呭
+        private Dictionary<int, ItemModel> _packModelDict;
+        private List<ItemModel> _sellItemlist = new List<ItemModel>();
+
+        public List<ItemModel> GetSellItemList()
+        {
+            GetOneKeySellModel();
+            _sellItemlist.Sort(SetSellItemOrder);
+            return _sellItemlist;
+        }
+
+        public int SetSellItemOrder(ItemModel startModel, ItemModel endModel)
+        {
+            bool startIsEquip = IsEquip(startModel);
+            bool endIsEquip = IsEquip(endModel);
+            if (startIsEquip.CompareTo(endIsEquip) != 0) return -startIsEquip.CompareTo(endIsEquip);
+            int order1 = startModel.config.Type;
+            int order2 = endModel.config.Type;
+            if (order1.CompareTo(order2) != 0) return order1.CompareTo(order2);
+            int color1 = startModel.config.ItemColor;
+            int color2 = endModel.config.ItemColor;
+            if (color1.CompareTo(color2) != 0) return -color1.CompareTo(color2);
+            int code1 = startModel.itemId;
+            int code2 = endModel.itemId;
+            if (code1.CompareTo(code2) != 0) return -code1.CompareTo(code2);
+            return 0;
+        }
+
+        public bool IsEquip(ItemModel model)
+        {
+            return model.config.EquipPlace != 0;
+        }
+
+        public void GetOneKeySellModel()
+        {
+            SinglePack singlePack = playerPack.GetSinglePack(PackType.Item);
+            if (singlePack == null)
+                return;
+
+            _sellItemlist.Clear();
+            _lifePotionDict.Clear();
+            _sameIndexEquipDict.Clear();
+            _sellItemScorelist.Clear();
+            playerLv = PlayerDatas.Instance.baseData.LV;
+            _packModelDict = singlePack.GetAllItems();
+            foreach (var key in _packModelDict.Keys)
+            {
+                GetCanSellEquipList(_packModelDict[key]);
+                ItemModel itemModel = _packModelDict[key];
+                if (drugIDs.Contains(itemModel.itemId))
+                {
+                    if (!_lifePotionDict.ContainsKey(itemModel.config.LV))
+                    {
+                        List<ItemModel> modellist = new List<ItemModel>();
+                        modellist.Add(itemModel);
+                        _lifePotionDict.Add(itemModel.config.LV, modellist);
+                    }
+                    else
+                    {
+                        _lifePotionDict[itemModel.config.LV].Add(itemModel);
+                    }
+                }
+            }
+
+            #region 寰楀埌鍙互鍑哄敭鐨勮澶�
+            foreach (var key in _sameIndexEquipDict.Keys)
+            {
+                _sellItemScorelist = _sameIndexEquipDict[key].Keys.ToList();
+                _sellItemScorelist.Sort();
+                if (_sellItemScorelist.Count > 0)
+                {
+                    int score = 0;
+                    int curJob = PlayerDatas.Instance.baseData.Job;
+                    for (score = _sellItemScorelist.Count - 1; score > -1; score--)
+                    {
+                        SinglePack equipPack = playerPack.GetSinglePack(PackType.Equip);
+                        ItemModel model = null;
+                        if (equipPack != null)
+                        {
+                            model = equipPack.GetItemByIndex(key);
+                        }
+
+                        List<ItemModel> modellist = _sameIndexEquipDict[key][_sellItemScorelist[score]];
+                        int i = 0;
+                        bool remainBetter = true;
+                        for (i = 0; i < modellist.Count; i++)
+                        {
+                            double joblimit = Math.Floor((double)modellist[i].config.JobLimit / 100);
+                            if (model != null)
+                            {
+                                if (remainBetter)
+                                {
+                                    if (model.equipScore < _sellItemScorelist[score] && curJob == joblimit)
+                                    {
+                                        _sameIndexEquipDict[key].Remove(_sellItemScorelist[score]);
+                                        remainBetter = false;
+                                        break;
+                                    }
+                                }
+
+                            }
+                            else
+                            {
+                                if (curJob == joblimit)
+                                {
+                                    if (remainBetter)
+                                    {
+                                        _sameIndexEquipDict[key].Remove(_sellItemScorelist[score]);
+                                        remainBetter = false;
+                                        break;
+                                    }
+                                }
+                            }
+                        }
+
+                        if (!remainBetter)
+                        {
+                            break;
+                        }
+
+                    }
+                    int j = 0;
+                    for (j = 0; j < _sellItemScorelist.Count; j++)
+                    {
+
+                        if (_sameIndexEquipDict[key].ContainsKey(_sellItemScorelist[j]))
+                        {
+                            int k = 0;
+                            List<ItemModel> sellModlelist = _sameIndexEquipDict[key][_sellItemScorelist[j]];
+                            for (k = 0; k < sellModlelist.Count; k++)
+                            {
+                                _sellItemlist.Add(sellModlelist[k]);
+                            }
+                        }
+                    }
+
+                }
+
+            }
+            #endregion
+
+            List<int> drugLvlist = new List<int>();
+            drugLvlist.AddRange(_lifePotionDict.Keys.ToList());
+            drugLvlist.Sort();
+            for (int i = drugLvlist.Count - 1; i > -1; i--)
+            {
+                if (drugLvlist[i] > playerLv)
+                {
+                    _lifePotionDict.Remove(drugLvlist[i]);
+                }
+                else
+                {
+                    _lifePotionDict.Remove(drugLvlist[i]);
+                    break;
+                }
+            }
+
+            foreach (var list in _lifePotionDict.Values)
+            {
+                for (int i = 0; i < list.Count; i++)
+                {
+                    _sellItemlist.Add(list[i]);
+                }
+
+            }
+        }
+
+
+        //寰楀埌婊¤冻鍑哄敭鏉′欢鐨勮澶囧垪琛�
+        public void GetCanSellEquipList(ItemModel model)
+        {
+
+            if (model.config.EquipPlace == 0 || !onekeySellTypes.Contains(model.config.Type))
+                return;
+
+            Dictionary<int, List<ItemModel>> sameScoreDict;
+            List<ItemModel> sameScorelist;
+
+            if (model.config.ItemColor < 3)
+            {
+                if (!_sameIndexEquipDict.ContainsKey(model.config.EquipPlace))
+                {
+                    sameScoreDict = new Dictionary<int, List<ItemModel>>();
+                    sameScorelist = new List<ItemModel>();
+                    sameScorelist.Add(model);
+                    sameScoreDict.Add(model.equipScore, sameScorelist);
+                    _sameIndexEquipDict.Add(model.config.EquipPlace, sameScoreDict);
+
+                }
+                else
+                {
+                    if (_sameIndexEquipDict[model.config.EquipPlace].ContainsKey(model.equipScore))
+                    {
+                        _sameIndexEquipDict[model.config.EquipPlace][model.equipScore].Add(model);
+                    }
+                    else
+                    {
+                        sameScorelist = new List<ItemModel>();
+                        sameScorelist.Add(model);
+                        _sameIndexEquipDict[model.config.EquipPlace].Add(model.equipScore, sameScorelist);
+                    }
+
+                }
+            }
+
+
+        }
+
+        #endregion
+
+        #region 鍙戦�佽姹�
+        /// <summary>
+        /// 涓�閿嚭鍞墿鍝佺殑璇锋眰
+        /// </summary>
+        /// <param name="_oneKeySelllist"></param>
+        public void SendOneKeySellQuest(List<ItemModel> _oneKeySelllist)
+        {
+            if (!isPackResetOk || SettingEffectMgr.Instance.isStartOneKeySell) return;
+
+            SettingEffectMgr.Instance.isStartOneKeySell = true;
+            byte[] itemIndexs = new byte[_oneKeySelllist.Count];
+            int i = 0;
+            for (i = 0; i < _oneKeySelllist.Count; i++)
+            {
+                itemIndexs[i] = (byte)_oneKeySelllist[i].itemPlace;
+            }
+            CA311_tagCMSellItem sellItem = new CA311_tagCMSellItem();
+            sellItem.PackType = (int)PackType.Item;
+            sellItem.Count = (byte)_oneKeySelllist.Count;
+            sellItem.ItemIndex = itemIndexs;
+            GameNetSystem.Instance.SendInfo(sellItem);
+        }
+
+        /// <summary>
+        /// 鏁寸悊鍖呰9鐗╁搧
+        /// </summary>
+        /// <param name="type"></param>
+        public bool isPackResetOk { get; set; }
+        public void SendPackResetQuest(PackType type)
+        {
+            if (lookLineIndex > -1)
+            {
+                SetLookIndex(null);
+            }
+
+            if (KnapSackWin.titleType == KnapsackFuncTitle.bag)
+            {
+                playerPack.isPlayBetterEquipEffect = true;
+            }
+
+            SinglePack singlePack = playerPack.GetSinglePack(type);
+            if (singlePack != null)
+            {
+                C070F_tagCItemPackReset packReset = new C070F_tagCItemPackReset();
+                packReset.Type = (byte)type;
+                packReset.ItemBeginIndex = 0;
+                packReset.ItemEndIndex = (ushort)(singlePack.unlockedGridCount - 1);
+                GameNetSystem.Instance.SendInfo(packReset); //鏁寸悊鐗╁搧
+                if (type == PackType.Item)
+                {
+                    isPackResetOk = false;
+                }
+            }
+        }
+        #endregion
+
+        #region 鏌ョ湅鏌愪釜浣嶇疆鐨勭墿鍝�
+        public event Action lookEquipEvent;
+        private int _lookLineIndex = -1;
+        public int lookLineIndex { get { return _lookLineIndex; } private set { _lookLineIndex = value; } }
+
+        public string lookItemGUID { get; private set; }
+
+        public void SetLookIndex(string guid, int singleRowCount = 5)
+        {
+
+            if (string.IsNullOrEmpty(guid) || guid == "")
+            {
+                lookLineIndex = -1;
+            }
+            else
+            {
+                int index = playerPack.GetItemByGuid(guid).itemPlace;
+                lookLineIndex = index / singleRowCount;
+                lookItemGUID = guid;
+            }
+
+            if (lookEquipEvent != null)
+            {
+                lookEquipEvent();
+            }
+
+        }
+        #endregion
+
+        #region 鍒ゆ柇鏄惁鏈夋洿濂界殑瑁呭鏇挎崲
+        /// <summary>
+        /// 杩囨护瑁呭浣嶅垽鏂�
+        /// </summary>
+        /// <param name="ignoreType"></param>
+        /// <returns></returns>
+        public bool CheckBetterEquip(RoleEquipType ignoreType)
+        {
+            SinglePack singlePack = playerPack.GetSinglePack(PackType.Equip);
+            if (singlePack != null)
+            {
+                Dictionary<int, ItemModel> putOnDic = singlePack.GetAllItems();
+                foreach (var key in putOnDic.Keys)
+                {
+                    if ((RoleEquipType)key == ignoreType)
+                    {
+                        continue;
+                    }
+                    if (key < 13)
+                    {
+                        List<ItemModel> itemlist = GetSameEquipPlacelist(key);
+                        int i = 0;
+                        for (i = 0; i < itemlist.Count; i++)
+                        {
+                            bool isOverdue = IsOverdue(itemlist[i].guid, itemlist[i].itemId, itemlist[i].useDataDict);
+                            bool isRealm = PlayerDatas.Instance.baseData.realmLevel >= itemlist[i].config.RealmLimit ? true : false;
+                            if (itemlist[i].equipScore > putOnDic[key].equipScore && !isOverdue && isRealm)
+                            {
+                                return true;
+                            }
+                        }
+                    }
+                }
+            }
+            else
+            {
+                int i = 1;
+                for (i = 1; i < 13; i++)
+                {
+                    List<ItemModel> itemlist = GetSameEquipPlacelist(i);
+                    if (itemlist.Count > 0)
+                    {
+                        return true;
+                    }
+                }
+            }
+            return false;
+        }
+
+        private List<ItemModel> GetSameEquipPlacelist(int equipPlace)
+        {
+            List<ItemModel> modellist = new List<ItemModel>();
+            Dictionary<int, ItemModel> dic = null;
+            SinglePack singlePack = playerPack.GetSinglePack(PackType.Item);
+            if (singlePack != null)
+            {
+                dic = singlePack.GetAllItems();
+                foreach (var model in dic.Values)
+                {
+                    if (model.config.EquipPlace == equipPlace)
+                    {
+                        double equipJob = Math.Floor((double)model.config.JobLimit / 100);
+                        if (equipJob == 0 || equipJob == PlayerDatas.Instance.baseData.Job)
+                        {
+                            modellist.Add(model);
+                        }
+                    }
+                }
+            }
+            return modellist;
+        }
+
+        /// <summary>
+        /// 鑾峰彇瑁呭璇勫垎鏈�楂樺彲鎻愬崌鎴樺姏鐨勮澶�
+        /// </summary>
+        /// <param name="_places"></param>
+        /// <returns></returns>
+        public string GetHighestScoreEquipByPlace(int equipPlace)
+        {
+            var itemPackage = playerPack.GetSinglePack(PackType.Item);
+            var allItems = itemPackage.GetAllItems();
+            ItemModel putModel = playerPack.GetItemByIndex(PackType.Equip, equipPlace);
+            equipPlace = (equipPlace == 9 || equipPlace == 10) ? 9 : equipPlace;
+            var guid = string.Empty;
+            var equips = new List<string>();
+            var score = putModel == null ? 0 : putModel.equipScore;
+            var job = PlayerDatas.Instance.baseData.Job;
+            foreach (var item in allItems.Values)
+            {
+                if (item.config.EquipPlace == equipPlace)
+                {
+                    if (!IsOverdue(item.guid, item.itemId, item.useDataDict)
+                       && (item.config.JobLimit == 0 || (item.config.JobLimit / 100) == job) && item.equipScore > score)
+                    {
+                        guid = item.guid;
+                        score = item.equipScore;
+                    }
+                }
+            }
+
+            return guid;
+        }
+        #endregion
+
+        #region 鑳屽寘鏁寸悊鍚庡ソ鐨勫悓绫诲瀷鏈�濂界殑瑁呭
+        Dictionary<int, Dictionary<int, ItemModel>> itemModelDict = new Dictionary<int, Dictionary<int, ItemModel>>();  // key1 瑁呭浣嶇疆绱㈠紩 key2 鑳屽寘浣嶇疆绱㈠紩
+
+        public void ClearSortedBetterEquip()
+        {
+            itemModelDict.Clear();
+        }
+
+        public void SetBagSortBetterEquipList(ItemModel itemModel)
+        {
+            if (itemModel == null || itemModel.packType != PackType.Item) return;
+
+            if (!IsCanPutOn(itemModel)) return;
+
+            int equipPlace = itemModel.config.EquipPlace;
+            if (!itemModelDict.ContainsKey(equipPlace))
+            {
+                Dictionary<int, ItemModel> dict = new Dictionary<int, ItemModel>();
+                if (IsFightUp(itemModel.itemId, itemModel.equipScore) == 1)
+                {
+                    dict.Add(itemModel.itemPlace, itemModel);
+                    itemModelDict.Add(equipPlace, dict);
+                }
+            }
+            else
+            {
+                if (IsFightUp(itemModel.itemId, itemModel.equipScore) == 1)
+                {
+                    itemModelDict[equipPlace].Add(itemModel.itemPlace, itemModel);
+                }
+            }
+
+        }
+
+        public ItemModel GetBagSortBetterEquip(int equipPlace, int index)
+        {
+            ItemModel itemModel = null;
+            if (itemModelDict.ContainsKey(equipPlace))
+            {
+                itemModelDict[equipPlace].TryGetValue(index, out itemModel);
+            }
+            return itemModel;
+        }
+
+        public bool IsCanPutOn(ItemModel itemModel)
+        {
+            double equipJob = Math.Floor((double)itemModel.config.JobLimit / 100);
+            int playerJob = PlayerDatas.Instance.baseData.Job;
+            int equipPlace = itemModel.config.EquipPlace;
+            if (equipPlace == 0 || equipPlace > 12) return false;
+            if (equipJob != 0 && equipJob != playerJob) return false;
+
+            List<int> putOnlimitList = itemModel.GetUseDataModel((int)ItemUseDataKey.cancelUseLimit);
+            if (putOnlimitList != null)
+            {
+                if (putOnlimitList[0] == 1)
+                {
+                    return true;
+                }
+            }
+
+            return CheckPutOnRealm(itemModel.config);
+        }
+
+        private bool CheckPutOnRealm(ItemConfig config)
+        {
+            var _realmLv = config.RealmLimit;
+            if (PlayerDatas.Instance.baseData.realmLevel < _realmLv)
+            {
+                return false;
+            }
+            return true;
+        }
+        #endregion
+
+        #region 寰楀埌鐗╁搧鐨勫搧璐ㄩ鑹�
+        private Dictionary<int, int> wingRefineQualityDict;
+        private int[] wingsQualitys;
+        private int[] wingsRefineExps;
+        public int GetItemQuality(int itemId, Dictionary<int, List<int>> useDataDic = null)
+        {
+            wingsQualitys = null;
+            wingsRefineExps = null;
+            ItemConfig itemConfig = ItemConfig.Get(itemId);
+            wingRefineQualityDict = WingRefineAttrConfig.GetWingsQualityModel(itemConfig.LV);
+            if (useDataDic != null)
+            {
+                if (useDataDic.ContainsKey(42) && wingRefineQualityDict != null)
+                {
+                    wingsQualitys = wingRefineQualityDict.Keys.ToArray();
+                    wingsRefineExps = wingRefineQualityDict.Values.ToArray();
+                    int i = 0;
+                    for (i = wingsRefineExps.Length - 1; i > -1; i--)
+                    {
+                        if (useDataDic[42][0] >= wingsRefineExps[i])
+                        {
+                            return wingsQualitys[i];
+                        }
+                    }
+                }
+            }
+            return itemConfig.ItemColor;
+        }
+        #endregion
+
+        //璁剧疆鐜╁璐у竵鏄剧ず
+        public string OnChangeCoinsUnit(ulong value)
+        {
+
+            string strCoins = value.ToString();
+            if (strCoins.Length > 4 && strCoins.Length < 9)
+            {
+                double coins = Math.Floor((double)value / 10000);
+                strCoins = coins + Language.Get("KnapS114");
+            }
+            else if (strCoins.Length >= 9 && strCoins.Length < 13)
+            {
+                double coins = Math.Floor((double)value / 100000000);
+                strCoins = coins + Language.Get("KnapS115");
+            }
+            else if (strCoins.Length >= 13 && strCoins.Length < 19)
+            {
+                double coins = Math.Floor((double)value / 1000000000000);
+                strCoins = coins + Language.Get("KnapS126");
+            }
+            else if (strCoins.Length >= 19)
+            {
+                ServerTipDetails.DisplayNormalTip(Language.Get("KnapS127"));
+            }
+            return strCoins;
+        }
+
+        /// <summary>
+        /// 瑁呭鏄惁鍙互鎻愬崌鎴樺姏
+        /// </summary>
+        /// <param name="_itemID"></param>
+        /// <param name="_score"></param>
+        /// <returns></returns>
+        public int IsFightUp(int _itemID, int _score)//-1浣庣骇锛�0涓嶆槸鏈亴涓氾紝1鏇村ソ
+        {
+            ItemConfig chinItemModel = ItemConfig.Get(_itemID);
+            if (chinItemModel != null)
+            {
+                ItemModel putOnModel = null;
+                switch ((RoleEquipType)chinItemModel.EquipPlace)
+                {
+                    case RoleEquipType.Clothes:
+                    case RoleEquipType.FairyCan:
+                    case RoleEquipType.Belt:
+                    case RoleEquipType.Hat:
+                    case RoleEquipType.Neck:
+                    case RoleEquipType.Shoes:
+                    case RoleEquipType.SpiritAnimal:
+                    case RoleEquipType.Trousers:
+                    case RoleEquipType.Weapon:
+                    case RoleEquipType.Weapon2:
+                    case RoleEquipType.Wing:
+                        putOnModel = playerPack.GetItemByIndex(PackType.Equip, chinItemModel.EquipPlace);
+                        break;
+                    case RoleEquipType.JadeDynasty_Cloak:
+                    case RoleEquipType.JadeDynasty_FaceMask:
+                    case RoleEquipType.JadeDynasty_Glove1:
+                    case RoleEquipType.JadeDynasty_Pendant:
+                    case RoleEquipType.JadeDynasty_Ring1:
+                    case RoleEquipType.JadeDynasty_Ruyi:
+                    case RoleEquipType.JadeDynasty_Sword1:
+                    case RoleEquipType.JadeDynasty_Sword2:
+                    case RoleEquipType.JadeDynasty_Sword3:
+                    case RoleEquipType.JadeDynasty_Sword4:
+                        putOnModel = playerPack.GetItemByIndex(PackType.JadeDynastyEquip, chinItemModel.EquipPlace);
+                        break;
+                    default:
+                        return 0;
+                }
+
+                ItemModel putOnModel2 = null;
+                switch ((RoleEquipType)chinItemModel.EquipPlace)
+                {
+                    case RoleEquipType.FairyCan:
+                        putOnModel2 = playerPack.GetItemByIndex(PackType.Equip, (int)RoleEquipType.FairyCan2);
+                        break;
+                    case RoleEquipType.JadeDynasty_Glove1:
+                        putOnModel2 = playerPack.GetItemByIndex(PackType.JadeDynastyEquip, (int)RoleEquipType.JadeDynasty_Glove2);
+                        break;
+                    case RoleEquipType.JadeDynasty_Ring1:
+                        putOnModel2 = playerPack.GetItemByIndex(PackType.JadeDynastyEquip, (int)RoleEquipType.JadeDynasty_Ring2);
+                        break;
+                }
+
+                switch ((RoleEquipType)chinItemModel.EquipPlace)
+                {
+                    case RoleEquipType.FairyCan:
+                    case RoleEquipType.JadeDynasty_Glove1:
+                    case RoleEquipType.JadeDynasty_Ring1:
+                        if (putOnModel2 != null)
+                        {
+                            if (putOnModel != null)
+                            {
+                                if (putOnModel2.equipScore < putOnModel.equipScore)
+                                {
+                                    putOnModel = putOnModel2;
+                                }
+                            }
+                        }
+                        else
+                        {
+                            putOnModel = putOnModel2;
+                        }
+                        break;
+                }
+
+                int equipScore1 = 0;
+                if (putOnModel != null)
+                {
+                    equipScore1 = (int)putOnModel.equipScore;
+                }
+
+                int playerJob = PlayerDatas.Instance.baseData.Job;
+
+                if (playerJob == Math.Floor((double)chinItemModel.JobLimit / 100) || chinItemModel.JobLimit == 0)
+                {
+                    if (equipScore1 > _score)
+                        return -1;
+                    else if (equipScore1 < _score)
+                        return 1;
+                    else
+                        return 0;
+                }
+                else
+                {
+                    return 0;
+                }
+            }
+            return 0;
+        }
+
+        #region 鐗╁搧鏄惁杩囨湡
+        public bool IsOverdue(string guid, int itemId, Dictionary<int, List<int>> useDataDict = null)
+        {
+            ItemConfig itemConfig = ItemConfig.Get(itemId);
+            if (itemConfig == null) return false;
+
+            if (itemConfig.ExpireTime > 0)
+            {
+                ItemCDCool cool = KnapsackTimeCDMgr.Instance.GetItemCoolById(guid);
+                switch ((EquipReduceType)itemConfig.EndureReduceType)
+                {
+                    case EquipReduceType.Def_EquipReduceType_Time:
+                        if (guid != "")
+                        {
+                            List<int> itemEffectTime = null;
+                            if (useDataDict != null)
+                            {
+                                if (useDataDict.ContainsKey((int)ItemUseDataKey.createTime))
+                                {
+                                    itemEffectTime = useDataDict[(int)ItemUseDataKey.createTime];
+                                }
+                            }
+
+                            if (itemEffectTime != null && itemEffectTime[0] != 0)
+                            {
+                                if (cool == null || cool.GetRemainTime() <= 0)
+                                {
+                                    return true;
+                                }
+                            }
+                        }
+                        break;
+
+                    case EquipReduceType.Def_EquipReduceType_RTimeItem:
+                        if (guid != "")
+                        {
+                            if (cool == null || cool.GetRemainTime() <= 0)
+                            {
+                                return true;
+                            }
+                        }
+                        break;
+
+                }
+            }
+
+            return false;
+        }
+        #endregion
+    }
+}

--
Gitblit v1.8.0