From b813aa21bc48546c8e5adead95ba4cb4e8e02148 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期三, 14 十一月 2018 14:11:10 +0800
Subject: [PATCH] 4730 【后端】【1.3】神兵系统修改(激活方式修改、升级支持自动锤炼)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGodWeapon.py |   86 +++++++++++++++++++++++++++++++++++--------
 1 files changed, 70 insertions(+), 16 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGodWeapon.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGodWeapon.py
index 7e0f89c..57f43a4 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGodWeapon.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGodWeapon.py
@@ -80,7 +80,11 @@
 
     allAttrList = [{} for i in range(4)]
     for gwType in xrange(1, maxType + 1):
+        # 因为神兵解锁条件做了调整,由之前的0~1阶解锁改为由前置神兵类型等级解锁,默认解锁后为1阶
+        # 为兼容老号,刷属性时只要判断等级是否大于0,不管是否解锁,新号解锁由神兵升级的时候进行解锁
         attrLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponLV % gwType)
+        if not attrLV:
+            continue
         godWeaponData = IpyGameDataPY.GetIpyGameData('GodWeapon', gwType, attrLV)
         if not godWeaponData:
             continue
@@ -88,25 +92,30 @@
         for i, attrID in enumerate(attrTypeList):
             PlayerControl.CalcAttrDict_Type(attrID, attrValueList[i], allAttrList)
         
+    GameWorld.DebugLog("神兵属性:%s" % allAttrList)
     # 保存计算值
     PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_GodWeapon, allAttrList)   
     return
 
 #---------------------------------------------------------------------------------------------------
 #===============================================================================
-# // A5 55 神兵升级 #tagCMGodWeaponPlus
-# 
-# struct    tagCMGodWeaponPlus
-# {
+#// A5 55 神兵升级 #tagCMGodWeaponPlus
+#
+#struct    tagCMGodWeaponPlus
+#{
 #    tagHead        Head;
 #    DWORD        WeaponType;    // 神兵类型
 #    DWORD        ItemID;        //消耗的物品ID
-# };
+#    BYTE        ItemCount;        //消耗个数,默认1
+#    BYTE        IsAutoBuy;        //是否自动购买,默认0
+#};
 #===============================================================================
 def OnPlusGodWeapon(index, clientData, tick):
     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
     weaponType = clientData.WeaponType
     useItemID = clientData.ItemID
+    useItemCount = max(1, clientData.ItemCount)
+    isAutoBuy = clientData.IsAutoBuy
     
     if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_GodWeapon):
         #等级不足
@@ -114,6 +123,10 @@
     
     #1.判断表中有没此类型,2.是否满级,3.判断是否有物品
     attrLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponLV % weaponType)
+    if not attrLV:
+        GameWorld.DebugLog("神兵未解锁,无法升级!weaponType=%s,attrLV=%s" % (weaponType, attrLV))
+        return
+      
     beforeAttrLV = attrLV   # 用于提示
     godWeaponData = IpyGameDataPY.GetIpyGameData('GodWeapon', weaponType, attrLV)
     if not godWeaponData:
@@ -129,12 +142,10 @@
     if useItemID not in IpyGameDataPY.GetFuncEvalCfg("GodWeapon%s"%weaponType):
         return
     
-    curItem = ItemCommon.FindItemInPackByItemID(curPlayer, useItemID, IPY_GameWorld.rptItem)
-    if not curItem:
-        GameWorld.DebugLog('###神兵假包,没有物品ID=%s'%useItemID)
+    itemData = GameWorld.GetGameData().GetItemByTypeID(useItemID)
+    if not itemData:
         return
-
-    effect = ItemCommon.GetItemEffectByEffectID(curItem, ChConfig.Def_Item_Eff_GodWeaponExp)
+    effect = ItemCommon.GetItemEffectByEffectID(itemData, ChConfig.Def_Item_Eff_GodWeaponExp)
     if not effect:
         GameWorld.DebugLog('###神兵假包,物品ID=%s没有经验值'%useItemID)
         return
@@ -143,16 +154,37 @@
         GameWorld.DebugLog('###神兵假包,物品ID=%s没有经验值'%useItemID)
         return
     
