From 65a4c2029af3f70ce484a2eec167c50f227d7a5c Mon Sep 17 00:00:00 2001
From: xdh <xiefantasy@qq.com>
Date: 星期一, 27 五月 2019 14:08:22 +0800
Subject: [PATCH] 6805 【后端】【2.0】副本前端化(封魔坛前期本)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/Operate_ItemCompound.py |  136 ++++++++++++++++++++++++++++++---------------
 1 files changed, 90 insertions(+), 46 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/Operate_ItemCompound.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/Operate_ItemCompound.py
index 2a65f95..8e71809 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/Operate_ItemCompound.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/Operate_ItemCompound.py
@@ -71,6 +71,7 @@
         GameWorld.ErrLog("找不到该合成表数据配置! ID=%s" % compoundID)
         return
     
+    composeGroup = ipyData.GetComposeGroup()
     makeIDList = ipyData.GetMakeID()
     unfixedItemIDList = ipyData.GetUnfixedItemID()
     fixedItemIDList = ipyData.GetFixedItemID()
@@ -92,12 +93,16 @@
         GameWorld.ErrLog("不存在该合成物品! makeItemID=%s" % makeItemID)
         return
     
+    packType = ChConfig.GetItemPackType(makeItemData.GetType(), IPY_GameWorld.rptItem)
+    GameWorld.DebugLog("makeItemID=%s,packType=%s" % (makeItemID, packType), playerID)
+    
     needSpace = int(math.ceil(float(compoundCnt) / makeItemData.GetPackCount()))
-    emptySpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, needSpace)
+    emptySpace = ItemCommon.GetItemPackSpace(curPlayer, packType, needSpace)
     #验证背包空间
     if needSpace > emptySpace:
-        PlayerControl.NotifyCode(curPlayer, "GeRen_lhs_202580")
-        GameWorld.DebugLog("背包空间不足!needSpace=%s > emptySpace=%s" % (needSpace, emptySpace), playerID)
+        #PlayerControl.NotifyCode(curPlayer, "GeRen_lhs_202580")
+        PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [packType])
+        GameWorld.DebugLog("背包空间不足!packType=%s,needSpace=%s > emptySpace=%s" % (packType, needSpace, emptySpace), playerID)
         return
     
     compoundBindCnt = 0
@@ -122,7 +127,8 @@
     canDecompound = makeItemData.GetType() in canDecompoundItemTypeList and makeItemData.GetItemColor() >= decompoundMinColor
     decompoundItemInfo = [] # 拆解返还物品列表 [装备ID,材料1ID,个数,是否绑定,材料2ID,个数,是否绑定,...]
     
-    itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
+    itemPack = curPlayer.GetItemManager().GetPack(packType)
+    itemExpireTime = 0
     wingItemExpInfo = None #材料翅膀精炼信息
     dogzEquipPlusExp = 0 #神兽装备强化熟练度
     # 检查不固定消耗道具
@@ -130,30 +136,32 @@
         unfixedItem = GameWorld.GetGameData().GetItemByTypeID(unfixedItemIDList[0])
         if not unfixedItem:
             return
