From aab7e5a8c81a4bc4ad2af6df8a934d78682ecc47 Mon Sep 17 00:00:00 2001
From: Client_PangDeRong <593317293@qq.com>
Date: 星期二, 13 十一月 2018 17:26:31 +0800
Subject: [PATCH] 4534 【1.3】【前端】组队功能和助战积分优化
---
System/Store/StoreModel.cs | 254 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 254 insertions(+), 0 deletions(-)
diff --git a/System/Store/StoreModel.cs b/System/Store/StoreModel.cs
index e26af1d..a58834a 100644
--- a/System/Store/StoreModel.cs
+++ b/System/Store/StoreModel.cs
@@ -109,6 +109,260 @@
isLogin = false;
}
+ #region 瑙f瀽鏈湴鏁版嵁
+ public Dictionary<int, List<int>> storeRedRuleDict { get; private set; } //绾㈢偣绫诲瀷 1,鍏嶈垂鍟嗗搧 2,蹇呬拱鍟嗗搧 3,鍧愰獞鐏靛疇 4,鍙喘涔扮墿鍝侊紙绉垎鍏戞崲锛�
+ public Dictionary<int, List<int>> storePushDict { get; private set; } //1锛屾瘡鏃ュ脊1娆�2,鍙脊1娆�
+ private void ParseFuncConfig()
+ {
+ storeRedRuleDict = new Dictionary<int, List<int>>();
+ storePushDict = new Dictionary<int, List<int>>();
+ FuncConfigConfig storeRedRules = Config.Instance.Get<FuncConfigConfig>("StoreRedRules");
+ if(storeRedRules != null)
+ {
+ JsonData redRules = JsonMapper.ToObject(storeRedRules.Numerical1);
+ foreach(var type in redRules.Keys)
+ {
+ int redType = 0;
+ int.TryParse(type,out redType);
+ JsonData shops = redRules[type];
+ if (!storeRedRuleDict.ContainsKey(redType))
+ {
+ List<int> shopIdlist = new List<int>();
+ if(shops.IsArray)
+ {
+ for(int i = 0; i < shops.Count; i++)
+ {
+ int shopId = 0;
+ int.TryParse(shops[i].ToString(),out shopId);
+ shopIdlist.Add(shopId);
+ }
+ }
+ storeRedRuleDict.Add(redType,shopIdlist);
+ }
+ }
+
+ JsonData pushRules = JsonMapper.ToObject(storeRedRules.Numerical2);
+ foreach(var type in pushRules.Keys)
+ {
+ int pushType = 0;
+ int.TryParse(type,out pushType);
+ JsonData shops = pushRules[type];
+ if (!storePushDict.ContainsKey(pushType))
+ {
+ List<int> shopIdlist = new List<int>();
+ if (shops.IsArray)
+ {
+ for (int i = 0; i < shops.Count; i++)
+ {
+ int shopId = 0;
+ int.TryParse(shops[i].ToString(), out shopId);
+ shopIdlist.Add(shopId);
+ }
+ }
+ storePushDict.Add(pushType, shopIdlist);
+ }
+ }
+ }
+ }
+
+ public Dictionary<int,List<StoreConfig>> storeTypeDict { get; private set; }
+ private void ParseStoreConfig()
+ {
+ storeTypeDict = new Dictionary<int, List<StoreConfig>>();
+ List<StoreConfig> storeConfigs = Config.Instance.GetAllValues<StoreConfig>();
+ for(int i = 0; i < storeConfigs.Count; i++)
+ {
+ var config = storeConfigs[i];
+ if(config.ShopType != 0)
+ {
+ if(!storeTypeDict.ContainsKey(config.ShopType))
+ {
+ List<StoreConfig> configs = new List<StoreConfig>();
+ configs.Add(config);
+ storeTypeDict.Add(config.ShopType,configs);
+ }
+ else
+ {
+ storeTypeDict[config.ShopType].Add(config);
+ }
+ }
+ }
+
+ foreach(var type in storeTypeDict.Keys)
+ {
+ var configs = storeTypeDict[type];
+ configs.Sort(CompareByShopSort);
+ }
+ }
+
+ public int CompareByShopSort(StoreConfig start, StoreConfig end)
+ {
+ int sort1 = start.ShopSort;
+ int sort2 = end.ShopSort;
+ if (sort1.CompareTo(sort2) != 0) return sort1.CompareTo(sort2);
+
+ return 0;
+ }
+ #endregion
+
+ #region 鑾峰彇鏁版嵁
+ public bool TryGetRedTypeByShopId(int shopId, out int type)
+ {
+ type = 0;
+ foreach (var key in storeRedRuleDict.Keys)
+ {
+ List<int> idlist = storeRedRuleDict[key];
+ if (idlist.Contains(shopId))
+ {
+ type = key;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public bool TryGetPushTypeByShopId(int shopId, out int type)
+ {
+ type = 0;
+ foreach (var key in storePushDict.Keys)
+ {
+ List<int> idlist = storePushDict[key];
+ if (idlist.Contains(shopId))
+ {
+ type = key;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private Dictionary<int, List<StoreConfig>> showStoreTypeDict = new Dictionary<int, List<StoreConfig>>();
+ public void UpdateShowStore()
+ {
+ showStoreTypeDict.Clear();
+ foreach(var type in storeTypeDict.Keys)
+ {
+ var configs = storeTypeDict[type];
+ List<StoreConfig> showConfigs = new List<StoreConfig>();
+ if(!showStoreTypeDict.ContainsKey(type))
+ {
+ for (int i = 0; i < configs.Count; i++)
+ {
+ var config = configs[i];
+ int remainNum = 0;
+ bool isSellOut = TryGetIsSellOut(config, out remainNum);
+ if(isSellOut && config.TheOnlyShop == 1)
+ {
+
+ }
+ }
+ }
+ }
+ }
+
+ public bool TryGetIsSellOut(StoreConfig storeConfig, out int remainCnt)
+ {
+ int canBuyCnt = 0;
+ int addBuyCnt = 0;
+ remainCnt = 0;
+ bool isLimitBuy = TryGetLimitBuy(storeConfig, out canBuyCnt, out addBuyCnt);
+ if (!isLimitBuy) return false;
+
+ int remainNum = canBuyCnt;
+ BuyShopItemLimit shopItemLimit = GetBuyShopLimit((uint)storeConfig.ID);
+ if (shopItemLimit != null)
+ {
+ remainNum -= shopItemLimit.BuyCnt;
+ }
+
+ if (remainNum <= 0)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public bool TryGetLimitBuy(StoreConfig config, out int canBuyCnt, out int addBuyCnt)
+ {
+ canBuyCnt = 0;
+ addBuyCnt = 0;
+ if (config == null) return false;
+
+ int[] canBuyNums = config.PurchaseNumber;
+ if (canBuyNums == null || canBuyNums.Length < 1) return false;
+
+ int curVipIndex = -1;
+ int nexVipIndex = -1;
+ bool isVipBuy = TryGetVipBuy(config, out curVipIndex, out nexVipIndex);
+ if (isVipBuy)
+ {
+ if (curVipIndex != -1)
+ {
+ canBuyCnt = canBuyNums[curVipIndex];
+ }
+
+ if (nexVipIndex != -1)
+ {
+ addBuyCnt = canBuyNums[nexVipIndex] - canBuyCnt;
+ }
+ return true;
+ }
+ else
+ {
+ if (canBuyNums[0] != 0)
+ {
+ canBuyCnt = canBuyNums[0];
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+ public bool TryGetVipBuy(StoreConfig config, out int curVipIndex, out int nextVipIndex)
+ {
+ curVipIndex = -1;
+ nextVipIndex = -1;
+ bool isVipBuy = false;
+ if (config == null) return false;
+
+ var vipLvs = config.VIPLV;
+ if (vipLvs == null || vipLvs.Length < 1) return false;
+
+ for(int i = 0; i < vipLvs.Length; i++)
+ {
+ var vipLv = vipLvs[i];
+ if(vipLv != 0)
+ {
+ isVipBuy = true;
+ }
+ }
+
+ if (isVipBuy)
+ {
+ int playerVip = PlayerDatas.Instance.baseData.VIPLv;
+ for (int i = vipLvs.Length - 1; i > -1; i--)
+ {
+ var vipLv = vipLvs[i];
+ if (vipLv > playerVip)
+ {
+ nextVipIndex = i;
+ }
+ else if (vipLv <= playerVip)
+ {
+ curVipIndex = i;
+ break;
+ }
+ }
+
+ }
+
+ return isVipBuy;
+ }
+ #endregion
+
public string GetStoreRefreshTimeByType(int type)
{
if (resetTimeDict == null || !resetTimeDict.ContainsKey(type)) return string.Empty;
--
Gitblit v1.8.0