From cd69ff158ae8ffa10d9fd1b4971ebf7d2ed74c7c Mon Sep 17 00:00:00 2001
From: xdh <xiefantasy@qq.com>
Date: 星期二, 25 十二月 2018 17:29:34 +0800
Subject: [PATCH] 5580 【后端】【1.3.20】【1.3.100】【1.4】仙盟任务奖励背包已满时的处理

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/UseItem/Item_Chests.py |   71 ++++++++++++++++++++++++++---------
 1 files changed, 53 insertions(+), 18 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/UseItem/Item_Chests.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/UseItem/Item_Chests.py
index 199fcec..bd1d3cd 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/UseItem/Item_Chests.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/UseItem/Item_Chests.py
@@ -41,7 +41,7 @@
     if showType:
         useCnt = 1
         
-    isBind = int(curRoleItem.GetIsBind() or chestsIpyData.GetIsBind()) # 奖励物品是否绑定
+    isBind = int(chestsIpyData.GetIsBind()) # 奖励物品是否绑定
     costItemID = chestsIpyData.GetCostItemID()
     costItemCountTotal = chestsIpyData.GetCostItemCount() * useCnt
     costGoldTotal = chestsIpyData.GetCostGold() * useCnt
@@ -62,15 +62,15 @@
     awardInfo = GetChestsAwardInfo(curPlayer, chestsItemID, useCnt, exData)
     if not awardInfo:
         return
-    needSpaceMax, needSpaceDict, jobAwardItemDict, moneyType, moneyCount, notifyItemList = awardInfo
-    GameWorld.DebugLog("    needSpaceDict=%s,jobAwardItemDict=%s,moneyType=%s,moneyCount=%s,notifyItemList=%s" 
-                       % (needSpaceDict, jobAwardItemDict, moneyType, moneyCount, notifyItemList))
+    needSpaceDict, jobAwardItemList, moneyType, moneyCount, notifyItemList, updOpenCount = awardInfo
+    GameWorld.DebugLog("    needSpaceDict=%s,jobAwardItemList=%s,moneyType=%s,moneyCount=%s,notifyItemList=%s,updOpenCount=%s" 
+                       % (needSpaceDict, jobAwardItemList, moneyType, moneyCount, notifyItemList, updOpenCount))
     
     for packType, needSpace in needSpaceDict.items():
         packSpace = ItemCommon.GetItemPackSpace(curPlayer, packType, needSpace)
         if packSpace < needSpace:
             #PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [packType])
-            PlayerControl.NotifyCode(curPlayer, "OpenBoxItem", [packType, chestsItemID, needSpaceMax - packSpace])
+            PlayerControl.NotifyCode(curPlayer, "OpenBoxItem", [packType, chestsItemID, needSpace - packSpace])
             return
         
     # 扣除消耗
@@ -80,12 +80,17 @@
         infoDict = {ChConfig.Def_Cost_Reason_SonKey:chestsItemID}
         PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, costGoldTotal, ChConfig.Def_Cost_UseItem, infoDict)
         
-    saveDataDict = {"AwardItem":jobAwardItemDict}
+    # 更新开启次数
+    if updOpenCount:
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ChestsOpenCount % chestsItemID, updOpenCount)
+        GameWorld.DebugLog("    更新宝箱开启次数: %s" % updOpenCount)
+        
+    saveDataDict = {"AwardItem":jobAwardItemList}
     ItemCommon.DelItem(curPlayer, curRoleItem, useCnt, True, ChConfig.ItemDel_Chests, saveDataDict)
     
     # 给奖励
     syncItemList = []
