From f617d71ec6795493a67b0042ffbecd126e47b9fb Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期二, 18 二月 2025 15:16:34 +0800
Subject: [PATCH] 10393 2月11-14版本更新(商店限购改DWORD)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py |   49 +++++++++++++++++++++++++++++++------------------
 1 files changed, 31 insertions(+), 18 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py
index 373e88d..5af1bcb 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py
@@ -604,24 +604,38 @@
         
     return True
 
+#// A3 10 购买商城物品 #tagCMBuyItem
+#
+#struct    tagCMBuyItem
+#{
+#    tagHead        Head;
+#    WORD        BuyItemIndex;        //购买的物品索引
+#    DWORD        BuyCount;        //购买数量
+#};
+def PyBuyItem(index, clientData, tick):
+    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
+    itemIndex = clientData.BuyItemIndex
+    buyCount = clientData.BuyCount
+    OnBuyItem(curPlayer, itemIndex, buyCount)
+    return
+
 ##购买物品
 # @param curPlayer 玩家实例
 # @param tick 时间戳
 # @return 返回值真, 逻辑运行成功
 def BuyItem(curPlayer, tick):
-    
-    if GameWorld.IsCrossServer():
-        return
-    
     buyItemList = IPY_GameWorld.IPY_CBuyItemList()    
     itemIndex = buyItemList.GetBuyItemIndex()
-    if itemIndex < 0:
-        return
-    
     clientBuyCount = buyItemList.GetBuyCount()
-    if not clientBuyCount:
+    OnBuyItem(curPlayer, itemIndex, clientBuyCount)
+    return
+
+def OnBuyItem(curPlayer, itemIndex, clientBuyCount):
+    GameWorld.DebugLog("购买商城物品: itemIndex=%s,clientBuyCount=%s" % (itemIndex, clientBuyCount), curPlayer.GetPlayerID())
+    if GameWorld.IsCrossServer():
         return
-    
+    if itemIndex < 0 or clientBuyCount <= 0:
+        return
     ipyData = IpyGameDataPY.GetIpyGameData("Store", itemIndex)
     if not ipyData:
         return
@@ -775,27 +789,26 @@
     if limitBuyCnt > 0:
         dayBuyCntKey = ChConfig.Def_PDict_ShopItemDayBuyCnt % itemIndex
         curDayBuyCnt = curPlayer.NomalDictGetProperty(dayBuyCntKey)
-        PlayerControl.NomalDictSetProperty(curPlayer, dayBuyCntKey, curDayBuyCnt + clientBuyCount)
+        updDayBuyCnt = min(curDayBuyCnt + clientBuyCount, ChConfig.Def_UpperLimit_DWord)
+        PlayerControl.NomalDictSetProperty(curPlayer, dayBuyCntKey, updDayBuyCnt)
+        GameWorld.DebugLog("更新商城物品限购次数: itemIndex=%s,curDayBuyCnt=%s,clientBuyCount=%s,updDayBuyCnt=%s/%s" 
+                           % (itemIndex, curDayBuyCnt, clientBuyCount, updDayBuyCnt, limitBuyCnt), curPlayer.GetPlayerID())
         SyncShopItemTodayBuyCount(curPlayer, [itemIndex])
         
     dataDict = {"ShopType":shopType, "ShopItemIndex":itemIndex, "ClientBuyCount":clientBuyCount, 
                 "ItemPrice":itemPrice, "MoneyType":priceType, 
                 "BeforeMoney":beforeMoney, "AfterMoney":afterMoney}
     isForceEvent = priceType not in [IPY_GameWorld.TYPE_Price_Silver_Money]
-
-    itemControl = ItemControler.PlayerItemControler(curPlayer)
+    
     for itemID, itemCount, isBind in totalItemList:
         curItemObj = ItemControler.GetOutPutItemObj(itemID, itemCount, False, curPlayer=curPlayer)
         if not curItemObj:
             continue
         userData = curItemObj.GetUserData()
+        curItemObj.Clear()
         if not sendMailKey:
-            packType = ChConfig.GetItemPackType(curItemObj)
-            if not itemControl.PutInItem(packType, curItemObj, event=[ChConfig.ItemGive_BuyItem, isForceEvent, dataDict]):
-                curItemObj.Clear()
-                continue
-        else:
-            curItemObj.Clear()
+            if not ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isBind, event=[ChConfig.ItemGive_BuyItem, isForceEvent, dataDict]):
+                GameWorld.ErrLog("购买商城物品放入背包失败! itemID=%s, itemCount=%s" % (itemID, itemCount), curPlayer.GetPlayerID())
         EventShell.EventRespons_BuyItem(curPlayer, itemID, itemCount)
         
         if ipyData.GetNotifyMark() and itemID == mainItemID:

--
Gitblit v1.8.0