-        if ItemCommon.GetIsDogzEquip(unfixedItem):
-            unfixedItemPack = curPlayer.GetItemManager().GetPack(ShareDefine.rptDogzItem)
-        else:
-            unfixedItemPack = itemPack
-        unfixedItemCostInfo = __CheckUnfixedItem(playerID, compoundID, makeItemData, unfixedItemPack, unfixedItemIndexList, 
+        unfixedItemCostInfo = __CheckUnfixedItem(playerID, compoundID, makeItemData, itemPack, unfixedItemIndexList, 
                                                  unfixedItemIDList, needUnfixedItemCount)
         if not unfixedItemCostInfo:
             return
-        unfixedItemCostList, wingItemExpInfo, dogzEquipPlusExp = unfixedItemCostInfo
-    
+        unfixedItemCostList, wingItemExpInfo, dogzEquipPlusExp, expireTime = unfixedItemCostInfo
+        if expireTime:
+            itemExpireTime = expireTime if not itemExpireTime else min(itemExpireTime, expireTime)
+        
     # 检查固定消耗道具
     if fixedItemIDList:
         fixedItemInfo = __CheckFixedItem(playerID, compoundID, itemPack, fixedItemIndexList, fixedItemIDList, fixedItemCountList, compoundCnt)
         if not fixedItemInfo:
             return
-        fixedItemIndexDict, fixedItemNeedCntDict, compoundBindCnt = fixedItemInfo
-    
+        fixedItemIndexDict, fixedItemNeedCntDict, compoundBindCnt, expireTime = fixedItemInfo
+        if expireTime:
+            itemExpireTime = expireTime if not itemExpireTime else min(itemExpireTime, expireTime)
+        
     # 检查附加道具增加成功率消耗
     addSuccRate, addSuccRateItemInfo = 0, []
     if addonsCountMax > 0:
         addSuccRateInfo = __CheckAddonsItem(playerID, compoundID, itemPack, addonsItemIndexList, addonsItemCountList, addonsCountMax)
         if addSuccRateInfo == None:
             return
-        addSuccRate, addSuccRateItemInfo = addSuccRateInfo
+        addSuccRate, addSuccRateItemInfo, expireTime = addSuccRateInfo
+        if expireTime:
+            itemExpireTime = expireTime if not itemExpireTime else min(itemExpireTime, expireTime)
     
     # 检查提升概率道具
     incRateItemCostList, needIncRateItemCount, incRate = [], 0, 0
@@ -162,19 +170,21 @@
         incRateItemInfo = __CheckIncRateItem(playerID, compoundID, itemPack, incRateItemIndexList, incRateItemID, needIncRateItemCount)
         if not incRateItemInfo:
             return
-        incRateItemCostList = incRateItemInfo
+        incRateItemCostList, expireTime = incRateItemInfo
+        if expireTime:
+            itemExpireTime = expireTime if not itemExpireTime else min(itemExpireTime, expireTime)
         
     # 扣铜钱
     PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Silver_Money, totalNeedMoney, ChConfig.Def_Cost_ItemProduce, 
                            {ChConfig.Def_Cost_Reason_SonKey:makeItemID, "CompoundCount":compoundCnt})
     
-    drDict = {"CompoundID":compoundID, "MakeItemID":makeItemID, "CompoundCount":compoundCnt}
+    drDict = {"CompoundID":compoundID, "MakeItemID":makeItemID, "CompoundCount":compoundCnt, "itemExpireTime":itemExpireTime, "PackType":packType}
     makeItemBind = False
     
     # 扣不固定消耗物品
     if unfixedItemIDList:
         bindUnfixedIndexList, unbindUnfixedIndexList = unfixedItemCostList
-        hasBind = ItemCommon.ReduceItem(curPlayer, unfixedItemPack, bindUnfixedIndexList + unbindUnfixedIndexList, needUnfixedItemCount, 
+        hasBind = ItemCommon.ReduceItem(curPlayer, itemPack, bindUnfixedIndexList + unbindUnfixedIndexList, needUnfixedItemCount, 
                                         False, ChConfig.ItemDel_ItemCompound, drDict)
         makeItemBind = True if hasBind else makeItemBind
         
@@ -223,12 +233,16 @@
         totalSuccRate = min(successRateMax, totalSuccRate)
     GameWorld.DebugLog("合成成功率: successRate=%s,addSuccRate=%s,incRate=%s,successRateMax=%s,totalSuccRate=%s" 
                        % (successRate, addSuccRate, incRate, successRateMax, totalSuccRate), playerID)
-    # 首次合成一代翅膀成功率百分百
-    if makeItemData.GetType() == ChConfig.Def_ItemType_retWing and ItemCommon.GetWingLV(makeItemData) == 1:
-        if not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HadCompoundWing):
+    # 前X次合成成功率百分百
+    composeMustSuccessDict = IpyGameDataPY.GetFuncEvalCfg("ComposeMustSuccess", 1, {})
+    if composeGroup in composeMustSuccessDict:
+        mustSuccessCountTotal = composeMustSuccessDict[composeGroup]
+        hisComposeCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ComposeMustSuccess % composeGroup)
+        if hisComposeCount < mustSuccessCountTotal:
             totalSuccRate = ShareDefine.Def_MaxRateValue
-            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_HadCompoundWing, 1)
-            GameWorld.DebugLog("首次合成一代翅膀,必定成功!totalSuccRate=%s" % totalSuccRate, playerID)
+            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ComposeMustSuccess % composeGroup, hisComposeCount + 1)
+            GameWorld.DebugLog("前X次合成必定成功!composeGroup=%s,hisComposeCount=%s,mustSuccessCountTotal=%s,totalSuccRate=%s" 
+                               % (composeGroup, hisComposeCount, mustSuccessCountTotal, totalSuccRate), playerID)
             
     # 合成成功
     maxRateValue = ShareDefine.Def_MaxRateValue
