From 3ba3a5bf8077702514e96f9d79246a61c454ef76 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期三, 13 三月 2024 17:42:42 +0800
Subject: [PATCH] 10033 【后端】仙树升级系统及砍树产出规则(增加砍树内置CD300毫秒;砍树装备产出及分解规则调整;砍树装备操作支持批量;)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCutTree.py |   98 +++++++++++++++++++++++++-----------------------
 1 files changed, 51 insertions(+), 47 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCutTree.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCutTree.py
index a24328a..e18e122 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCutTree.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCutTree.py
@@ -50,6 +50,10 @@
     cutCount = clientData.CutCount
     playerID = curPlayer.GetPlayerID()
     
+    if not GameWorld.SetPlayerTickTime(curPlayer, ChConfig.TYPE_Player_Tick_CutTree, tick):
+        GameWorld.DebugLog("砍树CD中...", playerID)
+        return
+    
     identifyPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptIdentify)
     packCount = identifyPack.GetCount()
     for i in range(0, packCount):
@@ -84,43 +88,35 @@
     maxRate = 10000
     totalRate = 0
     colorRateList = []
-    for equipColor, colorRate in enumerate(equipColorRateList):
+    for equipColor, colorRate in enumerate(equipColorRateList, 1):
         if not colorRate:
             continue
         totalRate += colorRate
         colorRateList.append([totalRate, equipColor])
         
     if totalRate != maxRate:
-        GameWorld.SendGameError("GameWarning", "CutTreeTotalRateError:%s!=%s" % (totalRate, maxRate))    
+        GameWorld.SendGameError("GameWarning", "CutTreeTotalRateError:%s!=%s,treeLV=%s" % (totalRate, maxRate, treeLV))    
     if not colorRateList:
         return
     GameWorld.DebugLog("    colorRateList=%s,totalRate=%s" % (colorRateList, totalRate), playerID)
     
-    playerLV = curPlayer.GetLV()
-    classLV = int(playerLV / 50 + 1)
-    classLVMax = min(15, classLV + 1)
-    classLVMin = max(1, min(classLV - 1, classLVMax - 2)) 
-    classLVList = range(classLVMin, classLVMax + 1)
-    GameWorld.DebugLog("    classLVList=%s,playerLV=%s,classLVMin=%s,classLVMax=%s" 
-                       % (classLVList, playerLV, classLVMin, classLVMax), playerID)
-    
+    classLV, isSuit = 0, None
+    placeList = ChConfig.EquipPlace_Base + ChConfig.EquipPlace_Special
+    jobList = [curPlayer.GetJob()]
     randEquipIDList = []
     for _ in range(cutCount):
         itemColor = GameWorld.GetResultByRandomList(colorRateList)
         if not itemColor:
             continue
-        # 产出装备规则待扩展,先固定
-        classLV = random.choice(classLVList)
-        isSuit = 0
-        placeList = ChConfig.EquipPlace_Base
-        jobList = [curPlayer.GetJob()]
         equipIDList = NPCCommon.__GetEquipIDList(0, classLV, itemColor, isSuit, placeList, jobList, findType="CutTree")
         if not equipIDList:
             continue
-        randEquipIDList.append(random.choice(equipIDList))
+        randEquipID = random.choice(equipIDList)
+        GameWorld.DebugLog("    随机装备ID: %s, itemColor=%s,%s" % (randEquipID, itemColor, equipIDList), playerID)
+        randEquipIDList.append(randEquipID)
         
     GameWorld.DebugLog("    预产出装备: randEquipIDList=%s" % randEquipIDList, playerID)
-        
+    
     giveItemListEx = []
     giveEquipIDList = []
     for equipItemID in randEquipIDList:
@@ -167,60 +163,68 @@
 #struct    tagCMCutTreeEquipOP
 #{
 #    tagHead        Head;
-#    BYTE        ItemIndex;    // 物品在砍树背包的索引
+#    BYTE        IndexCount;
+#    BYTE        ItemIndexList[IndexCount];    // 物品在砍树背包的索引列表
 #    BYTE        OPType;        // 操作类型:1-替换;2-分解
 #    BYTE        AutoDecompose;    // 替换后是否自动分解原装备:0否1是,仅替换操作下有用
 #};
 def OnCutTreeEquipOP(index, clientData, tick):
     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
     opType = clientData.OPType
