6459 【后端】【2.0】缥缈仙域开发单(自定义场景无奖励也回包,防止卡流程)
| | |
| | | #------------------------------------------------------
|
| | | # B2 14 自定义副本奖励信息 #tagMCCuntomFBPrizeInfo
|
| | |
|
| | | class tagMCCuntomFBPrizeItem(Structure):
|
| | | ItemID = 0 #(DWORD ItemID)
|
| | | Count = 0 #(WORD Count)
|
| | | IsAuctionItem = 0 #(BYTE IsAuctionItem)//是否拍品
|
| | | UserDataLen = 0 #(WORD UserDataLen)//附加属性长度
|
| | | UserData = "" #(String UserData)//附加属性 size = UserDataLen
|
| | | data = None
|
| | |
|
| | | def __init__(self):
|
| | | self.Clear()
|
| | | return
|
| | |
|
| | | def ReadData(self, _lpData, _pos=0, _Len=0):
|
| | | self.Clear()
|
| | | self.ItemID,_pos = CommFunc.ReadDWORD(_lpData, _pos)
|
| | | self.Count,_pos = CommFunc.ReadWORD(_lpData, _pos)
|
| | | self.IsAuctionItem,_pos = CommFunc.ReadBYTE(_lpData, _pos)
|
| | | self.UserDataLen,_pos = CommFunc.ReadWORD(_lpData, _pos)
|
| | | self.UserData,_pos = CommFunc.ReadString(_lpData, _pos,self.UserDataLen)
|
| | | return _pos
|
| | |
|
| | | def Clear(self):
|
| | | self.ItemID = 0
|
| | | self.Count = 0
|
| | | self.IsAuctionItem = 0
|
| | | self.UserDataLen = 0
|
| | | self.UserData = ""
|
| | | return
|
| | |
|
| | | def GetLength(self):
|
| | | length = 0
|
| | | length += 4
|
| | | length += 2
|
| | | length += 1
|
| | | length += 2
|
| | | length += len(self.UserData)
|
| | |
|
| | | return length
|
| | |
|
| | | def GetBuffer(self):
|
| | | data = ''
|
| | | data = CommFunc.WriteDWORD(data, self.ItemID)
|
| | | data = CommFunc.WriteWORD(data, self.Count)
|
| | | data = CommFunc.WriteBYTE(data, self.IsAuctionItem)
|
| | | data = CommFunc.WriteWORD(data, self.UserDataLen)
|
| | | data = CommFunc.WriteString(data, self.UserDataLen, self.UserData)
|
| | | return data
|
| | |
|
| | | def OutputString(self):
|
| | | DumpString = '''
|
| | | ItemID:%d,
|
| | | Count:%d,
|
| | | IsAuctionItem:%d,
|
| | | UserDataLen:%d,
|
| | | UserData:%s
|
| | | '''\
|
| | | %(
|
| | | self.ItemID,
|
| | | self.Count,
|
| | | self.IsAuctionItem,
|
| | | self.UserDataLen,
|
| | | self.UserData
|
| | | )
|
| | | return DumpString
|
| | |
|
| | |
|
| | | class tagMCCuntomFBPrizeInfo(Structure):
|
| | | Head = tagHead()
|
| | | MapID = 0 #(DWORD MapID)
|
| | | FuncLineID = 0 #(WORD FuncLineID)
|
| | | PrizeItemCount = 0 #(BYTE PrizeItemCount)
|
| | | PrizeItemList = list() #(vector<tagMCCuntomFBPrizeItem> PrizeItemList)
|
| | | PrizeItemIDList = list() #(vector<DWORD> PrizeItemIDList)
|
| | | data = None
|
| | |
|
| | | def __init__(self):
|
| | |
| | | self.FuncLineID,_pos = CommFunc.ReadWORD(_lpData, _pos)
|
| | | self.PrizeItemCount,_pos = CommFunc.ReadBYTE(_lpData, _pos)
|
| | | for i in range(self.PrizeItemCount):
|
| | | temPrizeItemList = tagMCCuntomFBPrizeItem()
|
| | | _pos = temPrizeItemList.ReadData(_lpData, _pos)
|
| | | self.PrizeItemList.append(temPrizeItemList)
|
| | | value,_pos=CommFunc.ReadDWORD(_lpData,_pos)
|
| | | self.PrizeItemIDList.append(value)
|
| | | return _pos
|
| | |
|
| | | def Clear(self):
|
| | |
| | | self.MapID = 0
|
| | | self.FuncLineID = 0
|
| | | self.PrizeItemCount = 0
|
| | | self.PrizeItemList = list()
|
| | | self.PrizeItemIDList = list()
|
| | | return
|
| | |
|
| | | def GetLength(self):
|
| | |
| | | length += 4
|
| | | length += 2
|
| | | length += 1
|
| | | for i in range(self.PrizeItemCount):
|
| | | length += self.PrizeItemList[i].GetLength()
|
| | | length += 4 * self.PrizeItemCount
|
| | |
|
| | | return length
|
| | |
|
| | |
| | | data = CommFunc.WriteWORD(data, self.FuncLineID)
|
| | | data = CommFunc.WriteBYTE(data, self.PrizeItemCount)
|
| | | for i in range(self.PrizeItemCount):
|
| | | data = CommFunc.WriteString(data, self.PrizeItemList[i].GetLength(), self.PrizeItemList[i].GetBuffer())
|
| | | data = CommFunc.WriteDWORD(data, self.PrizeItemIDList[i])
|
| | | return data
|
| | |
|
| | | def OutputString(self):
|
| | |
| | | MapID:%d,
|
| | | FuncLineID:%d,
|
| | | PrizeItemCount:%d,
|
| | | PrizeItemList:%s
|
| | | PrizeItemIDList:%s
|
| | | '''\
|
| | | %(
|
| | | self.Head.OutputString(),
|
| | |
| | | #------------------------------------------------------
|
| | | # B2 14 自定义副本奖励信息 #tagMCCuntomFBPrizeInfo
|
| | |
|
| | | class tagMCCuntomFBPrizeItem(Structure):
|
| | | ItemID = 0 #(DWORD ItemID)
|
| | | Count = 0 #(WORD Count)
|
| | | IsAuctionItem = 0 #(BYTE IsAuctionItem)//是否拍品
|
| | | UserDataLen = 0 #(WORD UserDataLen)//附加属性长度
|
| | | UserData = "" #(String UserData)//附加属性 size = UserDataLen
|
| | | data = None
|
| | |
|
| | | def __init__(self):
|
| | | self.Clear()
|
| | | return
|
| | |
|
| | | def ReadData(self, _lpData, _pos=0, _Len=0):
|
| | | self.Clear()
|
| | | self.ItemID,_pos = CommFunc.ReadDWORD(_lpData, _pos)
|
| | | self.Count,_pos = CommFunc.ReadWORD(_lpData, _pos)
|
| | | self.IsAuctionItem,_pos = CommFunc.ReadBYTE(_lpData, _pos)
|
| | | self.UserDataLen,_pos = CommFunc.ReadWORD(_lpData, _pos)
|
| | | self.UserData,_pos = CommFunc.ReadString(_lpData, _pos,self.UserDataLen)
|
| | | return _pos
|
| | |
|
| | | def Clear(self):
|
| | | self.ItemID = 0
|
| | | self.Count = 0
|
| | | self.IsAuctionItem = 0
|
| | | self.UserDataLen = 0
|
| | | self.UserData = ""
|
| | | return
|
| | |
|
| | | def GetLength(self):
|
| | | length = 0
|
| | | length += 4
|
| | | length += 2
|
| | | length += 1
|
| | | length += 2
|
| | | length += len(self.UserData)
|
| | |
|
| | | return length
|
| | |
|
| | | def GetBuffer(self):
|
| | | data = ''
|
| | | data = CommFunc.WriteDWORD(data, self.ItemID)
|
| | | data = CommFunc.WriteWORD(data, self.Count)
|
| | | data = CommFunc.WriteBYTE(data, self.IsAuctionItem)
|
| | | data = CommFunc.WriteWORD(data, self.UserDataLen)
|
| | | data = CommFunc.WriteString(data, self.UserDataLen, self.UserData)
|
| | | return data
|
| | |
|
| | | def OutputString(self):
|
| | | DumpString = '''
|
| | | ItemID:%d,
|
| | | Count:%d,
|
| | | IsAuctionItem:%d,
|
| | | UserDataLen:%d,
|
| | | UserData:%s
|
| | | '''\
|
| | | %(
|
| | | self.ItemID,
|
| | | self.Count,
|
| | | self.IsAuctionItem,
|
| | | self.UserDataLen,
|
| | | self.UserData
|
| | | )
|
| | | return DumpString
|
| | |
|
| | |
|
| | | class tagMCCuntomFBPrizeInfo(Structure):
|
| | | Head = tagHead()
|
| | | MapID = 0 #(DWORD MapID)
|
| | | FuncLineID = 0 #(WORD FuncLineID)
|
| | | PrizeItemCount = 0 #(BYTE PrizeItemCount)
|
| | | PrizeItemList = list() #(vector<tagMCCuntomFBPrizeItem> PrizeItemList)
|
| | | PrizeItemIDList = list() #(vector<DWORD> PrizeItemIDList)
|
| | | data = None
|
| | |
|
| | | def __init__(self):
|
| | |
| | | self.FuncLineID,_pos = CommFunc.ReadWORD(_lpData, _pos)
|
| | | self.PrizeItemCount,_pos = CommFunc.ReadBYTE(_lpData, _pos)
|
| | | for i in range(self.PrizeItemCount):
|
| | | temPrizeItemList = tagMCCuntomFBPrizeItem()
|
| | | _pos = temPrizeItemList.ReadData(_lpData, _pos)
|
| | | self.PrizeItemList.append(temPrizeItemList)
|
| | | value,_pos=CommFunc.ReadDWORD(_lpData,_pos)
|
| | | self.PrizeItemIDList.append(value)
|
| | | return _pos
|
| | |
|
| | | def Clear(self):
|
| | |
| | | self.MapID = 0
|
| | | self.FuncLineID = 0
|
| | | self.PrizeItemCount = 0
|
| | | self.PrizeItemList = list()
|
| | | self.PrizeItemIDList = list()
|
| | | return
|
| | |
|
| | | def GetLength(self):
|
| | |
| | | length += 4
|
| | | length += 2
|
| | | length += 1
|
| | | for i in range(self.PrizeItemCount):
|
| | | length += self.PrizeItemList[i].GetLength()
|
| | | length += 4 * self.PrizeItemCount
|
| | |
|
| | | return length
|
| | |
|
| | |
| | | data = CommFunc.WriteWORD(data, self.FuncLineID)
|
| | | data = CommFunc.WriteBYTE(data, self.PrizeItemCount)
|
| | | for i in range(self.PrizeItemCount):
|
| | | data = CommFunc.WriteString(data, self.PrizeItemList[i].GetLength(), self.PrizeItemList[i].GetBuffer())
|
| | | data = CommFunc.WriteDWORD(data, self.PrizeItemIDList[i])
|
| | | return data
|
| | |
|
| | | def OutputString(self):
|
| | |
| | | MapID:%d,
|
| | | FuncLineID:%d,
|
| | | PrizeItemCount:%d,
|
| | | PrizeItemList:%s
|
| | | PrizeItemIDList:%s
|
| | | '''\
|
| | | %(
|
| | | self.Head.OutputString(),
|
| | |
| | | return callFunc(curPlayer, mapID, lineID)
|
| | |
|
| | | ## 给自定义副本奖励后续处理
|
| | | ## @return: 返回结算副本over信息字典,不含jsonItem信息
|
| | | def OnGiveCustomFBPrizeOK(curPlayer, mapID, lineID):
|
| | | do_FBLogic_ID = __GetFBLogic_MapID(mapID)
|
| | |
|
| | | callFunc = GameWorld.GetExecFunc(FBProcess, "GameLogic_%s.%s" % (do_FBLogic_ID, "OnGiveCustomFBPrizeOK"))
|
| | |
|
| | | if callFunc == None:
|
| | | return
|
| | | return {}
|
| | |
|
| | | return callFunc(curPlayer, mapID, lineID)
|
| | |
|
| | |
| | | return giveItemList
|
| | |
|
| | | ## 给自定义副本奖励后续处理
|
| | | ## @return: 返回结算副本over信息字典,不含jsonItem信息
|
| | | def OnGiveCustomFBPrizeOK(curPlayer, mapID, lineID):
|
| | | __SetDemonKingVisitState(curPlayer, mapID, lineID, PlayerFairyDomain.FDEventState_Visited)
|
| | | return
|
| | | ownerID, ownerName = curPlayer.GetPlayerID(), curPlayer.GetPlayerName()
|
| | | overDict = {FBCommon.Over_ownerID:ownerID, FBCommon.Over_ownerName:ownerName}
|
| | | return overDict
|
| | |
|
| | | def __GetDemonKingPrizeItemList(curPlayer, mapID, lineID, eventID, isOwner):
|
| | | giveItemList = PlayerFairyDomain.GetFairyAppointAward(curPlayer, eventID)
|
| | |
| | | def GivePlayerItemOrMail(curPlayer, itemList, mailKey=None, event=["", False, {}]):
|
| | | ##给物品,背包满则发邮件
|
| | | needPackSpaceDict = {}
|
| | | for itemInfo in itemList:
|
| | | itemID, itemCount, isAuctionItem, userData = GetItemInfo(itemInfo)
|
| | | if not itemID:
|
| | | continue
|
| | | for itemID, itemCnt, isAuctionItem in itemList:
|
| | | curItem = GameWorld.GetGameData().GetItemByTypeID(itemID)
|
| | | if not curItem:
|
| | | GameWorld.ErrLog('GivePlayerItemOrMail 物品ID不存在 itemID=%s'%itemID, curPlayer.GetID())
|
| | | return
|
| | | packType = ChConfig.GetItemPackType(curItem.GetType())
|
| | | needSpace = GetItemNeedPackCount(packType, curItem, itemCount, isAuctionItem)
|
| | | needSpace = GetItemNeedPackCount(packType, curItem, itemCnt, isAuctionItem)
|
| | | needPackSpaceDict[packType] = needPackSpaceDict.get(packType, 0) + needSpace
|
| | | isSendMail = False
|
| | | for packType, needSpace in needPackSpaceDict.items():
|
| | |
| | | if isSendMail:
|
| | | PlayerControl.SendMailByKey(mailKey, [curPlayer.GetPlayerID()], itemList)
|
| | | GameWorld.DebugLog("GivePlayerItemOrMail背包空间不够,发送邮件: mailItemList=%s" % str(itemList), curPlayer.GetPlayerID())
|
| | | return
|
| | | |
| | | playerItemControl = PlayerItemControler(curPlayer)
|
| | | for itemInfo in itemList:
|
| | | itemID, itemCount, isAuctionItem, userData = GetItemInfo(itemInfo)
|
| | | if not itemID:
|
| | | continue
|
| | | if GetAppointItemRealID(itemID):
|
| | | curCreateItem = GetItemByData(GetAppointItemDictData(itemID, isAuctionItem))
|
| | | else:
|
| | | curCreateItem = ItemCommon.CreateSingleItem(itemID, itemCount, isAuctionItem)
|
| | | if not curCreateItem:
|
| | | continue
|
| | | if userData: |
| | | curCreateItem.SetUserData(userData, len(userData))
|
| | | ItemCommon.MakeEquipGS(curCreateItem)
|
| | | #放入玩家背包
|
| | | playerItemControl.PutInItem(IPY_GameWorld.rptItem, curCreateItem, event=event)
|
| | | |
| | | return
|
| | |
|
| | | def GetItemInfo(itemInfo):
|
| | | if isinstance(itemInfo, dict):
|
| | | itemID = itemInfo['ItemID']
|
| | | itemCount = itemInfo['Count']
|
| | | isAuctionItem = itemInfo['IsAuctionItem']
|
| | | userData = itemInfo['UserData']
|
| | | elif isinstance(itemInfo, list) and len(itemInfo) == 3:
|
| | | itemID, itemCount, isAuctionItem = itemInfo
|
| | | userData = ""
|
| | | else:
|
| | | return 0, 0, 0, ""
|
| | | return itemID, itemCount, isAuctionItem, userData
|
| | | for itemID, itemCnt, isAuctionItem in itemList:
|
| | | GivePlayerItem(curPlayer, itemID, itemCnt, isAuctionItem, [IPY_GameWorld.rptItem], event=event)
|
| | | return
|
| | |
|
| | |
| | | mapID = clientData.MapID
|
| | | funcLineID = clientData.FuncLineID
|
| | | prizeItemList = FBLogic.OnRefreshCustomFBPrize(curPlayer, mapID, funcLineID)
|
| | | if not prizeItemList:
|
| | | return
|
| | | PyGameData.g_customFBPrizeInfo[playerID] = [mapID, funcLineID, prizeItemList]
|
| | | PyGameData.g_customFBPrizeInfo[playerID] = prizeItemList
|
| | | prizePack = ChPyNetSendPack.tagMCCuntomFBPrizeInfo()
|
| | | prizePack.MapID = mapID
|
| | | prizePack.FuncLineID = funcLineID
|
| | | prizePack.PrizeItemList = []
|
| | | for prizeItemInfo in prizeItemList:
|
| | | itemID, itemCount, isAuctionItem, userData = ItemControler.GetItemInfo(prizeItemInfo)
|
| | | if not itemID:
|
| | | continue
|
| | | prizeItem = ChPyNetSendPack.tagMCCuntomFBPrizeItem()
|
| | | prizeItem.ItemID = itemID
|
| | | prizeItem.Count = itemCount
|
| | | prizeItem.IsAuctionItem = isAuctionItem
|
| | | prizeItem.UserData = userData
|
| | | prizeItem.UserDataLen = len(prizeItem.UserData)
|
| | | prizePack.PrizeItemList.append(prizeItem)
|
| | | prizePack.PrizeItemCount = len(prizePack.PrizeItemList)
|
| | | prizePack.PrizeItemIDList = [prizeItemInfo[0] for prizeItemInfo in prizeItemList]
|
| | | prizePack.PrizeItemCount = len(prizePack.PrizeItemIDList)
|
| | | NetPackCommon.SendFakePack(curPlayer, prizePack)
|
| | | return
|
| | |
|
| | |
| | | def OnGiveCustomFBPrize(playerIndex, clientData, tick):
|
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(playerIndex)
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | packMapID = clientData.MapID
|
| | | packFuncLineID = clientData.FuncLineID
|
| | | prizeInfo = PyGameData.g_customFBPrizeInfo.pop(playerID, None)
|
| | | if not prizeInfo:
|
| | | return
|
| | | mapID, funcLineID, prizeItemList = prizeInfo
|
| | | if mapID != packMapID or funcLineID != packFuncLineID:
|
| | | return
|
| | | FBLogic.OnGiveCustomFBPrizeOK(curPlayer, mapID, funcLineID)
|
| | | ItemControler.GivePlayerItemOrMail(curPlayer, prizeItemList)
|
| | | mapID = clientData.MapID
|
| | | lineID = clientData.FuncLineID
|
| | | prizeItemList = PyGameData.g_customFBPrizeInfo.pop(playerID, [])
|
| | | |
| | | mailItemList = []
|
| | | jsonItemList = []
|
| | | playerItemControl = ItemControler.PlayerItemControler(curPlayer)
|
| | | for itemID, itemCount, isAuctionItem in prizeItemList:
|
| | | curItem = ItemControler.GetOutPutItemObj(itemID, itemCount, isAuctionItem, curPlayer=curPlayer)
|
| | | if not curItem:
|
| | | continue
|
| | | jsonItem = ItemCommon.GetJsonItem(curItem)
|
| | | jsonItemList.append(jsonItem)
|
| | | #放入玩家背包
|
| | | if not playerItemControl.PutInItem(IPY_GameWorld.rptItem, curItem):
|
| | | mailItemList.append(jsonItem)
|
| | | |
| | | if mailItemList:
|
| | | PlayerControl.SendMailByKey("ItemNoPickUp", [playerID], mailItemList, [mapID])
|
| | | |
| | | overDict = FBLogic.OnGiveCustomFBPrizeOK(curPlayer, mapID, lineID)
|
| | | isPass = 1
|
| | | overDict.update({FBCommon.Over_itemInfo:jsonItemList})
|
| | | FBCommon.NotifyFBOver(curPlayer, mapID, lineID, isPass, overDict)
|
| | | return
|
| | |
|
| | |
|