From 476fb6e578f29c09d558187deeb215afe2e5bf59 Mon Sep 17 00:00:00 2001
From: xdh <xiefantasy@qq.com>
Date: 星期四, 14 三月 2019 11:42:28 +0800
Subject: [PATCH] 6307 【后端】【2.0】多套装备开发单(优化代码)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/AddLegendAttr.py |  126 +++++------------------------------------
 1 files changed, 16 insertions(+), 110 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/AddLegendAttr.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/AddLegendAttr.py
index 94a3c9b..547a570 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/AddLegendAttr.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/AddLegendAttr.py
@@ -19,11 +19,7 @@
 import ItemCommon
 import ItemControler
 import IPY_GameWorld
-import IpyGameDataPY
 import ShareDefine
-import ChConfig
-
-import random
 
 #---------------------------------------------------------------------
 #逻辑实现
@@ -35,8 +31,7 @@
     cmdlen = len(cmdList)
     if cmdlen < 1:
         GameWorld.DebugAnswer(curPlayer, "重新随机传奇属性: AddLegendAttr 背包格子索引")
-        GameWorld.DebugAnswer(curPlayer, "添加指定传奇属性: AddLegendAttr 背包格子索引 属性ID1 属性ID2 ...")
-        GameWorld.DebugAnswer(curPlayer, "添加所有传奇属性: AddLegendAttr 背包格子索引 0")
+        GameWorld.DebugAnswer(curPlayer, "部位所有传奇属性: AddLegendAttr 背包格子索引 1")
         return
     
     #获取物品
@@ -46,117 +41,28 @@
         GameWorld.DebugAnswer(curPlayer, "非装备无法获得传奇属性!")
         return
     
-    attrIDList, attrValueList = [], [] # 重新刷新的属性
-    addAttrIDList, addAttrValueList = [], [] # 添加的属性
-    if curItem.GetType() == ChConfig.Def_ItemType_retWing:
-        attrInfo = __GetWingGMAddLegendAttrInfo(curPlayer, curItem, cmdList)
-    else:
-        attrInfo = __GetEquipGMAddLegendAttrInfo(curPlayer, curItem, cmdList)
-        
-    if not attrInfo or (not attrInfo[0] and not attrInfo[1]):
-        GameWorld.DebugAnswer(curPlayer, "获取该装备传奇属性失败或没有传奇属性!")
+    if curItem.GetIsBind():
+        GameWorld.DebugAnswer(curPlayer, "拍品无法生成传奇属性!")
         return
     
-    if attrInfo[0]:
-        attrIDList, attrValueList = attrInfo[0]
-    if attrInfo[1]:
-        addAttrIDList, addAttrValueList = attrInfo[1]
-        
+    isAllAttr = cmdList[1] if len(cmdList) > 1 else 0
+    legendAttrInfo = ItemControler.GetAddEquipLegendAttr(curItem, curPlayer, isAllAttr)
+    if not legendAttrInfo:
+        GameWorld.DebugAnswer(curPlayer, "获取该装备传奇属性失败或没有传奇属性!")
+        return
+    attrIDList, attrValueList = legendAttrInfo
+    
     # 传奇属性
     if attrIDList and attrValueList and len(attrIDList) == len(attrValueList):
         curItem.ClearUserAttr(ShareDefine.Def_IudetLegendAttrID)
         curItem.ClearUserAttr(ShareDefine.Def_IudetLegendAttrValue)
-        GameWorld.DebugLog("刷新传奇属性: ID=%s,value=%s" % (attrIDList, attrValueList))
+        attrDict = {}
         for i, attrID in enumerate(attrIDList):
+            value = attrValueList[i]
             curItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrID, attrID)