@@ -240,13 +254,13 @@
     if successRate != maxRateValue:
         drDict = {"PlayerID":curPlayer.GetPlayerID(), "AccID":curPlayer.GetAccID(), "ID":compoundID, "MakeItemID":makeItemID, "IsSuccess":canHappen,
                   "RateInfo":{"totalSuccRate":"%s(%s+%s+%s)" % (totalSuccRate, successRate, addSuccRate, incRate), "randValue":randValue, "maxRateValue":maxRateValue},
-                  "AddSuccRateItemInfo":addSuccRateItemInfo
+                  "AddSuccRateItemInfo":addSuccRateItemInfo, "PackType":packType,
                   }
         DataRecordPack.SendEventPack("ItemCompound", drDict, curPlayer)
         
     if canHappen:
-        GameWorld.DebugLog("合成成功: makeItemID=%s,compoundCnt=%s,compoundBindCnt=%s" % (makeItemID, compoundCnt, compoundBindCnt), playerID)
-        userData = GiveNewCompoundItem(curPlayer, makeItemID, compoundCnt, compoundBindCnt, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo)
+        GameWorld.DebugLog("合成成功: makeItemID=%s,compoundCnt=%s,compoundBindCnt=%s,itemExpireTime=%s" % (makeItemID, compoundCnt, compoundBindCnt, itemExpireTime), playerID)
+        userData = GiveNewCompoundItem(curPlayer, packType, makeItemID, compoundCnt, compoundBindCnt, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo, itemExpireTime)
         
         msgMark = ipyData.GetSysMark()
         paramType = ipyData.GetSysMarkParamType()
@@ -264,12 +278,12 @@
         ItemCommon.SyncMakeItemAnswer(curPlayer, ShareDefine.Def_mitItemCompound, ChConfig.Def_ComposeState_Sucess, makeItemID)
         #成功合成1个物品成就
         PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_CompoundItemEx, compoundCnt, [makeItemID])
-        #合成X阶X颜色X星级以上装备
-        classLV = ItemCommon.GetItemClassLV(makeItemData)
-        itemColor = makeItemData.GetItemColor()
-        itemQuality = makeItemData.GetItemQuality()
-        PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_CompoundEquip, compoundCnt, [classLV, itemColor, itemQuality])
-        EventShell.EventRespons_CompoundEquip(curPlayer, itemColor, itemQuality)
+        #合成X阶X颜色X星级以上装备, 星级改为装备位了,暂时没有用,屏蔽
+        #classLV = ItemCommon.GetItemClassLV(makeItemData)
+        #itemColor = makeItemData.GetItemColor()
+        #itemQuality = makeItemData.GetItemQuality()
+        #PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_CompoundEquip, compoundCnt, [classLV, itemColor, itemQuality])
+        #EventShell.EventRespons_CompoundEquip(curPlayer, itemColor, itemQuality)
     # 合成失败
     else:
         GameWorld.DebugLog("合成失败!")
@@ -285,6 +299,7 @@
 
 def __CheckUnfixedItem(playerID, compoundID, makeItemData, itemPack, unfixedItemIndexList, unfixedItemIDList, needUnfixedItemCount):
     ## 检查不固定消耗道具, 只要客户端提交的数据有不符合要求的,则直接返回 None
+    expireTime = 0
     wingItemExpInfo = None
     dogzEquipPlusExp = 0
     unfixedItemTotalCount = 0
@@ -304,6 +319,13 @@
                           % (compoundID, index, itemID, unfixedItemIDList), playerID)
             return
         
+        isExpireItem, remainingTime = ItemCommon.GetItemRemainingTime(curItem)
+        if isExpireItem:
+            if not remainingTime:
+                GameWorld.Log("不固定消耗道具时效物品已失效,无法合成! index=%s,itemID=%s" % (index, itemID), playerID)
+                return
+            expireTime = remainingTime if not expireTime else min(expireTime, remainingTime)
+            
         isBind = curItem.GetIsBind()
         itemCount = curItem.GetCount()
         unfixedItemTotalCount += itemCount
