From 0109694e42f8eb784aef55436051e2a0f4fae06f Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期二, 03 十一月 2020 15:33:15 +0800
Subject: [PATCH] 1111 【BT】支持一键整理过期拍品(同步主干、长尾);

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py |    8 ++++++--
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/ChItem.py |   29 ++++++++++++++++++++++++++++-
 ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py                      |    8 ++++++--
 3 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py
index a6d8ba1..8beef4d 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py
@@ -7207,6 +7207,7 @@
                   ("SubCmd", c_ubyte),
                   ("PackType", c_ubyte),    #背包类型
                   ("ItemIndex", c_ubyte),    #物品在背包中索引
+                  ("IsAll", c_ubyte),    #是否处理所有过期物品
                   ]
 
     def __init__(self):
@@ -7225,6 +7226,7 @@
         self.SubCmd = 0x08
         self.PackType = 0
         self.ItemIndex = 0
+        self.IsAll = 0
         return
 
     def GetLength(self):
@@ -7238,13 +7240,15 @@
                                 Cmd:%s,
                                 SubCmd:%s,
                                 PackType:%d,
-                                ItemIndex:%d
+                                ItemIndex:%d,
+                                IsAll:%d
                                 '''\
                                 %(
                                 self.Cmd,
                                 self.SubCmd,
                                 self.PackType,
-                                self.ItemIndex
+                                self.ItemIndex,
+                                self.IsAll
                                 )
         return DumpString
 
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py
index a6d8ba1..8beef4d 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py
@@ -7207,6 +7207,7 @@
                   ("SubCmd", c_ubyte),
                   ("PackType", c_ubyte),    #背包类型
                   ("ItemIndex", c_ubyte),    #物品在背包中索引
+                  ("IsAll", c_ubyte),    #是否处理所有过期物品
                   ]
 
     def __init__(self):
@@ -7225,6 +7226,7 @@
         self.SubCmd = 0x08
         self.PackType = 0
         self.ItemIndex = 0
+        self.IsAll = 0
         return
 
     def GetLength(self):
@@ -7238,13 +7240,15 @@
                                 Cmd:%s,
                                 SubCmd:%s,
                                 PackType:%d,
-                                ItemIndex:%d
+                                ItemIndex:%d,
+                                IsAll:%d
                                 '''\
                                 %(
                                 self.Cmd,
                                 self.SubCmd,
                                 self.PackType,
-                                self.ItemIndex
+                                self.ItemIndex,
+                                self.IsAll
                                 )
         return DumpString
 
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/ChItem.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/ChItem.py
index 92e34b2..cdd3d6f 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/ChItem.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/ChItem.py
@@ -55,6 +55,7 @@
 
 import random
 import json
+import time
 #---------------------------------------------------------------------
 #导入
 GameWorld.ImportAll("Script\\Item\\" , "UseItem")
@@ -2034,15 +2035,41 @@
 #    tagHead        Head;
 #    BYTE        PackType;        //背包类型
 #    BYTE        ItemIndex;        //物品在背包中索引
+#    BYTE        IsAll;            //是否处理所有过期物品
 #};
 def OnItemTimeout(index, clientData, tick):
     packType = clientData.PackType
     itemIndex = clientData.ItemIndex
-    
+    isAll = clientData.IsAll
     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
     backPack = curPlayer.GetItemManager().GetPack(packType)
     if not backPack:
         return
+    
+    if isAll:
+        # 目前仅针对拍品
+        GameWorld.DebugLog("=== 一键处理所有过期物品 ===")
+        curTime = int(time.time())
+        auctionItemTimeout = IpyGameDataPY.GetFuncCfg("AuctionItem", 1)
+        for i in xrange(backPack.GetCount()):
+            curItem = backPack.GetAt(i)
+            if not ItemCommon.CheckItemCanUse(curItem):
+                continue
+            if not ItemControler.GetIsAuctionItem(curItem):
+                continue
+            auctionItemCreateTime = curItem.GetUserAttr(ShareDefine.Def_IudetAuctionItemCreateTime)
+            if not auctionItemCreateTime:
+                continue
+            if curTime - auctionItemCreateTime < auctionItemTimeout * 3600:
+                # 未过期
+                continue
+            GameWorld.DebugLog("玩家拍品过期: i=%s,itemID=%s" % (i, curItem.GetItemTypeID()), curPlayer.GetPlayerID())
+            ItemControler.SetIsAuctionItem(curItem, False, curPlayer)
+            
+        # 整理背包
+        ItemControler.ResetItem(curPlayer, packType, 0, 0, tick)
+        return
+    
     curItem = backPack.GetAt(itemIndex)
     if not ItemCommon.CheckItemCanUse(curItem):
         GameWorld.DebugLog("物品不存在!")

--
Gitblit v1.8.0