-            curItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrValue, attrValueList[i])
-            
-    # 直接添加的
-    if addAttrIDList and addAttrValueList and len(addAttrIDList) == len(addAttrValueList):
-        GameWorld.DebugLog("添加传奇属性: ID=%s,value=%s" % (addAttrIDList, addAttrValueList))
-        for i, attrID in enumerate(addAttrIDList):
-            curItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrID, attrID)
-            curItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrValue, addAttrValueList[i])
-            
-        idList = [curItem.GetUserAttrByIndex(ShareDefine.Def_IudetLegendAttrID, i) \
-                  for i in range(curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrID))]
-        valueList = [curItem.GetUserAttrByIndex(ShareDefine.Def_IudetLegendAttrValue, i) \
-                     for i in range(curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrValue))]
-        GameWorld.DebugLog("当前传奇属性: ID=%s,value=%s" % (idList, valueList))
-                    
+            curItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrValue, value)
+            attrDict[attrID] = value
+        GameWorld.DebugAnswer(curPlayer, "传奇属性:%s" % (attrDict))
+        
     return
-
-def __GetEquipGMAddLegendAttrInfo(curPlayer, curItem, cmdList):
-    isAdd = False
-    cmdlen = len(cmdList)
-    equipPlace = curItem.GetEquipPlace()
-    itemColor = curItem.GetItemColor()
-    if cmdlen == 1:
-        return ItemControler.GetAddEquipLegendAttr(curItem), []
-    
-    if cmdList[1] == 0:
-        legAttrRuleDict = IpyGameDataPY.GetFuncEvalCfg("LegendAttrRule")
-        if equipPlace not in legAttrRuleDict:
-            GameWorld.DebugAnswer(curPlayer, "该装备位无法获得传奇属性!equipPlace=%s" % equipPlace)
-            return
-        commAttrList, goodAttrList, specAttrList = legAttrRuleDict[equipPlace]
-        attrIDList = commAttrList + goodAttrList
-        if specAttrList:
-            if type(specAttrList) == int:
-                attrIDList.append(specAttrList)
-            else:
-                attrIDList += specAttrList
-    else:
-        isAdd = True
-        attrIDList = cmdList[1:]
-        
-    legAttrIDList = []
-    legAttrValueList = []
-    
-    legAttrValueDict = IpyGameDataPY.GetFuncEvalCfg("LegendAttrValue")
-    for attrID in attrIDList:
-        if attrID not in legAttrValueDict:
-            GameWorld.DebugAnswer(curPlayer, "没有该传奇属性: %s" % attrID)
-            continue
-        colorValueDict = legAttrValueDict[attrID]
-        if itemColor not in colorValueDict:
-            continue
-        legAttrIDList.append(attrID)
-        legAttrValueList.append(colorValueDict[itemColor])
-        
-    if not legAttrIDList or not legAttrValueList:
-        return
-    return ([], [legAttrIDList, legAttrValueList]) if isAdd else ([legAttrIDList, legAttrValueList], [])
-
-def __GetWingGMAddLegendAttrInfo(curPlayer, curItem, cmdList):
-    isAdd = False
-    cmdlen = len(cmdList)
-    if cmdlen == 1:
-        return ItemControler.GetAddEquipLegendAttr(curItem), []
-        
-    itemClassLV = ItemCommon.GetItemClassLV(curItem)
-    wingLegAttrValueDict = IpyGameDataPY.GetFuncEvalCfg("WingLegendAttrValue")
-    if itemClassLV not in wingLegAttrValueDict:
-        GameWorld.DebugAnswer(curPlayer, "该翅膀阶级无法获得传奇属性!itemClassLV=%s" % itemClassLV)
-        return
-    curClassLVLegAttrDict = wingLegAttrValueDict[itemClassLV]
-    if cmdList[1] == 0:
-        attrIDList = curClassLVLegAttrDict.keys()
-    else:
-        isAdd = True
-        attrIDList = cmdList[1:]
-        
-    legAttrIDList = []
-    legAttrValueList = []
-    for attrID in attrIDList:
-        if attrID not in curClassLVLegAttrDict:
-            GameWorld.DebugAnswer(curPlayer, "没有该翅膀传奇属性: %s" % attrID)
-            continue
-        legAttrIDList.append(attrID)
-        legAttrValueList.append(random.choice(curClassLVLegAttrDict[attrID]))
-        
-    if not legAttrIDList or not legAttrValueList:
-        return
-    return ([], [legAttrIDList, legAttrValueList]) if isAdd else ([legAttrIDList, legAttrValueList], [])
-
 

--
Gitblit v1.8.0