From aba9f71e75f2d956c621c9ad21593838e04fa312 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期三, 27 十一月 2024 11:51:53 +0800
Subject: [PATCH] 10318 【英文】【越南】【BT】【砍树】统一增加奖励获得封包

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/ItemControler.py |   56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 55 insertions(+), 1 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/ItemControler.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/ItemControler.py
index 9449df4..07dc288 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/ItemControler.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/ItemControler.py
@@ -47,6 +47,7 @@
 
 import math
 import time
+import json
 #---------------------------------------------------------------------
 
 ## 获得背包的一个空格子
@@ -2521,7 +2522,7 @@
         
     return True
 
-def GivePlayerItemOrMail(curPlayer, itemList, mailKey=None, event=["", False, {}]):
+def GivePlayerItemOrMail(curPlayer, itemList, mailKey=None, event=["", False, {}], isNotifyAward=True):
     ##给物品,背包满则发邮件
     if not itemList:
         return
@@ -2554,6 +2555,59 @@
     else:
         for itemID, itemCnt, isAuctionItem in giveItemList:
             GivePlayerItem(curPlayer, itemID, itemCnt, isAuctionItem, [IPY_GameWorld.rptItem], event=event)
+            
+        if isNotifyAward:
+            eventName = event[0] if event else ""
+            NotifyGiveAwardInfo(curPlayer, giveItemList, eventName)
+    return
+
+def NotifyGiveAwardInfo(curPlayer, giveItemInfo, eventName="", exp=0, moneyInfo=None, dataEx=None):
+    '''通知玩家获得奖励信息
+    @param giveItemInfo: 可以是列表 [[itemID,count,isBind], ...] 或  [[itemID,count], ...] 或  {itemID:count, ...}
+    @param moneyInfo: 奖励货币信息 {moneyType:moneyValue, ...} moneyType 可以是字符串或数值
+    '''
+    notifyItemList = []
+    if isinstance(giveItemInfo, dict):
+        notifyItemList = [[a, b] for a, b in giveItemInfo.items()]
+    else:
+        notifyItemList = giveItemInfo
+    eventName = ChConfig.ItemGiveTypeDict.get(eventName, str(eventName))
+    clientPack = ChPyNetSendPack.tagMCGiveAwardInfo()
+    clientPack.EventName = eventName
+    clientPack.EventLen = len(clientPack.EventName)
+    clientPack.ExpPoint = exp / ChConfig.Def_PerPointValue
+    clientPack.Exp = exp % ChConfig.Def_PerPointValue
+    if moneyInfo and isinstance(moneyInfo, dict):
+        for moneyType, moneyValue in moneyInfo.items():
+            if isinstance(moneyType, str):
+                moneyType = int(moneyType)
+            if not moneyType or not moneyValue:
+                continue
+            money = ChPyNetSendPack.tagMCGiveAwardMoney()
+            money.MoneyType = moneyType
+            money.MoneyValue = moneyValue
+            clientPack.MoneyList.append(money)
+        clientPack.MoneyLen = len(clientPack.MoneyList)
+    for itemInfo in notifyItemList:
+        itemID, itemCount = itemInfo[:2]
+        isBind = itemInfo[2] if len(itemInfo) > 2 else 1
+        if not itemID or not itemCount:
+            continue
+        item = ChPyNetSendPack.tagMCGiveAwardItem()
+        item.ItemID = itemID
+        item.Count = itemCount
+        item.IsBind = isBind
+        clientPack.ItemList.append(item)
+    clientPack.ItemLen = len(clientPack.ItemList)
+    if dataEx:
+        if isinstance(dataEx, dict):
+            dataEx = json.dumps(dataEx, ensure_ascii=False)
+        elif not isinstance(dataEx, str):
+            dataEx = str(dataEx)
+        dataEx = dataEx.replace(" ", "")
+        clientPack.DataEx = dataEx
+        clientPack.DataLen = len(clientPack.DataEx)
+    NetPackCommon.SendFakePack(curPlayer, clientPack)
     return
 
 def RecycleItem(curPlayer, itemID, notifyMailKey):

--
Gitblit v1.8.0