From 5c27c43c293460a98a1374504c07533ddf17d24f Mon Sep 17 00:00:00 2001 From: xdh <xiefantasy@qq.com> Date: 星期一, 03 六月 2019 19:32:21 +0800 Subject: [PATCH] 7067 【2.0】【后端】丹炉新增批量炼丹 --- ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/CrossRealmPlayer.py | 96 ++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 80 insertions(+), 16 deletions(-) diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/CrossRealmPlayer.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/CrossRealmPlayer.py index 11a0900..8eca865 100644 --- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/CrossRealmPlayer.py +++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/CrossRealmPlayer.py @@ -17,6 +17,7 @@ import GameWorld import ReadChConfig import PlayerControl +import IpyGameDataPY import IPY_GameWorld import ShareDefine import ChConfig @@ -35,9 +36,83 @@ return opName.decode('gbk').encode(GameWorld.GetCharacterEncoding()) + playerName +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 # @@ -65,31 +140,20 @@ GameWorld.SendMsgToClientServer(ShareDefine.CrossServerMsg_ExitCrossServer, playerID, [serverGroupID]) # 设置非跨服状态,踢下线 - PlayerControl.SetCrossRealmState(curPlayer, 0) + PlayerControl.SetCrossMapID(curPlayer, 0) curPlayer.Kick(IPY_GameWorld.disMapServerClose) GameWorld.Log("PlayerExitCrossServer...", curPlayer.GetPlayerID()) return def DoEnterCrossRealm(curPlayer): ## 玩家进入跨服处理,本服的逻辑处理 - curPlayer.SetVisible(False) - curPlayer.SetSight(0) - curPet = curPlayer.GetPetMgr().GetFightPet() - if curPet: - curPet.SetVisible(False) + PlayerControl.SetPlayerSightLevel(curPlayer, curPlayer.GetID()) return def DoExitCrossRealm(curPlayer): ## 玩家退出跨服处理,本服的逻辑处理 GameWorld.Log("DoExitCrossRealm...", curPlayer.GetPlayerID()) - curPlayer.SetVisible(True) - curPlayer.SetSight(1) - curPlayer.RefreshView() - curPlayer.SetSight(ChConfig.Def_PlayerSight_Default) - curPlayer.RefreshView() - curPet = curPlayer.GetPetMgr().GetFightPet() - if curPet: - curPet.SetVisible(True) - if PlayerControl.GetCrossRealmState(curPlayer): - PlayerControl.SetCrossRealmState(curPlayer, 0) + PlayerControl.SetPlayerSightLevel(curPlayer, 0) + if PlayerControl.GetCrossMapID(curPlayer): + PlayerControl.SetCrossMapID(curPlayer, 0) return -- Gitblit v1.8.0