@@ -324,7 +346,7 @@
                       % (compoundID, unfixedItemIDList, needUnfixedItemCount, unfixedItemTotalCount), playerID)
         return
     
-    return unfixedItemCostList, wingItemExpInfo, dogzEquipPlusExp
+    return unfixedItemCostList, wingItemExpInfo, dogzEquipPlusExp, expireTime
 
 
 def __CheckFixedItem(playerID, compoundID, itemPack, fixedItemIndexList, fixedItemIDList, fixedItemCountList, compoundCnt):
@@ -338,6 +360,7 @@
                       % (fixedItemIDList, fixedItemCountList), playerID)
         return
     
+    expireTime = 0
     for index in fixedItemIndexList:
         if index >= maxPackCount:
             GameWorld.Log("该物品格子索引不存在!无法合成!index=%s,maxPackCount=%s" % (index, maxPackCount), playerID)
@@ -352,6 +375,13 @@
                           % (compoundID, index, fixedItemID, fixedItemIDList), playerID)
             return
         
+        isExpireItem, remainingTime = ItemCommon.GetItemRemainingTime(curItem)
+        if isExpireItem:
+            if not remainingTime:
+                GameWorld.Log("固定消耗道具时效物品已失效,无法合成! index=%s,fixedItemID=%s" % (index, fixedItemID), playerID)
+                return
+            expireTime = remainingTime if not expireTime else min(expireTime, remainingTime)
+            
         isBind = curItem.GetIsBind()
         itemCount = curItem.GetCount()
         bindIndex = 0 if isBind else 1
@@ -435,7 +465,7 @@
             return
         
     GameWorld.DebugLog("最终消耗材料个数: %s" % (fixedItemNeedCntDict))
-    return fixedItemIndexDict, fixedItemNeedCntDict, compoundBindCnt
+    return fixedItemIndexDict, fixedItemNeedCntDict, compoundBindCnt, expireTime
 
 
 def __CheckAddonsItem(playerID, compoundID, itemPack, addonsItemIndexList, addonsItemCountList, addonsCountMax):
@@ -456,6 +486,7 @@
                       % (addonsItemIndexList, addonsItemCountList), playerID)
         return
     
+    expireTime = 0
     useCount = 0
     addTotalSuccRate = 0
     for i, index in enumerate(addonsItemIndexList):
@@ -495,14 +526,22 @@
             GameWorld.Log("附加物品总个数超出限制,无法合成! useCount=%s > addonsCountMax=%s" % (useCount, addonsCountMax), playerID)
             return
         
+        isExpireItem, remainingTime = ItemCommon.GetItemRemainingTime(curItem)
+        if isExpireItem:
+            if not remainingTime:
+                GameWorld.Log("附加材料时效物品已失效,无法合成! index=%s,itemID=%s" % (index, itemID), playerID)
+                return
+            expireTime = remainingTime if not expireTime else min(expireTime, remainingTime)
+            
         addSuccRate = eval(FormulaControl.GetCompileFormula("ComposeAddonsFormula", ComposeAddonsFormula))
         addTotalSuccRate += (addSuccRate*costCount)
         addSuccRateItemInfo.append({"ItemID":itemID, "ItemColor":itemColor, "ItemClassLV":itemClassLV, "addSuccRate":addSuccRate, "costCount":costCount})
         
-    return int(addTotalSuccRate), addSuccRateItemInfo
+    return int(addTotalSuccRate), addSuccRateItemInfo, expireTime
 
 def __CheckIncRateItem(playerID, compoundID, itemPack, incRateItemIndexList, incRateItemID, needIncRateItemCount):
     ## 检查提升概率道具, 只要客户端提交的数据有不符合要求的,则直接返回 None
+    expireTime = 0
     incRateItemTotalCount = 0
     incRateItemCostList = [[], []] # [[绑定索引], [非绑定索引]]
     maxPackCount = itemPack.GetCount()
@@ -519,7 +558,13 @@
             GameWorld.Log("该物品不可用于提升合成目标物品概率!ID=%s,index=%s,itemID=%s != incRateItemID=%s" 
                           % (compoundID, index, itemID, incRateItemID), playerID)
             return
-        
+        isExpireItem, remainingTime = ItemCommon.GetItemRemainingTime(curItem)
+        if isExpireItem:
+            if not remainingTime:
+                GameWorld.Log("提升概率时效物品已失效,无法合成! index=%s,itemID=%s" % (index, itemID), playerID)
+                return
+            expireTime = remainingTime if not expireTime else min(expireTime, remainingTime)
+            
         isBind = curItem.GetIsBind()
         itemCount = curItem.GetCount()
         incRateItemTotalCount += itemCount
