5722 【后端】【1.5】跨服BOSS开发(支持拾取物品、货币、好物品记录)
| | |
| | | import PlayerControl
|
| | | import IPY_GameServer
|
| | | import CrossRealmPlayer
|
| | | import GameWorldBoss
|
| | | import CrossRealmPK
|
| | | import CrossBoss
|
| | | import ChConfig
|
| | |
| | | elif msgType == ShareDefine.CrossServerMsg_CrossBossState:
|
| | | CrossBoss.CrossServerMsg_CrossBossState(msgData)
|
| | |
|
| | | elif msgType == ShareDefine.CrossServerMsg_PutInItem:
|
| | | CrossRealmPlayer.CrossServerMsg_PutInItem(msgData)
|
| | | |
| | | elif msgType == ShareDefine.CrossServerMsg_GiveMoney:
|
| | | CrossRealmPlayer.CrossServerMsg_GiveMoney(msgData)
|
| | | |
| | | elif msgType == ShareDefine.CrossServerMsg_DropGoodItem:
|
| | | GameWorldBoss.CrossServerMsg_DropGoodItem(msgData, tick)
|
| | | |
| | | elif msgType == ShareDefine.CrossServerMsg_CrossServerState:
|
| | | CrossRealmPlayer.CrossServerMsg_CrossServerState(msgData)
|
| | |
|
| | |
| | | import PyGameDataStruct
|
| | | import PyDataManager
|
| | | import PlayerControl
|
| | | import CrossRealmMsg
|
| | | import CommFunc
|
| | | import PyGameData
|
| | | import PlayerGeTui
|
| | |
| | |
|
| | | ##--------------------------------------------------------------------------------------------------
|
| | |
|
| | | def CrossServerMsg_DropGoodItem(msgList, tick):
|
| | | ## 收到跨服服务器同步的掉落好物品信息
|
| | | playerID = msgList[0]
|
| | | curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
|
| | | if curPlayer:
|
| | | msgList[1] = curPlayer.GetName() # 本服玩家在线,修改为本服玩家的名字展示
|
| | | OnKillBossDropGoodItem(msgList, tick)
|
| | | return
|
| | |
|
| | | def OnKillBossDropGoodItem(msgList, tick):
|
| | | # playerName, mapID, npcID, itemID, userData
|
| | | if len(msgList) != 7:
|
| | | if len(msgList) != 8:
|
| | | return
|
| | | playerID, killerName, mapID, npcID, itemID, userData, weightValue = msgList
|
| | | GameWorld.DebugLog("击杀Boss掉落好物品: mapID=%s,npcID=%s,killerName=%s,itemID=%s, userData=%s, weightValue=%s" |
| | | % (mapID, npcID, killerName, itemID, userData, weightValue))
|
| | | playerID, killerName, mapID, npcID, itemID, userData, weightValue, serverGroupID = msgList
|
| | | GameWorld.DebugLog("击杀Boss掉落好物品: mapID=%s,npcID=%s,killerName=%s,itemID=%s, userData=%s, weightValue=%s, serverGroupID=%s" |
| | | % (mapID, npcID, killerName, itemID, userData, weightValue, serverGroupID))
|
| | | maxRecordCnt = IpyGameDataPY.GetFuncCfg('DropRecordNum')
|
| | | if not maxRecordCnt:
|
| | | return
|
| | | |
| | | if GameWorld.IsCrossServer():
|
| | | # 同步到玩家对应子服
|
| | | if not serverGroupID:
|
| | | return
|
| | | CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_DropGoodItem, msgList, [serverGroupID])
|
| | | return
|
| | | |
| | | recType = ShareDefine.Def_UniversalGameRecType_BossDropGoodItemInfo
|
| | | universalRecMgr = GameWorld.GetUniversalRecMgr()
|
| | | recordList = universalRecMgr.GetTypeList(recType)
|
| | |
| | |
|
| | | PlayerUniversalGameRec.MapServer_UniversalGameRec(None, recType, [mapID, npcID, itemID, playerID, weightValue],
|
| | | [killerName, "", userData])
|
| | | |
| | | msgList = [killerName, playerID, mapID, npcID, itemID, userData]
|
| | | PlayerControl.WorldNotify(0, 'DropRecord' , msgList)
|
| | | return
|
| | |
|
| | |
|
| | |
| | | import ChConfig
|
| | | import PlayerControl
|
| | | import PlayerViewCache
|
| | | import PlayerCompensation
|
| | | import ChPyNetSendPack
|
| | | import PlayerDBGSEvent
|
| | | import NetPackCommon
|
| | |
| | | NetPackCommon.SendFakePack(curPlayer, sendPack)
|
| | | return
|
| | |
|
| | |
|
| | | def CrossServerMsg_PutInItem(itemInfo):
|
| | | ## 跨服获得物品
|
| | |
|
| | | GameWorld.DebugLog("收到跨服服务器获得物品!")
|
| | | playerID = itemInfo["PlayerID"]
|
| | | itemData = itemInfo["ItemData"]
|
| | | event = itemInfo["Event"]
|
| | | curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
|
| | | if curPlayer:
|
| | | # 在线的话推到MapServer处理
|
| | | itemMsg = str(itemInfo)
|
| | | curPlayer.MapServer_QueryPlayerResult(0, 0, "CrossPutInItem", itemMsg, len(itemMsg))
|
| | | return
|
| | | # 离线的话直接发邮件
|
| | | GameWorld.Log("收到跨服获得物品,玩家不在线,直接发邮件! itemInfo=%s" % str(itemInfo), playerID)
|
| | | itemID, itemCount, isBind, itemUserData = itemData
|
| | | addItemList = [{"ItemID":itemID, "Count":itemCount, "IsBind":isBind, "UserData":itemUserData}]
|
| | | PlayerCompensation.SendMailByKey("", [playerID], addItemList, detail={"CrossPutInItem":1, "Event":event})
|
| | | return
|
| | |
|
| | | def CrossServerMsg_GiveMoney(msgInfo):
|
| | | ## 跨服获得货币
|
| | | |
| | | playerID = msgInfo["PlayerID"]
|
| | | curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
|
| | | if not curPlayer:
|
| | | GameWorld.ErrLog("跨服获得货币时玩家不在线! msgInfo=%s" % str(msgInfo), playerID)
|
| | | return
|
| | | msgInfo = str(msgInfo)
|
| | | curPlayer.MapServer_QueryPlayerResult(0, 0, "CrossGiveMoney", msgInfo, len(msgInfo))
|
| | | return
|
| | |
|
| | |
|
| | | |
| | |
| | | #------------------------------------------------------------------------------
|
| | | import GameWorld
|
| | | import ChConfig
|
| | | #import ShareDefine
|
| | | import ShareDefine
|
| | | import IPY_GameServer
|
| | | import ChGameToMapPyPack
|
| | | import NetPackCommon
|
| | |
| | | return
|
| | |
|
| | | def SendMailByKey(mailTypeKey, playerIDList, addItemList, paramList=[], gold=0, goldPaper=0, silver=0, detail=""):
|
| | | if not mailTypeKey:
|
| | | mailTypeKey = ShareDefine.DefaultLackSpaceMailType
|
| | | GameWorld.DebugLog("SendMailByKey %s, playerIDList=%s, addItemList=%s, paramList=%s, gold=%s, goldPaper=%s, silver=%s"
|
| | | % (mailTypeKey, playerIDList, addItemList, paramList, gold, goldPaper, silver))
|
| | | title = ""
|
| | |
| | | CrossServerMsg_PKSyncBillboard = "PKSyncBillboard" # 跨服PK同步排行榜
|
| | | CrossServerMsg_CrossBossInfo = "CrossBossInfo" # 跨服Boss信息
|
| | | CrossServerMsg_CrossBossState = "CrossBossState" # 跨服Boss状态
|
| | | CrossServerMsg_PutInItem = "PutInItem" # 获得物品
|
| | | CrossServerMsg_GiveMoney = "GiveMoney" # 获得货币
|
| | | CrossServerMsg_DropGoodItem = "DropGoodItem" # 掉落好物品
|
| | |
|
| | | # 子服发送跨服信息定义
|
| | | ClientServerMsg_ServerInitOK = "ServerInitOK" # 子服启动成功
|
| | |
| | | return
|
| | |
|
| | | if dropItemNPCID:
|
| | | serverGroupID = PlayerControl.GetPlayerServerGroupID(curPlayer)
|
| | | mapID = GameWorld.GetGameWorld().GetMapID()
|
| | | NPCCommon.SendGameServerGoodItemRecord(mapID, dropItemNPCID, curPlayer.GetName(),
|
| | | curPlayer.GetPlayerID(), curItemID, equipInfo)
|
| | | curPlayer.GetPlayerID(), curItemID, equipInfo, serverGroupID)
|
| | |
|
| | | # 不需要队伍提示
|
| | | #=======================================================================
|
| | |
| | | PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_Honor, itemCount)
|
| | | return True
|
| | |
|
| | | def __CrossServerPutInItem(self, packIndex, tagItem, event=["", False, {}]):
|
| | | ## 跨服获得物品
|
| | | curPlayer = self.__Player
|
| | | serverGroupID = PlayerControl.GetPlayerServerGroupID(curPlayer)
|
| | | itemData = [tagItem.GetItemTypeID(), tagItem.GetCount(), tagItem.GetIsBind(), tagItem.GetUserData()]
|
| | | itemMsg = {"PlayerID":curPlayer.GetPlayerID(), "ItemData":itemData, "PackIndex":packIndex, "Event":event}
|
| | | GameWorld.SendMsgToClientServer(ShareDefine.CrossServerMsg_PutInItem, itemMsg, [serverGroupID])
|
| | | return
|
| | | |
| | | ## 放入物品
|
| | | # @param packIndex 背包索引
|
| | | # @param tagItem 物品
|
| | |
| | | curItemData = GameWorld.GetGameData().GetItemByTypeID(tagItem.GetItemTypeID())
|
| | | if not curItemData:
|
| | | return False
|
| | | |
| | | if GameWorld.IsCrossServer():
|
| | | self.__CrossServerPutInItem(packIndex, tagItem, event)
|
| | | tagItem.Clear()
|
| | | return True
|
| | |
|
| | | packIndex = ChConfig.GetItemPackType(curItemData.GetType(), packIndex)
|
| | |
|
| | |
| | | # @return True or False
|
| | | # @remarks 函数详细说明.
|
| | | def CanPutInItem(self, packIndex, curItemID, curItemCount, isBind, defaultPile=True):
|
| | | if GameWorld.IsCrossServer():
|
| | | return True
|
| | | checkRet, putIndex = self.CanPutInItemEx(packIndex, curItemID, curItemCount, isBind, defaultPile)
|
| | | return checkRet
|
| | |
|
| | |
| | | NetPackCommon.SendFakePack(curPlayer, npcInfoPack)
|
| | | return
|
| | |
|
| | | def SendGameServerGoodItemRecord(mapID, npcID, playerName, playerID, itemID, equipInfo=[]):
|
| | | def SendGameServerGoodItemRecord(mapID, npcID, playerName, playerID, itemID, equipInfo=[], serverGroupID=0):
|
| | | # @param equipInfo: [equipPlace, itemClassLV, itemColor, itemQuality, itemUserData]
|
| | | # GameWorld.DebugLog("检查物品是否发送GameServer: mapID=%s, npcID=%s, playerName=%s, itemID=%s"
|
| | | # % (mapID, npcID, playerName, itemID))
|
| | |
| | | if not needRecord:
|
| | | return
|
| | |
|
| | | dropEquipMsg = str([playerID, playerName, mapID, npcID, itemID, itemUserData, weightValue])
|
| | | dropEquipMsg = str([playerID, playerName, mapID, npcID, itemID, itemUserData, weightValue, serverGroupID])
|
| | | GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, 'BossDropGoodItem', dropEquipMsg, len(dropEquipMsg))
|
| | | GameWorld.DebugLog("发送GameServer记录拾取掉落好物品: %s" % dropEquipMsg, playerID)
|
| | | |
| | | msgList = [playerName, playerID, mapID, npcID, itemID, itemUserData]
|
| | | |
| | | PlayerControl.WorldNotify(0, 'DropRecord' , msgList)
|
| | | return
|
| | |
|
| | | #// A5 52 购买功能NPC采集次数 #tagCMBuyCollectionCnt
|
| | |
| | | GameWorld.ErrLog("ChangeLine -> 封包错误, 无此线路 = %s" % (changLineID), curPlayer.GetID())
|
| | | return
|
| | |
|
| | | if GameWorld.IsCrossServer():
|
| | | # 跨服服务器无法切线
|
| | | return
|
| | | |
| | | mapID = curPlayer.GetMapID()
|
| | |
|
| | | activityLineID = 0 # 活动线, 默认1线
|
| | |
| | | GameWorld.DebugLog("WorldTransPort packTransportType=%s,mapID=%s,lineID=%s,exData1=%s"
|
| | | % (packTransportType, mapID, lineID, exData1), playerID)
|
| | | lineID = -1 if lineID == 255 else lineID
|
| | | if GameWorld.IsCrossServer():
|
| | | if curPlayer.GetMapID() != mapID:
|
| | | return
|
| | | lineID = -1 # 跨服默认只能本线
|
| | | |
| | | #世界传送封包允许类型(世界,大地图,任务)
|
| | | if packTransportType not in ChConfig.Def_PackType_TransportType.keys():
|
| | | GameWorld.ErrLog('WorldTransPort packTransportType = %s, NoFind' % (packTransportType), playerID)
|
| | |
| | | GameWorld.DebugLog("跨服服务器不允许该操作!")
|
| | | return
|
| | |
|
| | | if GetCrossRealmState(curPlayer):
|
| | | GameWorld.ErrLog("玩家当前为跨服状态,不允许再次请求进入跨服!", curPlayer.GetPlayerID())
|
| | | return
|
| | | |
| | | if not CrossRealmPlayer.IsCrossServerOpen():
|
| | | NotifyCode(curPlayer, "CrossMatching18")
|
| | | return
|
| | |
| | | if PlayerTJG.GetIsTJG(curPlayer):
|
| | | GameWorld.DebugLog("脱机的玩家不处理分流!", curPlayer.GetPlayerID())
|
| | | return tagLineID
|
| | | |
| | | if GameWorld.IsCrossServer():
|
| | | return tagLineID
|
| | | # 非常规地图之间的切换不处理
|
| | | if curMapID not in PyGameData.g_commMapLinePlayerCountDict or tagMapID not in PyGameData.g_commMapLinePlayerCountDict:
|
| | | return tagLineID
|
| | |
| | | GameWorld.Log('玩家获得金钱异常 , value = %s , priceType = %s ,' % (value, priceType))
|
| | | return
|
| | |
|
| | | if GameWorld.IsCrossServer():
|
| | | serverGroupID = GetPlayerServerGroupID(curPlayer)
|
| | | msgInfo = {"PlayerID":curPlayer.GetPlayerID(), "MoneyType":priceType, "Value":value, "GiveType":giveType, "AddDataDict":addDataDict}
|
| | | GameWorld.SendMsgToClientServer(ShareDefine.CrossServerMsg_GiveMoney, msgInfo, [serverGroupID])
|
| | | return True
|
| | | |
| | | if priceType == IPY_GameWorld.TYPE_Price_Gold_Money:
|
| | | if curPlayer.GetGold() + value > ChConfig.Def_PlayerTotalMoney_Gold:
|
| | | #超过金钱上限
|
New file |
| | |
| | | #!/usr/bin/python
|
| | | # -*- coding: GBK -*-
|
| | | #-------------------------------------------------------------------------------
|
| | | #
|
| | | ##@package Player.RemoteQuery.GY_Query_CrossGiveMoney
|
| | | #
|
| | | # @todo:跨服获得货币
|
| | | # @author hxp
|
| | | # @date 2019-01-09
|
| | | # @version 1.0
|
| | | #
|
| | | # 详细描述: 跨服获得货币
|
| | | #
|
| | | #-------------------------------------------------------------------------------
|
| | | #"""Version = 2019-01-09 19:30"""
|
| | | #-------------------------------------------------------------------------------
|
| | |
|
| | | import GameWorld
|
| | | import PlayerControl
|
| | |
|
| | | #------------------------------------------------------------------------------ |
| | | ## 跨服赛报名调用接口
|
| | | # @param query_Type 请求类型
|
| | | # @param query_ID 请求的玩家ID
|
| | | # @param packCMDList 发包命令
|
| | | # @param tick 当前时间
|
| | | # @return "True" or "False" or ""
|
| | | # @remarks 函数详细说明.
|
| | | def DoLogic(query_Type, query_ID, packCMDList, tick): |
| | | return
|
| | |
|
| | |
|
| | | #------------------------------------------------------------------------------ |
| | | ## 执行结果
|
| | | # @param curPlayer 发出请求的玩家
|
| | | # @param callFunName 功能名称
|
| | | # @param funResult 查询的结果
|
| | | # @param tick 当前时间
|
| | | # @return None
|
| | | # @remarks 函数详细说明.
|
| | | def DoResult(curPlayer, callFunName, funResult, tick):
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | GameWorld.Log("GY_Query_CrossGiveMoney %s" % funResult, playerID)
|
| | | msgInfo = eval(funResult)
|
| | | if playerID != msgInfo["PlayerID"]:
|
| | | return
|
| | | #"PlayerID":curPlayer.GetPlayerID(), "MoneyType":priceType, "Value":value, "GiveType":giveType, "AddDataDict":addDataDict
|
| | | priceType = msgInfo["MoneyType"]
|
| | | value = msgInfo["Value"]
|
| | | giveType = msgInfo["GiveType"]
|
| | | addDataDict = msgInfo["AddDataDict"]
|
| | | PlayerControl.GiveMoney(curPlayer, priceType, value, giveType, addDataDict)
|
| | | return
|
| | |
|
| | | |
| | | |
New file |
| | |
| | | #!/usr/bin/python
|
| | | # -*- coding: GBK -*-
|
| | | #-------------------------------------------------------------------------------
|
| | | #
|
| | | ##@package Player.RemoteQuery.GY_Query_CrossPutInItem
|
| | | #
|
| | | # @todo:跨服获得物品
|
| | | # @author hxp
|
| | | # @date 2019-01-09
|
| | | # @version 1.0
|
| | | #
|
| | | # 详细描述: 跨服获得物品
|
| | | #
|
| | | #-------------------------------------------------------------------------------
|
| | | #"""Version = 2019-01-09 19:30"""
|
| | | #-------------------------------------------------------------------------------
|
| | |
|
| | | import GameWorld
|
| | | import ItemCommon
|
| | | import ItemControler
|
| | | import PlayerControl
|
| | |
|
| | | #------------------------------------------------------------------------------ |
| | | ## 跨服赛报名调用接口
|
| | | # @param query_Type 请求类型
|
| | | # @param query_ID 请求的玩家ID
|
| | | # @param packCMDList 发包命令
|
| | | # @param tick 当前时间
|
| | | # @return "True" or "False" or ""
|
| | | # @remarks 函数详细说明.
|
| | | def DoLogic(query_Type, query_ID, packCMDList, tick): |
| | | return
|
| | |
|
| | |
|
| | | #------------------------------------------------------------------------------ |
| | | ## 执行结果
|
| | | # @param curPlayer 发出请求的玩家
|
| | | # @param callFunName 功能名称
|
| | | # @param funResult 查询的结果
|
| | | # @param tick 当前时间
|
| | | # @return None
|
| | | # @remarks 函数详细说明.
|
| | | def DoResult(curPlayer, callFunName, funResult, tick):
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | GameWorld.Log("GY_Query_CrossPutInItem %s" % funResult, playerID)
|
| | | itemInfo = eval(funResult)
|
| | | if playerID != itemInfo["PlayerID"]:
|
| | | return
|
| | | itemData = itemInfo["ItemData"]
|
| | | packIndex = itemInfo["PackIndex"]
|
| | | event = itemInfo["Event"]
|
| | | itemID, itemCount, isBind, itemUserData = itemData
|
| | | curItem = ItemCommon.CreateSingleItem(itemID, itemCount, isBind)
|
| | | if not curItem:
|
| | | return
|
| | | if itemUserData and itemUserData != "{}":
|
| | | curItem.SetUserData(itemUserData, len(itemUserData))
|
| | | |
| | | if ItemControler.PlayerItemControler(curPlayer).PutInItem(packIndex, curItem, event=event):
|
| | | return
|
| | | |
| | | # 放入失败发邮件
|
| | | GameWorld.Log("收到跨服获得物品,放入失败,直接发邮件! itemInfo=%s" % str(itemInfo), playerID)
|
| | | addItemList = [{"ItemID":itemID, "Count":itemCount, "IsBind":isBind, "UserData":itemUserData}]
|
| | | PlayerControl.SendMailByKey("", [playerID], addItemList, detail={"CrossPutInItem":1, "Event":event})
|
| | | return
|
| | |
|
| | | |
| | | |
| | |
| | | CrossServerMsg_PKSyncBillboard = "PKSyncBillboard" # 跨服PK同步排行榜
|
| | | CrossServerMsg_CrossBossInfo = "CrossBossInfo" # 跨服Boss信息
|
| | | CrossServerMsg_CrossBossState = "CrossBossState" # 跨服Boss状态
|
| | | CrossServerMsg_PutInItem = "PutInItem" # 获得物品
|
| | | CrossServerMsg_GiveMoney = "GiveMoney" # 获得货币
|
| | | CrossServerMsg_DropGoodItem = "DropGoodItem" # 掉落好物品
|
| | |
|
| | | # 子服发送跨服信息定义
|
| | | ClientServerMsg_ServerInitOK = "ServerInitOK" # 子服启动成功
|