-    itemIndex = clientData.ItemIndex
+    itemIndexList = clientData.ItemIndexList
     autoDecompose = clientData.AutoDecompose
     playerID = curPlayer.GetPlayerID()
     
     identifyPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptIdentify)
-    if itemIndex >= identifyPack.GetCount():
-        GameWorld.DebugLog("砍树背包索引不存在: itemIndex=%s" % itemIndex, playerID)
-        return
-    curEquip = identifyPack.GetAt(itemIndex)
-    if not ItemCommon.CheckItemCanUse(curEquip):
-        GameWorld.DebugLog("砍树背包物品不存在: itemIndex=%s" % itemIndex, playerID)
-        return
-    GameWorld.DebugLog("砍树装备操作: itemIndex=%s,opType=%s,autoDecompose=%s" % (itemIndex, opType, autoDecompose), playerID)
-    
-    # 替换
-    if opType == 1:
-        equipIndex = ItemCommon.GetEquipPackIndex(curEquip)
-        if not ChEquip.DoPlayerEquipItem(curPlayer, curEquip, equipIndex, tick):
-            return
+    GameWorld.DebugLog("砍树装备操作: itemIndexList=%s,opType=%s,autoDecompose=%s" % (itemIndexList, opType, autoDecompose), playerID)
+    for itemIndex in itemIndexList:
+        if itemIndex >= identifyPack.GetCount():
+            GameWorld.DebugLog("砍树背包索引不存在: itemIndex=%s" % itemIndex, playerID)
+            continue
+        curEquip = identifyPack.GetAt(itemIndex)
+        if not ItemCommon.CheckItemCanUse(curEquip):
+            GameWorld.DebugLog("砍树背包物品不存在: itemIndex=%s" % itemIndex, playerID)
+            continue
         
-        if autoDecompose:
-            __DoEquipDecompose(curPlayer, identifyPack.GetAt(itemIndex)) # 需重新获得装备对象
+        # 替换
+        if opType == 1:
+            equipIndex = ItemCommon.GetEquipPackIndex(curEquip)
+            if not ChEquip.DoPlayerEquipItem(curPlayer, curEquip, equipIndex, tick):
+                continue
             
-    # 分解
-    elif opType == 2:
-        __DoEquipDecompose(curPlayer, curEquip)
+            if autoDecompose:
+                __DoEquipDecompose(curPlayer, identifyPack.GetAt(itemIndex)) # 需重新获得装备对象
+                
+        # 分解
+        elif opType == 2:
+            __DoEquipDecompose(curPlayer, curEquip)
+            
+        # 放入备用仓库
+        elif opType == 3:
+            pass
         
-    # 放入备用仓库
-    elif opType == 3:
-        pass
-    
-    else:
-        return
-    
     return
 
 def __DoEquipDecompose(curPlayer, curEquip):
     if not curEquip:
         return
     itemID = curEquip.GetItemTypeID()
+    itemColor = curEquip.GetItemColor()
+    itemLV = ItemControler.GetItemLV(curEquip)
     playerID = curPlayer.GetPlayerID()
-    GameWorld.DebugLog("装备分解: itemID=%s" % (itemID), playerID)
     
-    # 这边执行分解逻辑,待扩展...
+    colorIpyData = IpyGameDataPY.GetIpyGameData("EquipColor", itemColor)
+    moneyBase = colorIpyData.GetMoneyBase() if colorIpyData else 0
+    GameWorld.DebugLog("装备分解: itemID=%s,itemColor=%s,itemLV=%s,moneyBase=%s" % (itemID, itemColor, itemLV, moneyBase), playerID)
     
     ItemCommon.DelItem(curPlayer, curEquip, curEquip.GetCount(), True, ChConfig.ItemDel_EquipDecompose)
     
+    moneyType = IPY_GameWorld.TYPE_Price_Gold_Paper
+    moneyValye = eval(IpyGameDataPY.GetFuncCompileCfg("CutTree", 3))
+    if moneyValye:
+        addDataDict = {ChConfig.Def_Give_Reason_SonKey:itemID, "itemColor":itemColor, "itemLV":itemLV}
+        PlayerControl.GiveMoney(curPlayer, moneyType, moneyValye, "EquipDecompose", addDataDict)
+        
     PlayerTask.AddTaskValue(curPlayer, ChConfig.TaskType_EquipDecompose, 1)
     return
 

--
Gitblit v1.8.0