@@ -530,10 +575,10 @@
                       % (compoundID, incRateItemID, needIncRateItemCount, incRateItemTotalCount), playerID)
         return
     
-    return incRateItemCostList
+    return incRateItemCostList, expireTime
 
 def __CheckItemCanUseCompound(playerID, index, curItem):
-    if not ItemCommon.CheckItemCanUse(curItem):
+    if not ItemCommon.CheckItemCanUse(curItem) or ItemControler.GetIsAuctionItem(curItem):
         GameWorld.DebugLog("该物品不可使用!无法合成! index=%s" % (index), playerID)
         return
     
@@ -556,21 +601,21 @@
 #  @param newItem: 新物品
 #  @param itemCount: 合成数量
 #  @return None
-def GiveNewCompoundItem(curPlayer, newItemID, itemCount, compoundBindCnt, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo):
+def GiveNewCompoundItem(curPlayer, packType, newItemID, itemCount, compoundBindCnt, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo, itemExpireTime):
     compoundUnBindCnt = itemCount - compoundBindCnt
     
     if compoundBindCnt > 0:
-        userData = __GivePlayerCompoundItem(curPlayer, newItemID, compoundBindCnt, True, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo)
+        userData = __GivePlayerCompoundItem(curPlayer, packType, newItemID, compoundBindCnt, True, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo, itemExpireTime)
     if compoundUnBindCnt > 0:
-        userData = __GivePlayerCompoundItem(curPlayer, newItemID, compoundUnBindCnt, False, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo)
+        userData = __GivePlayerCompoundItem(curPlayer, packType, newItemID, compoundUnBindCnt, False, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo, itemExpireTime)
         
     if not userData:
         return ""
     return userData
 
-def __GivePlayerCompoundItem(curPlayer, newItemID, itemCount, isBind, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo):
+def __GivePlayerCompoundItem(curPlayer, packType, newItemID, itemCount, isBind, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo, expireTime):
     playerID = curPlayer.GetPlayerID()
-    curSingleItem = ItemControler.GetOutPutItemObj(newItemID, itemCount, isBind)
+    curSingleItem = ItemControler.GetOutPutItemObj(newItemID, itemCount, False, expireTime, curPlayer=curPlayer)
     if not curSingleItem:
         GameWorld.ErrLog("创造物品失败, give item itemid:%s,count:%s" % (newItemID, itemCount), playerID)
         return
@@ -608,8 +653,7 @@
         GameWorld.Log("保存可拆解装备拆解物品信息: %s" % decompoundItemInfo, playerID)
         
     userData = curSingleItem.GetUserData()
-    if not ItemControler.PlayerItemControler(curPlayer).PutInItem(IPY_GameWorld.rptItem, curSingleItem, 
-                                                                  event=[ChConfig.ItemGive_ItemCompound, False, {}]):
+    if not ItemControler.PlayerItemControler(curPlayer).PutInItem(packType, curSingleItem, event=[ChConfig.ItemGive_ItemCompound, False, {}]):
         GameWorld.ErrLog("给合成物品失败, give item itemid:%s,count:%s" % (newItemID, itemCount), playerID)
         curSingleItem.Clear()
         return
@@ -666,7 +710,7 @@
         return
     curEquip = itemPack.GetAt(decompoundItemIndex)
     
-    if not ItemCommon.CheckItemCanUse(curEquip):
+    if not ItemCommon.CheckItemCanUse(curEquip) or ItemControler.GetIsAuctionItem(curEquip):
         return
     
     attrCount = curEquip.GetUserAttrCount(ShareDefine.Def_IudetItemDecompound)
@@ -703,7 +747,7 @@
     
     # 返还物品
     for itemID, itemCount, isBind in giveItemList:
-        ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isBind, [IPY_GameWorld.rptItem], 
+        ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, 0, [IPY_GameWorld.rptItem], 
                                      event=["ItemDecompound", True, {"decompoundItemNoteDict":decompoundItemNoteDict}])
         
     GameWorld.Log("拆解物品成功: decompoundItemNoteDict=%s" % str(decompoundItemNoteDict), playerID)

--
Gitblit v1.8.0