129 【战斗】战斗系统-服务端(优化多地图战斗发送接收日志;)
| | |
| | | isMultiMap = True
|
| | |
|
| | | if isMultiMap:
|
| | | CrossServerPackLogic.SendToBattleServer(ShareDefine.SSMsg_BattleRequest, reqInfo, reqPlayerID)
|
| | | CrossServerPackLogic.SendBattleRequest(reqInfo, guid, mapID, funcLineID, reqPlayerID)
|
| | | else:
|
| | | SSMsg_BattleRequest(reqInfo, fromServerID)
|
| | | return
|
| | |
|
| | | def SSMsg_BattleRequest(reqInfo, fromServerID):
|
| | | def SSMsg_BattleRequest(reqInfo, fromServerID, msgType=""):
|
| | | ## 请求执行战斗,由本地图或其他服务器地图分配过来的战斗请求
|
| | | guid, mapID, funcLineID, lineupDictA, lineupDictB, reqPlayerID, playerServerID, npcLineupIDList, strongerLV, difficulty, reqData = reqInfo
|
| | | |
| | | if msgType:
|
| | | GameWorld.Log("OnServerReceiveMsg => %s, fromServerID=%s,funcMapID=%s,funcLineID=%s,%s,%s" |
| | | % (msgType, fromServerID, mapID, funcLineID, guid, time.time()), reqPlayerID)
|
| | | |
| | | if npcLineupIDList:
|
| | | turnFight = DoTurnFightPVE(guid, mapID, funcLineID, reqPlayerID, playerServerID, lineupDictA, npcLineupIDList, strongerLV, difficulty)
|
| | | else:
|
| | |
| | |
|
| | | # 其他服务器地图请求的,发送战斗结果回去
|
| | | else:
|
| | | CrossServerPackLogic.SendToServer(ShareDefine.SSMsg_BattleResult, retInfo, [fromServerID], playerID=reqPlayerID)
|
| | | CrossServerPackLogic.SendBattleResult(retInfo, fromServerID, guid, mapID, funcLineID, reqPlayerID)
|
| | | return
|
| | |
|
| | | def SSMsg_BattleResult(retInfo, fromServerID):
|
| | | def SSMsg_BattleResult(retInfo, fromServerID, msgType=""):
|
| | | ## 收到战斗结果信息
|
| | |
|
| | | guid, mapID, funcLineID, reqPlayerID, winFaction, statMsg, dateStr, reqData = retInfo
|
| | | |
| | | if msgType:
|
| | | GameWorld.Log("OnServerReceiveMsg => %s, fromServerID=%s,funcMapID=%s,funcLineID=%s,%s,%s" |
| | | % (msgType, fromServerID, mapID, funcLineID, guid, time.time()), reqPlayerID)
|
| | | |
| | | curPlayer = None
|
| | | if reqPlayerID:
|
| | | curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(reqPlayerID)
|
| | |
| | | SendToServer(msgType, dataMsg, serverIDList, ShareDefine.dirType_Main, playerID, isLog=False) # 默认发给主服即可
|
| | | return
|
| | |
|
| | | def SendToBattleServer(msgType, dataMsg, playerID=0):
|
| | | SendToServer(msgType, dataMsg, dirType=ShareDefine.dirType_Battle, playerID=playerID)
|
| | | def SendBattleRequest(dataMsg, guid, mapID, funcLineID, reqPlayerID=0):
|
| | | msgType = ShareDefine.SSMsg_BattleRequest
|
| | | GameWorld.Log("SendToBattleServer => %s, funcMapID=%s,funcLineID=%s,%s,%s" % (msgType, mapID, funcLineID, guid, time.time()), reqPlayerID)
|
| | | SendToServer(msgType, dataMsg, dirType=ShareDefine.dirType_Battle, playerID=reqPlayerID, isLog=False)
|
| | | return
|
| | |
|
| | | def SendBattleResult(retInfo, fromServerID, guid, mapID, funcLineID, reqPlayerID=0):
|
| | | msgType = ShareDefine.SSMsg_BattleResult
|
| | | GameWorld.Log("SendToFromServer => %s, fromServerID=%s,funcMapID=%s,funcLineID=%s,%s,%s" |
| | | % (msgType, fromServerID, mapID, funcLineID, guid, time.time()), reqPlayerID)
|
| | | SendToServer(msgType, retInfo, [fromServerID], ShareDefine.dirType_Main, reqPlayerID, isLog=False)
|
| | | return
|
| | |
|
| | | def SendToServer(msgType, dataMsg, serverIDList=None, dirType=ShareDefine.dirType_Main, playerID=0, isLog=True):
|
| | |
| | | try:
|
| | | dataMsg = cPickle.loads(recvMsg)
|
| | | if GameWorld.IsCrossServer():
|
| | | GameWorld.Log("OnCrossServerReceiveMsg: %s, fromServerID=%s, %s" % (msgType, fromServerID, dataMsg))
|
| | | pass #GameWorld.Log("OnCrossServerReceiveMsg: %s, fromServerID=%s, %s" % (msgType, fromServerID, dataMsg))
|
| | | else:
|
| | | GameWorld.Log("OnClientServerReceiveMsg: %s, fromServerID=%s, %s" % (msgType, fromServerID, dataMsg))
|
| | | pass #GameWorld.Log("OnClientServerReceiveMsg: %s, fromServerID=%s, %s" % (msgType, fromServerID, dataMsg))
|
| | |
|
| | | crossServerID = GetCrossServerID()
|
| | | if crossServerID == fromServerID:
|
| | | __fixCrossServerTime(msgType, fromServerTime)
|
| | |
|
| | | if msgType == ShareDefine.SSMsg_BattleRequest:
|
| | | TurnAttack.SSMsg_BattleRequest(dataMsg, fromServerID)
|
| | | TurnAttack.SSMsg_BattleRequest(dataMsg, fromServerID, msgType)
|
| | | elif msgType == ShareDefine.SSMsg_BattleResult:
|
| | | TurnAttack.SSMsg_BattleResult(dataMsg, fromServerID)
|
| | | TurnAttack.SSMsg_BattleResult(dataMsg, fromServerID, msgType)
|
| | |
|
| | | except:
|
| | | GameWorld.RaiseException("服务器接收信息处理报错 \r\n%s" % str(traceback.format_exc()))
|