#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#-------------------------------------------------------------------------------
|
#
|
##@package Player.CrossRealmPlayer
|
#
|
# @todo:¿ç·þÍæ¼Ò
|
# @author hxp
|
# @date 2018-12-21
|
# @version 1.0
|
#
|
# ÏêϸÃèÊö: ¿ç·þÍæ¼Ò
|
#
|
#-------------------------------------------------------------------------------
|
#"""Version = 2018-12-21 18:00"""
|
#-------------------------------------------------------------------------------
|
import GameWorld
|
import PyGameData
|
import ReadChConfig
|
import PlayerControl
|
import IpyGameDataPY
|
import IPY_GameWorld
|
import ChPyNetSendPack
|
import NetPackCommon
|
import ShareDefine
|
import ChConfig
|
import FBLogic
|
import PlayerAssist
|
|
def GetPlayerCrossPropDataShort(curPlayer):
|
## »ñÈ¡¿ç·þÍæ¼ÒÊôÐÔ¼ò¶ÌÐÅÏ¢
|
PropData = {}
|
PropData["AccID"] = curPlayer.GetAccID()
|
PropData["LV"] = curPlayer.GetLV()
|
PropData["RealmLV"] = curPlayer.GetOfficialRank()
|
PropData["Job"] = curPlayer.GetJob()
|
PropData["Name"] = GetCrossPlayerName(curPlayer)
|
PropData["FightPower"] = PlayerControl.GetFightPower(curPlayer)
|
return PropData
|
|
# »ñÈ¡Íæ¼Ò¿ç·þ·þÎñÆ÷ÉϵÄÃû×Ö
|
def GetCrossPlayerName(curPlayer):
|
# ͨ¹ýÓÎÏ·Õ˺ÅÖÐµÄÆ½Ì¨±êÖ¾»ñÈ¡Ãû³Æ£¬Ä¿Ç°Îªspid
|
playerName = curPlayer.GetPlayerName()
|
|
opName = ReadChConfig.GetPyMongoConfig("Merge", "OpName_%s_%s" % (GameWorld.GetPlayerPlatform(curPlayer),
|
GameWorld.GetPlayerServerSID(curPlayer)))
|
|
if not opName:
|
return playerName
|
|
return opName.decode('gbk').encode(GameWorld.GetCharacterEncoding()) + playerName
|
|
def GetCrossPlayerZoneID(curPlayer, mapID):
|
## »ñÈ¡Íæ¼Ò¿ç·þ¹¦ÄÜËùÊô·ÖÇø
|
serverGroupID = PlayerControl.GetPlayerServerGroupID(curPlayer)
|
zoneIpyData = GetCrossZoneIpyDataByServerGroupID(mapID, serverGroupID)
|
if not zoneIpyData:
|
return 0
|
return zoneIpyData.GetZoneID()
|
|
def GetCrossZoneIpyDataByServerGroupID(mapID, serverGroupID):
|
## »ñÈ¡¿ç·þ·ÖÇø
|
zoneTypeName = ChConfig.Def_CrossZoneTypeName.get(mapID, "CrossZoneComm")
|
crossZoneName = GameWorld.GetCrossZoneName()
|
ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition(zoneTypeName, {"CrossZoneName":crossZoneName}, True)
|
if not ipyDataList:
|
return
|
for ipyData in ipyDataList:
|
serverGroupIDList = ipyData.GetServerGroupIDList()
|
for serverGroupIDInfo in serverGroupIDList:
|
if (isinstance(serverGroupIDInfo, tuple) and serverGroupIDInfo[0] <= serverGroupID <= serverGroupIDInfo[1]) \
|
or (isinstance(serverGroupIDInfo, int) and serverGroupIDInfo == serverGroupID):
|
return ipyData
|
GameWorld.ErrLog("ûÓÐÕÒµ½¿ç·þÍæ·¨¶ÔÓ¦·ÖÇø! mapID=%s, serverGroupID=%s, zoneTypeName=%s" % (mapID, serverGroupID, zoneTypeName))
|
return
|
|
def GetServerCrossZoneMapIpyData(zoneID, mapID):
|
## »ñÈ¡±¾·þ¶ÔÓ¦¿ç·þÍæ·¨·ÖÇøµØÍ¼ÐÅÏ¢ - ½öÊÊÓÃÓڹ̶¨µØÍ¼¼°ÐéÄâ·ÖÏߵĿç·þÍæ·¨
|
if mapID not in ChConfig.Def_CrossZoneMapTableName:
|
return
|
tableName = ChConfig.Def_CrossZoneMapTableName[mapID]
|
return IpyGameDataPY.GetIpyGameDataByCondition(tableName, {"ZoneID":zoneID})
|
|
def IsCrossServerOpen():
|
## ¿ç·þ·þÎñÆ÷ÊÇ·ñ¿ª·ÅÖÐ
|
return GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossServerOpen)
|
|
def SetCrossPlayerAttrValue(curPlayer, setDict, isDelay=True):
|
''' ÅúÁ¿ÉèÖÃÍæ¼ÒÊôÐÔÖµ
|
@param setDict: ÉèÖÃÊôÐÔ×Öµä {attrName:attrValue, ...}
|
@param isDelay: ÊÇ·ñÑÓ³Ùͬ²½£¬±ÈÈçOnDay¸üеÄÊýÖµ£¬¿ÉÄܶà¸öÍæ¼Òͬʱ¸üжà¸öÊôÐÔÖµ£¬ËùÒÔÐèÒªÉèÖÃÑÓ³Ùͳһͬ²½£¬ÆäËû¾ßÌå¸ù¾Ý¹¦ÄÜÐèҪѡÔñÊÇ·ñÑÓ³Ù
|
'''
|
if not setDict or not PlayerControl.GetCrossMapID(curPlayer):
|
return
|
playerID = curPlayer.GetPlayerID()
|
setType = "PlayerAttr"
|
msgList = str([playerID, setType, setDict, isDelay])
|
GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, "SetCrossPlayerAttrValue", msgList, len(msgList))
|
GameWorld.DebugLog("¸üпç·þÍæ¼ÒÊôÐÔ: isDelay=%s,%s" % (isDelay, setDict), playerID)
|
return
|
|
def SetCrossPlayerNomalDict(curPlayer, setDict, isDelay=True):
|
''' ÅúÁ¿ÉèÖÃÍæ¼Ò×ÖµäÖµ
|
@param setDict: ÉèÖÃ×Öµä, ÎÞ dictType ÐÅϢʱĬÈÏÀàÐÍ0 {dictKey:dictValue, dictKey:[dictValue, dictType], ...}
|
@param isDelay: ÊÇ·ñÑÓ³Ùͬ²½£¬±ÈÈçOnDay¸üеÄÊýÖµ£¬¿ÉÄܶà¸öÍæ¼Òͬʱ¸üжà¸öÊôÐÔÖµ£¬ËùÒÔÐèÒªÉèÖÃÑÓ³Ùͳһͬ²½£¬ÆäËû¾ßÌå¸ù¾Ý¹¦ÄÜÐèҪѡÔñÊÇ·ñÑÓ³Ù
|
'''
|
if not setDict or not PlayerControl.GetCrossMapID(curPlayer):
|
return
|
playerID = curPlayer.GetPlayerID()
|
setType = "PlayerDict"
|
msgList = str([playerID, setType, setDict, isDelay])
|
GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, "SetCrossPlayerAttrValue", msgList, len(msgList))
|
GameWorld.DebugLog("¸üпç·þÍæ¼Ò×Öµä: isDelay=%s,%s" % (isDelay, setDict), playerID)
|
return
|
|
def ClientServerMsg_SetPlayerAttrValue(curPlayer, playerSetInfoList):
|
## ÊÕµ½×Ó·þͬ²½µÄÉèÖÿç·þÍæ¼ÒÊôÐÔÖµ
|
playerID = curPlayer.GetPlayerID()
|
GameWorld.DebugLog("ÊÕµ½×Ó·þͬ²½µÄÉèÖÿç·þÍæ¼ÒÊôÐÔÖµ: %s" % playerSetInfoList, playerID)
|
for setType, setDict in playerSetInfoList:
|
if setType == "PlayerDict":
|
for dictKey, valeInfo in setDict.items():
|
if isinstance(valeInfo, int):
|
dictValue, dictType = valeInfo, 0
|
else:
|
dictValue, dictType = valeInfo
|
PlayerControl.NomalDictSetProperty(curPlayer, dictKey, dictValue, dictType)
|
GameWorld.DebugLog(" NomalDictSetProperty dictKey=%s, dictValue=%s, dictType=%s" % (dictKey, dictValue, dictType), playerID)
|
else:
|
for attrName, attrValue in setDict.items():
|
if hasattr(curPlayer, attrName):
|
getattr(curPlayer, attrName)(attrValue)
|
GameWorld.DebugLog(" curPlayer.%s(%s)" % (attrName, attrValue))
|
elif hasattr(PlayerControl, attrName):
|
getattr(PlayerControl, attrName)(curPlayer, attrValue)
|
GameWorld.DebugLog(" PlayerControl.%s(curPlayer, %s)" % (attrName, attrValue), playerID)
|
return
|
|
#// C1 04 Ö÷¶¯Í˳ö¿ç·þ #tagCMExitCrossRealm
|
#
|
#struct tagCMExitCrossRealm
|
#{
|
# tagHead Head;
|
#};
|
def OnExitCrossRealm(index, curPackData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
|
if not GameWorld.IsCrossServer():
|
return
|
|
GameWorld.Log("Íæ¼ÒÖ÷¶¯Í˳ö¿ç·þ", curPlayer.GetPlayerID())
|
|
FBLogic.DoPlayerLeaveFB(curPlayer, tick)
|
|
# À뿪µØÍ¼
|
PlayerAssist.OnPlayerLeaveMap(curPlayer)
|
|
PlayerExitCrossServer(curPlayer)
|
return
|
|
def PlayerExitCrossServer(curPlayer):
|
## Íæ¼ÒÍ˳ö¿ç·þ·þÎñÆ÷
|
|
# ֪ͨ×Ó·þÍæ¼ÒÍ˳ö¿ç·þ·þÎñÆ÷
|
playerID = curPlayer.GetPlayerID()
|
serverGroupID = PlayerControl.GetPlayerServerGroupID(curPlayer)
|
GameWorld.SendMsgToClientServer(ShareDefine.CrossServerMsg_ExitCrossServer, playerID, [serverGroupID])
|
|
# ÉèÖ÷ǿç·þ״̬£¬ÌßÏÂÏß
|
PlayerControl.SetCrossMapID(curPlayer, 0)
|
curPlayer.Kick(IPY_GameWorld.disMapServerClose)
|
GameWorld.Log("PlayerExitCrossServer...", curPlayer.GetPlayerID())
|
return
|
|
def DoEnterCrossRealm(curPlayer):
|
## Íæ¼Ò½øÈë¿ç·þ´¦Àí£¬±¾·þµÄÂß¼´¦Àí
|
PlayerControl.SetPlayerSightLevel(curPlayer, curPlayer.GetID())
|
return
|
|
def DoExitCrossRealm(curPlayer):
|
## Íæ¼ÒÍ˳ö¿ç·þ´¦Àí£¬±¾·þµÄÂß¼´¦Àí
|
GameWorld.Log("DoExitCrossRealm...", curPlayer.GetPlayerID())
|
PlayerControl.SetPlayerSightLevel(curPlayer, 0)
|
if PlayerControl.GetCrossMapID(curPlayer):
|
PlayerControl.SetCrossMapID(curPlayer, 0)
|
return
|
|
def GetPlayerCrossActInfo(curPlayer, actName):
|
## »ñÈ¡¿ç·þÍæ¼Ò¶ÔÓ¦µÄ¿ç·þ»î¶¯ÐÅÏ¢
|
actInfoDict = PyGameData.g_crossActInfoDict.get(actName, {})
|
if not actInfoDict:
|
return {}
|
playerServerID = GameWorld.GetPlayerServerID(curPlayer)
|
for actInfo in actInfoDict.values():
|
if not actInfo.get(ShareDefine.ActKey_State, 0):
|
continue
|
if ShareDefine.ActKey_ServerIDRangeList not in actInfo:
|
continue
|
serverIDRangeList = actInfo[ShareDefine.ActKey_ServerIDRangeList]
|
if not serverIDRangeList:
|
# È«·þ¿ªÆô
|
return actInfo
|
for serverIDA, serverIDB in serverIDRangeList:
|
if serverIDA <= playerServerID <= serverIDB:
|
return actInfo
|
return {}
|
|
def GetCrossActInfoByZoneID(actName, zoneID):
|
## ¸ù¾Ý·ÖÇø»ñÈ¡¿ç·þ¶ÔÓ¦µÄ¿ç·þ»î¶¯ÐÅÏ¢
|
actInfoDict = PyGameData.g_crossActInfoDict.get(actName, {})
|
if not actInfoDict:
|
return {}
|
for actInfo in actInfoDict.values():
|
if not actInfo.get(ShareDefine.ActKey_State, 0):
|
continue
|
ipyDataDict = actInfo.get(ShareDefine.ActKey_IpyDataInfo, {})
|
if zoneID == ipyDataDict.get("ZoneID", 0):
|
return actInfo
|
return {}
|
|
def NotifyCrossActEnd(curPlayer, actName):
|
'''֪ͨ¿ç·þÔËÓª»î¶¯½áÊø
|
·ÀÖ¹¿ç·þ·þÎñÆ÷Óë×Ó·þʱ¼ä²»Ò»Öµ¼Ö¿ÉÄܳöÏֻʵ¼ÊÒѹرÕ
|
µ«ÊÇǰ¶Ë¸ù¾Ý±¾·þ·þÎñÆ÷ʱ¼äÅжϻ¹Î´¹Ø±Õ£¬¿ÉÄÜÒýÆðÍæ¼ÒÎóÒÔΪ»î¶¯Î´¹Ø±Õ¶øÒý·¢µÄһϵÁÐÎÊÌâ
|
ǰ¶Ë¿ç·þ»î¶¯ÏÔÒþ¹æÔò£º
|
ÏÔʾ£º¸ù¾Ý֪ͨµÄ»î¶¯°ü ÇÒ Ê±¼ä>=»î¶¯¿ªÊ¼ÈÕÆÚ ²ÅÏÔʾ
|
¹Ø±Õ£ºÊÕµ½ºó¶Ë֪ͨµÄ»î¶¯½áÊø°ü »ò ʱ¼ä>=»î¶¯½áÊøÈÕÆÚ ÔòÖ±½Ó¹Ø±Õ»î¶¯½çÃæ
|
'''
|
|
clientPack = ChPyNetSendPack.tagGCCrossActEnd()
|
clientPack.ActName = actName
|
clientPack.ActNameLen = len(clientPack.ActName)
|
NetPackCommon.SendFakePack(curPlayer, clientPack)
|
return
|
|