From a4b26105257000b3eb001f0bc05a9a5135e79443 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期三, 26 九月 2018 21:56:52 +0800
Subject: [PATCH] 3885 【后端】神兽装备一键穿戴功能

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerDogz.py |   74 ++++++++++-------
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py       |   68 ++++++++++------
 ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py                            |   68 ++++++++++------
 3 files changed, 129 insertions(+), 81 deletions(-)

diff --git a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py
index 8213deb..a2e4493 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py
@@ -8210,56 +8210,74 @@
 # A5 C0 神兽穿戴装备 #tagCMDogzEquipItem
 
 class  tagCMDogzEquipItem(Structure):
-    _pack_ = 1
-    _fields_ = [
-                  ("Cmd", c_ubyte),
-                  ("SubCmd", c_ubyte),
-                  ("DogzID", c_ubyte),    # 神兽ID
-                  ("EquipIndex", c_ubyte),    #神兽装备所在神兽背包索引
-                  ]
+    Head = tagHead()
+    DogzID = 0    #(BYTE DogzID)// 神兽ID
+    EquipIndexCount = 0    #(BYTE EquipIndexCount)
+    EquipIndexList = list()    #(vector<BYTE> EquipIndexList)//神兽装备所在神兽背包索引列表
+    data = None
 
     def __init__(self):
         self.Clear()
-        self.Cmd = 0xA5
-        self.SubCmd = 0xC0
+        self.Head.Cmd = 0xA5
+        self.Head.SubCmd = 0xC0
         return
 
-    def ReadData(self, stringData, _pos=0, _len=0):
+    def ReadData(self, _lpData, _pos=0, _Len=0):
         self.Clear()
-        memmove(addressof(self), stringData[_pos:], self.GetLength())
-        return _pos + self.GetLength()
+        _pos = self.Head.ReadData(_lpData, _pos)
+        self.DogzID,_pos = CommFunc.ReadBYTE(_lpData, _pos)
+        self.EquipIndexCount,_pos = CommFunc.ReadBYTE(_lpData, _pos)
+        for i in range(self.EquipIndexCount):
+            value,_pos=CommFunc.ReadBYTE(_lpData,_pos)
+            self.EquipIndexList.append(value)
+        return _pos
 
     def Clear(self):
-        self.Cmd = 0xA5
-        self.SubCmd = 0xC0
+        self.Head = tagHead()
+        self.Head.Clear()
+        self.Head.Cmd = 0xA5
+        self.Head.SubCmd = 0xC0
         self.DogzID = 0
-        self.EquipIndex = 0
+        self.EquipIndexCount = 0
+        self.EquipIndexList = list()
         return
 
     def GetLength(self):
-        return sizeof(tagCMDogzEquipItem)
+        length = 0
+        length += self.Head.GetLength()
+        length += 1
+        length += 1
+        length += 1 * self.EquipIndexCount
+
+        return length
 
     def GetBuffer(self):
-        return string_at(addressof(self), self.GetLength())
+        data = ''
+        data = CommFunc.WriteString(data, self.Head.GetLength(), self.Head.GetBuffer())
+        data = CommFunc.WriteBYTE(data, self.DogzID)
+        data = CommFunc.WriteBYTE(data, self.EquipIndexCount)
+        for i in range(self.EquipIndexCount):
+            data = CommFunc.WriteBYTE(data, self.EquipIndexList[i])
+        return data
 
     def OutputString(self):
-        DumpString = '''// A5 C0 神兽穿戴装备 //tagCMDogzEquipItem:
-                                Cmd:%s,
-                                SubCmd:%s,
+        DumpString = '''
+                                Head:%s,
                                 DogzID:%d,