-    delCnt = 1
-    ItemCommon.DelItem(curPlayer, curItem, delCnt, False, ChConfig.ItemDel_GodWeapon)
-    
-    curExp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponExp % weaponType)
-    curExp = curExp + addExp
+    costItemIndexList, bindCnt, unBindCnt = ItemCommon.GetPackItemBindStateIndexInfo(curPlayer, useItemID, useItemCount)
+    lackCount = max(0, useItemCount - (bindCnt + unBindCnt))
+    if lackCount > 0:
+        if not isAutoBuy:
+            GameWorld.DebugLog("神兵升级消耗不足!useItemID=%s,useItemCount=%s,bindCnt=%s,unBindCnt=%s,lackCount=%s" 
+                               % (useItemID, useItemCount, bindCnt, unBindCnt, lackCount))
+            return
+        lackCost = ItemCommon.GetAutoBuyItemNeedGold({useItemID:lackCount})
+        if lackCost <= 0:
+            return
+        
+        infoDict = {ChConfig.Def_Cost_Reason_SonKey:useItemID}
+        if not PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, lackCost,
+                                      ChConfig.Def_Cost_BuyStoreItem, infoDict, lackCount):
+            return
+        
+    delUseItemCount = useItemCount - lackCount
+    # 扣除消耗
+    if delUseItemCount:
+        ItemCommon.DelCostItemByBind(curPlayer, costItemIndexList, bindCnt, unBindCnt, delUseItemCount, ChConfig.ItemDel_GodWeapon)
+        
+    addTotalExp = addExp * useItemCount
+    befExp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponExp % weaponType)
+    curExp = befExp + addTotalExp
+    GameWorld.DebugLog("执行神兵升级: weaponType=%s,beforeAttrLV=%s,befExp=%s,addTotalExp=%s(%s*%s),curExp=%s" 
+                       % (weaponType, beforeAttrLV, befExp, addTotalExp, addExp, useItemCount, curExp))
     
     isLVUP = False
     
     # 安全为主不用while
-    for i in xrange(100):
+    for _ in xrange(100):
         if curExp < totalExp:
             break
         godWeaponData = IpyGameDataPY.GetIpyGameData('GodWeapon', weaponType, attrLV+1)
@@ -160,6 +192,7 @@
             GameWorld.DebugLog('神兵升级找不到数据 %s-%s'%(weaponType, attrLV))
             break
         
+        GameWorld.DebugLog("    神兵升级: attrLV=%s,needExp=%s" % (attrLV, totalExp))
         curExp = curExp - totalExp
         attrLV += 1
         isLVUP = True
@@ -175,6 +208,7 @@
     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GodWeaponExp % weaponType, curExp)
     
     if isLVUP:
+        GameWorld.DebugLog("神兵升级结果: attrLV=%s,curExp=%s" % (attrLV, curExp))
         RefreshGodWeaponAttr(curPlayer)
         #x神器达到X级成就
         PlayerSuccess.UptateSuccessProgress(curPlayer, ShareDefine.SuccType_GodWeapon, attrLV, [weaponType])
@@ -190,6 +224,26 @@
                 if beforeAttrLV < notifyLV and attrLV >= notifyLV:
                     PlayerControl.WorldNotify(0, 'GodWeaponLv', [curPlayer.GetName(), weaponType, notifyLV])
         
+        #升级判断是否可解锁其他神兵
+        godWeaponUnlockDict = IpyGameDataPY.GetFuncEvalCfg("GodWeaponActive", 2, {})
+        for unlockGodWeaponType, unlockConditionList in godWeaponUnlockDict.items():
+            unlockGodWeaponType = int(unlockGodWeaponType)
+            if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponLV % unlockGodWeaponType):
+                GameWorld.DebugLog("已经解锁的神兵不需要再判断!unlockGodWeaponType=%s" % unlockGodWeaponType)
+                continue
+            isUnlock = True
+            for needType, needLV in unlockConditionList:
+                needTypeLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponLV % needType)
+                if needTypeLV < needLV:
+                    isUnlock = False
+                    GameWorld.DebugLog("所需前置神兵等级不足,无法解锁!unlockGodWeaponType=%s,needType=%s,needLV=%s > needTypeLV(%s)" 
+                                       % (unlockGodWeaponType, needType, needLV, needTypeLV))
+                    break
+            if isUnlock:
+                PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GodWeaponLV % unlockGodWeaponType, 1)
+                GameWorld.DebugLog("解锁神兵: unlockGodWeaponType=%s" % unlockGodWeaponType)
+                Sync_GodWeaponLVInfo(curPlayer, unlockGodWeaponType)
+                
     Sync_GodWeaponLVInfo(curPlayer, weaponType)
     #任务
     EventShell.EventRespons_PlusGodWeapon(curPlayer)

--
Gitblit v1.8.0