-    for itemID, itemCount in jobAwardItemDict.items():
+    for itemID, itemCount in jobAwardItemList:
         curItem = ItemControler.GetOutPutItemObj(itemID, itemCount, isBind)
         if not curItem:
             GameWorld.ErrLog("宝箱创建奖励物品异常!chestsItemID=%s,useCnt=%s,itemID=%s,itemCount=%s,isBind=%s" 
@@ -115,14 +120,13 @@
 def GetChestsAwardInfo(curPlayer, chestsItemID, useCount, exData=0):
     '''获取宝箱开启奖励
     @return: None - 获取宝箱奖励失败
-    @return: needSpaceMax, needSpaceDict, jobAwardItemDict{itemID:itemCount, ...}
+    @return: needSpaceDict, jobAwardItemList [[itemID, itemCount], ...]
     '''
     
     awardIpyData = __GetChestsAwardIpyDataByLV(curPlayer, chestsItemID)
     if not awardIpyData:
         return
     
-    needSpaceMax = 0
     awardItemDict = {}
     job = curPlayer.GetJob()
     jobItemList = awardIpyData.GetJobItemList()
@@ -147,32 +151,59 @@
         if not isSelectOK:
             GameWorld.ErrLog("选择的物品错误, 该宝箱没有该物品!chestsItemID=%s,selectItemID=%s" % (chestsItemID, selectItemID))
             return
-        needSpaceMax += 1
         
     # 固定产出物品
     if awardIpyData.GetFixedItemDict():
         for itemID, itemCount in awardIpyData.GetFixedItemDict().items():
-            needSpaceMax += 1
             __AddAwardItem(awardItemDict, itemID, itemCount * useCount)
             
     # 随机物品库1
     if awardIpyData.GetRandItemList1() and awardIpyData.GetRandTimeList1():
         if not __AddChestsRandAwardItem(curPlayer, chestsItemID, useCount, awardItemDict, awardIpyData.GetRandItemList1(), awardIpyData.GetRandTimeList1()):
             return
-        needSpaceMax += __GetMaxRandTime(awardIpyData.GetRandTimeList1())
+        
+    # 根据宝箱开启次数特殊产出
+    updOpenCount = 0
+    randItemList2DoCount = useCount
+    randItemByUseCountDict = awardIpyData.GetRandItemByUseCount()
+    if randItemByUseCountDict:
+        maxOpenCount = max(randItemByUseCountDict)
+        hisOpenCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ChestsOpenCount % chestsItemID)
+        if hisOpenCount < maxOpenCount:
+            updOpenCount = min(hisOpenCount + useCount, maxOpenCount)
+            for specUseCount, randItemList in randItemByUseCountDict.items():
+                if not (hisOpenCount < specUseCount <= updOpenCount):
+                    GameWorld.DebugLog("    不满足特殊次数产出: hisOpenCount=%s,specUseCount=%s,updOpenCount=%s" 
+                                       % (hisOpenCount, specUseCount, updOpenCount))
+                    continue
+                randItemList2DoCount -= 1
+                randItemInfo = GameWorld.GetResultByRandomList(randItemList)
+                GameWorld.DebugLog("    根据开启次数特殊产出: specUseCount=%s, %s, randItemList2DoCount=%s" 
+                                   % (specUseCount, randItemInfo, randItemList2DoCount))
+                if not randItemInfo:
+                    continue
+                if len(randItemInfo) != 2:
+                    GameWorld.ErrLog("宝箱开启次数特殊产出随机库配置错误!chestsItemID=%s" % chestsItemID)
+                    return
+                itemID, itemCount = randItemInfo
+                if not itemID:
+                    continue
+                __AddAwardItem(awardItemDict, itemID, itemCount)
+            
+    if randItemList2DoCount != useCount:
+        GameWorld.DebugLog("    随机物品库2执行次数: %s" % (randItemList2DoCount))
         
     # 随机物品库2
-    if awardIpyData.GetRandItemList2() and awardIpyData.GetRandTimeList2():
-        if not __AddChestsRandAwardItem(curPlayer, chestsItemID, useCount, awardItemDict, awardIpyData.GetRandItemList2(), awardIpyData.GetRandTimeList2()):
+    if awardIpyData.GetRandItemList2() and awardIpyData.GetRandTimeList2() and randItemList2DoCount:
+        if not __AddChestsRandAwardItem(curPlayer, chestsItemID, randItemList2DoCount, awardItemDict, awardIpyData.GetRandItemList2(), awardIpyData.GetRandTimeList2()):
             return
-        needSpaceMax += __GetMaxRandTime(awardIpyData.GetRandTimeList2())
     
     # 产出特殊物品广播
     needNotifyItemList = awardIpyData.GetNeedNotifyItemList()
     
     needSpaceDict = {} # {packType:needSpace, ...}
     notifyItemList = []
-    jobAwardItemDict = {}
+    jobAwardItemList = []
     for itemID, itemCount in awardItemDict.items():
         jobItemID = __GetChestsJobItem(chestsItemID, job, itemID, jobItemList)
         if not jobItemID:
@@ -186,11 +217,15 @@
         needSpace = int(math.ceil(itemCount / float(itemData.GetPackCount())))
         needSpaceDict[packType] = needSpaceDict.get(packType, 0) + needSpace
         
-        jobAwardItemDict[jobItemID] = itemCount
+        # 装备拆开给,需要同步每件装备的属性
+        if ItemCommon.GetIsEquip(itemData):
+            jobAwardItemList.extend([[jobItemID, 1]] * itemCount)
+        else:
+            jobAwardItemList.append([jobItemID, itemCount])
         if itemID in needNotifyItemList or jobItemID in needNotifyItemList:
             notifyItemList.append(jobItemID)
             
-    return needSpaceMax, needSpaceDict, jobAwardItemDict, awardIpyData.GetMoneyType(), awardIpyData.GetMoneyCount() * useCount, notifyItemList
+    return needSpaceDict, jobAwardItemList, awardIpyData.GetMoneyType(), awardIpyData.GetMoneyCount() * useCount, notifyItemList, updOpenCount
 
 def __GetMaxRandTime(randTimeList):
     if len(randTimeList) == 1 and type(randTimeList[0]) == int:

--
Gitblit v1.8.0