-                                EquipIndex:%d
+                                EquipIndexCount:%d,
+                                EquipIndexList:%s
                                 '''\
                                 %(
-                                self.Cmd,
-                                self.SubCmd,
+                                self.Head.OutputString(),
                                 self.DogzID,
-                                self.EquipIndex
+                                self.EquipIndexCount,
+                                "..."
                                 )
         return DumpString
 
 
 m_NAtagCMDogzEquipItem=tagCMDogzEquipItem()
-ChNetPackDict[eval("0x%02x%02x"%(m_NAtagCMDogzEquipItem.Cmd,m_NAtagCMDogzEquipItem.SubCmd))] = m_NAtagCMDogzEquipItem
+ChNetPackDict[eval("0x%02x%02x"%(m_NAtagCMDogzEquipItem.Head.Cmd,m_NAtagCMDogzEquipItem.Head.SubCmd))] = m_NAtagCMDogzEquipItem
 
 
 #------------------------------------------------------
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py
index 8213deb..a2e4493 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py
@@ -8210,56 +8210,74 @@
 # A5 C0 神兽穿戴装备 #tagCMDogzEquipItem
 
 class  tagCMDogzEquipItem(Structure):
-    _pack_ = 1
-    _fields_ = [
-                  ("Cmd", c_ubyte),
-                  ("SubCmd", c_ubyte),
-                  ("DogzID", c_ubyte),    # 神兽ID
-                  ("EquipIndex", c_ubyte),    #神兽装备所在神兽背包索引
-                  ]
+    Head = tagHead()
+    DogzID = 0    #(BYTE DogzID)// 神兽ID
+    EquipIndexCount = 0    #(BYTE EquipIndexCount)
+    EquipIndexList = list()    #(vector<BYTE> EquipIndexList)//神兽装备所在神兽背包索引列表
+    data = None
 
     def __init__(self):
         self.Clear()
-        self.Cmd = 0xA5
-        self.SubCmd = 0xC0
+        self.Head.Cmd = 0xA5
+        self.Head.SubCmd = 0xC0
         return
 
-    def ReadData(self, stringData, _pos=0, _len=0):
+    def ReadData(self, _lpData, _pos=0, _Len=0):
         self.Clear()
-        memmove(addressof(self), stringData[_pos:], self.GetLength())
-        return _pos + self.GetLength()
+        _pos = self.Head.ReadData(_lpData, _pos)
+        self.DogzID,_pos = CommFunc.ReadBYTE(_lpData, _pos)
+        self.EquipIndexCount,_pos = CommFunc.ReadBYTE(_lpData, _pos)
+        for i in range(self.EquipIndexCount):
+            value,_pos=CommFunc.ReadBYTE(_lpData,_pos)
+            self.EquipIndexList.append(value)
+        return _pos
 
     def Clear(self):
-        self.Cmd = 0xA5
-        self.SubCmd = 0xC0
+        self.Head = tagHead()
+        self.Head.Clear()
+        self.Head.Cmd = 0xA5
+        self.Head.SubCmd = 0xC0
         self.DogzID = 0
-        self.EquipIndex = 0
+        self.EquipIndexCount = 0
+        self.EquipIndexList = list()
         return
 
     def GetLength(self):
-        return sizeof(tagCMDogzEquipItem)
+        length = 0
+        length += self.Head.GetLength()
+        length += 1
+        length += 1
+        length += 1 * self.EquipIndexCount
+
+        return length
 
     def GetBuffer(self):
-        return string_at(addressof(self), self.GetLength())
+        data = ''
+        data = CommFunc.WriteString(data, self.Head.GetLength(), self.Head.GetBuffer())
+        data = CommFunc.WriteBYTE(data, self.DogzID)
+        data = CommFunc.WriteBYTE(data, self.EquipIndexCount)
+        for i in range(self.EquipIndexCount):
+            data = CommFunc.WriteBYTE(data, self.EquipIndexList[i])
+        return data
 
     def OutputString(self):
-        DumpString = '''// A5 C0 神兽穿戴装备 //tagCMDogzEquipItem:
-                                Cmd:%s,
-                                SubCmd:%s,
+        DumpString = '''
+                                Head:%s,
                                 DogzID:%d,
-                                EquipIndex:%d
+                                EquipIndexCount:%d,
+                                EquipIndexList:%s
                                 '''\
                                 %(
-                                self.Cmd,
-                                self.SubCmd,
+                                self.Head.OutputString(),
                                 self.DogzID,
-                                self.EquipIndex
+                                self.EquipIndexCount,
+                                "..."
                                 )
         return DumpString
 
 
 m_NAtagCMDogzEquipItem=tagCMDogzEquipItem()
-ChNetPackDict[eval("0x%02x%02x"%(m_NAtagCMDogzEquipItem.Cmd,m_NAtagCMDogzEquipItem.SubCmd))] = m_NAtagCMDogzEquipItem
+ChNetPackDict[eval("0x%02x%02x"%(m_NAtagCMDogzEquipItem.Head.Cmd,m_NAtagCMDogzEquipItem.Head.SubCmd))] = m_NAtagCMDogzEquipItem
 
 
 #------------------------------------------------------
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerDogz.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerDogz.py
index b2a436f..102814b 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerDogz.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerDogz.py
@@ -82,50 +82,62 @@
 #{
 #    tagHead        Head;
 #    BYTE        DogzID;    // 神兽ID
-#    BYTE        EquipIndex;    //神兽装备所在神兽背包索引
+#    BYTE        EquipIndexCount;
+#    BYTE        EquipIndexList[EquipIndexCount];    //神兽装备所在神兽背包索引列表
 #};
 def OnDogzEquipItem(index, clientData, tick):
     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
     playerID = curPlayer.GetPlayerID()
     dogzID = clientData.DogzID
-    equipIndex = clientData.EquipIndex
+    equipIndexList = clientData.EquipIndexList
     
     ipyData = IpyGameDataPY.GetIpyGameData("Dogz", dogzID)
     if not ipyData:
         return
     
-    dogzItemPack = curPlayer.GetItemManager().GetPack(ShareDefine.rptDogzItem)
-    curEquip = dogzItemPack.GetAt(equipIndex)
-    if not ItemCommon.CheckItemCanUse(curEquip):
-        GameWorld.DebugLog("物品不可用: equipIndex=%s" % equipIndex)
-        return
-    if not ItemCommon.GetIsDogzEquip(curEquip):
-        GameWorld.DebugLog("非神兽装备: equipIndex=%s" % equipIndex)
+    GameWorld.DebugLog("神兽穿戴装备: dogzID=%s,equipIndexList=%s" % (dogzID, equipIndexList), playerID)
+    if not equipIndexList:
         return
     
-    equipPlace = curEquip.GetEquipPlace()
-    equipPlaceIndex = GetDogzEquipPlaceIndex(equipPlace)
-    equipPlaceColorList = ipyData.GetEquipPlaceColorList()
-    if equipPlaceIndex < 0 or equipPlaceIndex >= len(equipPlaceColorList):
-        GameWorld.ErrLog("神兽装备位异常: equipPlace=%s,equipPlaceIndex=%s" % (equipPlace, equipPlaceIndex))
-        return
+    succIndexList = []
+    for equipIndex in equipIndexList:
+        dogzItemPack = curPlayer.GetItemManager().GetPack(ShareDefine.rptDogzItem)
+        curEquip = dogzItemPack.GetAt(equipIndex)
+        if not ItemCommon.CheckItemCanUse(curEquip):
+            GameWorld.DebugLog("物品为空或不可用: equipIndex=%s" % equipIndex, playerID)
+            continue
+        if not ItemCommon.GetIsDogzEquip(curEquip):
+            GameWorld.DebugLog("非神兽装备: equipIndex=%s" % equipIndex, playerID)
+            continue
+        
+        equipPlace = curEquip.GetEquipPlace()
+        equipPlaceIndex = GetDogzEquipPlaceIndex(equipPlace)
+        equipPlaceColorList = ipyData.GetEquipPlaceColorList()
+        if equipPlaceIndex < 0 or equipPlaceIndex >= len(equipPlaceColorList):
+            GameWorld.ErrLog("神兽装备位异常: equipIndex=%s,equipPlace=%s,equipPlaceIndex=%s" 
+                             % (equipIndex, equipPlace, equipPlaceIndex), playerID)
+            continue
+        
+        dogzEquipPack = curPlayer.GetItemManager().GetPack(ShareDefine.rptDogzEquip)
+        equipPackIndex = GetDogzEquipPackIndex(dogzID, equipPlaceIndex)
+        if equipPackIndex < 0 or equipPackIndex >= dogzEquipPack.GetCount():
+            GameWorld.ErrLog("神兽装备背包索引异常: dogzID=%s,equipIndex=%s,equipPlace=%s,equipPackIndex=%s" 
+                             % (dogzID, equipIndex, equipPlace, equipPackIndex), playerID)
+            continue
+        
+        equipColor = curEquip.GetItemColor()
+        limitColor = equipPlaceColorList[equipPlaceIndex]
+        if equipColor < limitColor:
+            GameWorld.Log("神兽装备位穿戴颜色限制:dogzID=%s,equipIndex=%s,equipPlaceIndex=%s,limitColor=%s > equipColor=%s" 
+                          % (dogzID, equipIndex, equipPlaceIndex, limitColor, equipColor), playerID)
+            continue
+        
+        destEquip = dogzEquipPack.GetAt(equipPackIndex)
+        if ItemCommon.DoLogicSwitchItem(curPlayer, curEquip, destEquip, ShareDefine.rptDogzEquip):
+            succIndexList.append(equipIndex)
     
-    dogzEquipPack = curPlayer.GetItemManager().GetPack(ShareDefine.rptDogzEquip)
-    equipPackIndex = GetDogzEquipPackIndex(dogzID, equipPlaceIndex)
-    if equipPackIndex < 0 or equipPackIndex >= dogzEquipPack.GetCount():
-        GameWorld.ErrLog("神兽装备背包索引异常: dogzID=%s,equipPlace=%s,equipPackIndex=%s" % (dogzID, equipPlace, equipPackIndex))
-        return
-    
-    equipColor = curEquip.GetItemColor()
-    limitColor = equipPlaceColorList[equipPlaceIndex]
-    if equipColor < limitColor:
-        GameWorld.Log("神兽装备位穿戴颜色限制:dogzID=%s,equipPlaceIndex=%s,limitColor=%s > equipColor=%s" 
-                      % (dogzID, equipPlaceIndex, limitColor, equipColor), playerID)
-        return
-    
-    destEquip = dogzEquipPack.GetAt(equipPackIndex)
-    isOK = ItemCommon.DoLogicSwitchItem(curPlayer, curEquip, destEquip, ShareDefine.rptDogzEquip)
-    if not isOK:
+    GameWorld.DebugLog("    穿戴成功索引列表: %s" % succIndexList, playerID)
+    if not succIndexList:
         return
     
     # 助战状态换装需要刷属性

--
Gitblit v1.8.0