#!/usr/bin/python # -*- coding: GBK -*- #------------------------------------------------------------------------------- # ##@package GameWorship # # @todo:Ĥ°Ý # @author hxp # @date 2024-07-02 # @version 1.0 # # ÏêϸÃèÊö: Ĥ°Ý # #------------------------------------------------------------------------------- #"""Version = 2024-7-02 16:30""" #------------------------------------------------------------------------------- import ShareDefine import PyDataManager import NetPackCommon import PlayerControl import ChPyNetSendPack import PlayerViewCache import PlayerRecData import CrossRealmMsg import IpyGameDataPY import GameWorld import ChConfig import random import time import json # ±»Ä¤°ÝÍæ¼Ò RecType = ShareDefine.Def_PlayerRecType_WorshipPlayer def GetWorshipType(recData): return recData.GetValue1() # Ĥ°ÝÀàÐÍ def SetWorshipType(recData, worshipType): recData.SetValue1(worshipType) def GetWorshipValue(recData): return recData.GetValue2() # Ĥ°ÝÀàÐÍÏµĹ¦ÄÜÖµ£¬¼´Ä¤°Ýʲô£¬¹¦ÄÜ×Ô¶¨Ò壬ÈçÅÅÃû»òÆäËû£¬¿ÉÑ¡ def SetWorshipValue(recData, worshipValue): recData.SetValue2(worshipValue) def GetWorshipDays(recData): return recData.GetValue3() # ³ÖÐøÌìÊý£º 0ÓÀ¾Ã£¬>0-ÌìÊý def SetWorshipDays(recData, days): recData.SetValue3(days) # Íæ¼ÒÿÈÕĤ°Ý¼Ç¼ RecType = ShareDefine.Def_PlayerRecType_WorshipDaily # ½ñÈÕÒÑĤ°Ý¼Ç¼ {tagPlayerID:[[Ĥ°ÝÀàÐÍ, Ĥ°ÝÖµ], ...], ...} # ½ñÈÕÊÇ·ñÒÑĤ°Ý¹ý¸ÃÍæ¼Òij¸öĤ°Ý def HasWorshipRecordToday(recData, tagPlayerID, worshipType, worshipValue): worshipRecordList = recData.GetUserDataByKey(tagPlayerID, []) if not worshipRecordList: return False return [worshipType, worshipValue] in worshipRecordList # ÉèÖýñÈÕÒÑĤ°Ý¹ý¸ÃÍæ¼Òij¸öĤ°Ý def SetWorshipRecordToday(recData, tagPlayerID, worshipType, worshipValue): worshipRecordList = recData.GetUserDataByKey(tagPlayerID, []) recordInfo = [worshipType, worshipValue] if recordInfo not in worshipRecordList: worshipRecordList.append(recordInfo) recData.SetUserDataByKey(tagPlayerID, worshipRecordList) return ##-------------------------------------------------------------------------------------------------- def OnServerStart(): ## ÐÞ¸ÄÁËĤ°ÝUserDataµÄ´æ´¢ÄÚÈݼ°¸ñʽ£¬ÐèÒª¶ÔÀÏÊý¾Ý½øÐд¦Àí # ÒòΪ»î¶¯ÀàµÄ»î¶¯½áÊøºóÎÞ·¨¸ù¾Ý·ÖÇøIDʶ±ðÊÇ·ñ¿ÉĤ°Ý£¬¹Ê¸ÄΪͬÏɹ¬Ò»ÑùÖ¸¶¨¿ÉĤ°ÝµÄ·þÎñÆ÷IDÁбí isCrossServer = GameWorld.IsCrossServer() crossZoneName = GameWorld.GetCrossZoneName() playerRecMgr = PyDataManager.GetDBPlayerRecDataManager() recDict = playerRecMgr.GetPlayerRecDataDict(ShareDefine.Def_PlayerRecType_WorshipPlayer) for recDataList in recDict.values(): for recData in recDataList: playerID = recData.GetPlayerID() worshipType = GetWorshipType(recData) worshipValue = GetWorshipValue(recData) if isCrossServer: if worshipType != ShareDefine.Def_WorshipType_CrossChampionship: # ¿ç·þ·þÎñÆ÷Ö»ÐÞÕý¿ç·þÅÅλĤ°Ý continue else: if worshipType != ShareDefine.Def_WorshipType_ServerNaming: # ×Ó·þ·þÎñÆ÷Ö»ÐÞÕý·þÎñÆ÷¹ÚÃûĤ°Ý continue userData = recData.GetUserData() try: userDataOld = eval(userData) except: userDataOld = {} if ChConfig.Def_RecDataKey_PlayerInfo in userDataOld: GameWorld.Log("¸ÃĤ°ÝÊý¾ÝÒѾ­±»ÐÞÕý¹ýÁË! worshipType=%s,worshipValue=%s" % (worshipType, worshipValue), playerID) continue recData.SetUserData({}) recData.SetUserDataByKey(ChConfig.Def_RecDataKey_PlayerInfo, userDataOld) if worshipType == ShareDefine.Def_WorshipType_CrossChampionship: zoneID = recData.GetValue4() zoneIpyData = IpyGameDataPY.GetIpyGameData("CrossZonePK", crossZoneName, zoneID) serverIDRangeList = zoneIpyData.GetServerGroupIDList() if zoneIpyData else [] recData.SetUserDataByKey(ChConfig.Def_RecDataKey_ServerIDList, serverIDRangeList) userDataNew = recData.GetUserData() GameWorld.Log("ÐÞÕýĤ°ÝÊý¾Ý! worshipType=%s,worshipValue=%s,userData=%s,userDataNew=%s" % (worshipType, worshipValue, userData, userDataNew), playerID) return def GetPlayerViewInfo(playerID): ## »ñȡĤ°Ý¶ÔÏóµÄÍâ¹ÛÏÔʾÐÅÏ¢ - ±¾·þ¿ç·þͨÓà return PlayerViewCache.GetShotCacheDict(playerID, "AccID", "VIPLV", "FightPower", "Model") def OnPlayerLogin(curPlayer): playerRecMgr = PyDataManager.GetDBPlayerRecDataManager() unWorshipList = [] # δĤ°ÝÁбí recDict = playerRecMgr.GetPlayerRecDataDict(ShareDefine.Def_PlayerRecType_WorshipPlayer) for recDataList in recDict.values(): for recData in recDataList: if not __CheckPlayerCanWorship(curPlayer, recData): continue unWorshipList.append(recData) Sync_UnWorshipInfo(curPlayer, unWorshipList) return def DoOnDay(): ''' ±¾·þÏȹýÌì ÒѹýÆÚµÄ¿ç·þĤ°ÝÒ²»á±»ÏÈɾ³ý£¬Ï൱ÓÚÌύɾ³ý¹ýÆÚµÄ¿ç·þĤ°Ý δ¹ýÆÚµÄ¿ç·þĤ°Ýµ±¿ç·þ·þÎñÆ÷¹ýÌìʱͬÑùÒ²ÊÇδ¹ýÆÚ£¬¹ÊÒ²¿ÉÕý³£Ä¤°Ý£¬Ã¿ÌìµÄĤ°Ý¼Ç¼ÊÇ´æÔÚ±¾·þÍæ¼Ò£¬Ï൱ÓÚÌáǰĤ°Ý ¿ç·þÏȹýÌì ÒѹýÆÚµÄ¿ç·þĤ°Ý»á±»É¾³ý£¬È»ºóͬ²½¸ø×Ó·þÏÈͬ²½É¾³ýµô¼´¿É δ¹ýÆÚµÄ¿ç·þĤ°Ý²»´¦Àí¼´¿É ËùÒÔ£¬¹ýÌìʱ£¬±¾·þ¼°¿ç·þ¸÷×Ô´¦Àí¸÷×ÔµÄÂß¼­¼´¿É ''' isCrossServer = GameWorld.IsCrossServer() playerRecMgr = PyDataManager.GetDBPlayerRecDataManager() worshipList = [] curTime = int(time.time()) recDict = playerRecMgr.GetPlayerRecDataDict(ShareDefine.Def_PlayerRecType_WorshipPlayer) for recDataList in recDict.values(): for recData in recDataList[::-1]: # µ¹Ðò´¦Àíɾ³ýµ½ÆÚµÄĤ°Ý¶ÔÏó recTime = recData.GetTime() tagPlayerID = recData.GetPlayerID() worshipType = GetWorshipType(recData) worshipValue = GetWorshipValue(recData) worshipDays = GetWorshipDays(recData) if not worshipDays: # ÓÀ¾ÃĤ°Ý²»´¦Àí£¬Ö±µ½±»Ìæ»» GameWorld.DebugLog("ÓÀ¾ÃĤ°Ý²»´¦Àí: worshipType=%s,worshipValue=%s,tagPlayerID=%s" % (worshipType, worshipValue, tagPlayerID)) __UpdWorshipByDay(isCrossServer, worshipList, recData) continue diffDays = GameWorld.GetDiff_Day(curTime, recTime) if diffDays < worshipDays: GameWorld.DebugLog("Ĥ°Ýδµ½ÆÚ: worshipType=%s,worshipValue=%s,tagPlayerID=%s,diffDays=%s < %s" % (worshipType, worshipValue, tagPlayerID, diffDays, worshipDays)) __UpdWorshipByDay(isCrossServer, worshipList, recData) continue GameWorld.DebugLog("ɾ³ýĤ°Ý: worshipType=%s,worshipValue=%s,tagPlayerID=%s" % (worshipType, worshipValue, tagPlayerID)) playerRecMgr.DelRecData(recData) if isCrossServer: # ͬ²½¸ø×Ó·þ dataMsg = {"msgType":"AllCrossWorship", "worshipDataList":worshipList} CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_Worship, dataMsg) return # ±¾·þ´¦Àí playerRecMgr.DelRecDataByType(ShareDefine.Def_PlayerRecType_WorshipDaily) # ɾ³ý±¾·þËùÓÐÍæ¼ÒµÄÿÈÕĤ°Ý¼Ç¼ Sync_UnWorshipInfo(None, worshipList) return def __UpdWorshipByDay(isCrossServer, worshipList, recData): ## ¹ýÌì¸üÐÂδ¹ýÆÚĤ°ÝÐÅÏ¢ playerID = recData.GetPlayerID() playerInfo = GetPlayerViewInfo(playerID) if playerInfo: recData.SetUserDataByKey(ChConfig.Def_RecDataKey_PlayerInfo, playerInfo) if isCrossServer: worshipList.append(recData.GetString()) else: worshipList.append(recData) return def IsWorshipPlayer(playerID): ## ÊÇ·ñĤ°ÝÍæ¼Ò playerRecMgr = PyDataManager.GetDBPlayerRecDataManager() if playerRecMgr.GetPlayerRecDataList(ShareDefine.Def_PlayerRecType_WorshipPlayer, playerID): return True return False def AddWorshipPlayer(worshipType, worshipValue, playerID, serverIDList, syncList=None, days=None): ## Ìí¼ÓĤ°ÝÍæ¼Ò£¬±¾·þ¿ç·þͨÓà if worshipType in ShareDefine.Def_WorshipTypeCross: if not GameWorld.IsCrossServer(): GameWorld.ErrLog("·Ç¿ç·þ·þÎñÆ÷²»ÔÊÐíÌí¼Ó¿ç·þĤ°Ý! worshipType=%s" % (worshipType)) return else: if GameWorld.IsCrossServer(): GameWorld.ErrLog("¿ç·þ·þÎñÆ÷²»ÔÊÐíÌí¼Ó·Ç¿ç·þĤ°Ý! worshipType=%s" % (worshipType)) return ipyData = IpyGameDataPY.GetIpyGameDataNotLog("Worship", worshipType, worshipValue) if not ipyData: return if days == None: days = ipyData.GetWorshipDays() # ûÓÐÖ¸¶¨ÌìÊýµÄ»°È¡Åä±í playerRecMgr = PyDataManager.GetDBPlayerRecDataManager() recData = playerRecMgr.GetPlayerRecData(ShareDefine.Def_PlayerRecType_WorshipPlayer, playerID, [worshipType, worshipValue]) if not recData: GameWorld.Log("Ìí¼ÓĤ°ÝÊý¾Ý: playerID=%s,worshipType=%s,worshipValue=%s,days=%s,%s" % (playerID, worshipType, worshipValue, days, serverIDList)) recData = playerRecMgr.AddPlayerRecData(ShareDefine.Def_PlayerRecType_WorshipPlayer, playerID) else: GameWorld.Log("¸üÐÂĤ°ÝÊý¾Ý: playerID=%s,worshipType=%s,worshipValue=%s,days=%s,%s" % (playerID, worshipType, worshipValue, days, serverIDList)) recData.SetTime(int(time.time())) SetWorshipType(recData, worshipType) SetWorshipValue(recData, worshipValue) SetWorshipDays(recData, days) playerInfo = GetPlayerViewInfo(playerID) serverID = GameWorld.GetAccIDServerID(playerInfo.get("AccID", "")) saveServerIDList = [] + serverIDList # ÖØÐ´´½¨Ò»·Ý´æ´¢£¬²»¸Ä±ä´«ÈëÖµ # È·±£Íæ¼Ò×ÔÉíÒ»¶¨ÄÜ¿´µ½×Ô¼º£¬¿ç·þÅÅλÈüÀúÊ··ÖÇøÎÊÌâ if saveServerIDList and serverID and not GameWorld.CheckServerIDInList(serverID, saveServerIDList): saveServerIDList.append(serverID) recData.SetUserDataByKey(ChConfig.Def_RecDataKey_ServerIDList, saveServerIDList) # ±£´æµ±ÏµÄÇø·þID·¶Î§ recData.SetUserDataByKey(ChConfig.Def_RecDataKey_PlayerInfo, playerInfo) # ±£´æµ±ÏµÄÍæ¼Ò»ù±¾ÐÅÏ¢ if isinstance(syncList, list): syncList.append(recData) else: SendNewWorshipPlayer([recData]) return recData def SendNewWorshipPlayer(syncList): ## ͬ²½ÐÂĤ°ÝÊý¾Ý if not syncList: return if GameWorld.IsCrossServer(): SyncAddCrossWorship(syncList) else: Sync_UnWorshipInfo(None, syncList) return def DelWorshipPlayer(worshipType, worshipValue=None, delPlayerID=None): ## ɾ³ýĤ°ÝÍæ¼Ò£¬±¾·þ¿ç·þͨÓà valueList = [worshipType] if worshipValue != None: valueList.append(worshipValue) playerRecMgr = PyDataManager.GetDBPlayerRecDataManager() playerRecMgr.DelRecDataByTypeValue(ShareDefine.Def_PlayerRecType_WorshipPlayer, valueList, delPlayerID) if GameWorld.IsCrossServer(): dataMsg = {"msgType":"DelCrossWorship", "worshipType":worshipType, "worshipValue":worshipValue, "delPlayerID":delPlayerID} CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_Worship, dataMsg) return #// B0 20 ÇëÇóĤ°ÝÍæ¼Ò #tagCGWorship # #struct tagCGWorship #{ # tagHead Head; # DWORD PlayerID; // Ä¿±êÍæ¼ÒID # BYTE WorshipType; // Ĥ°ÝÀàÐÍ # DWORD WorshipValue; // Ĥ°ÝÀàÐͶÔÓ¦µÄ¹¦ÄÜÖµ£¬ÈçÃû´Î»òÆäËû£¬ÓɾßÌåĤ°ÝÀàÐͶ¨Òå¶ÔÓ¦Öµº¬Òå #}; def OnWorship(index, clientData, tick): curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) playerID = curPlayer.GetPlayerID() tagPlayerID = clientData.PlayerID worshipType = clientData.WorshipType worshipValue = clientData.WorshipValue ipyData = IpyGameDataPY.GetIpyGameData("Worship", worshipType, worshipValue) if not ipyData: __SyncWorshipResult(curPlayer, tagPlayerID, worshipType, worshipValue, 1) return findWorshipData = None playerRecMgr = PyDataManager.GetDBPlayerRecDataManager() recDataList = playerRecMgr.GetPlayerRecDataList(ShareDefine.Def_PlayerRecType_WorshipPlayer, tagPlayerID) for recData in recDataList: if worshipType == GetWorshipType(recData) and worshipValue == GetWorshipValue(recData): findWorshipData = recData break if not findWorshipData: __SyncWorshipResult(curPlayer, tagPlayerID, worshipType, worshipValue, 2) GameWorld.DebugLog("²»´æÔÚ¸ÃÄ¿±êÍæ¼ÒµÄĤ°Ý! tagPlayerID=%s,worshipType=%s,worshipValue=%s" % (tagPlayerID, worshipType, worshipValue), playerID) return if not __CheckPlayerCanWorship(curPlayer, recData): __SyncWorshipResult(curPlayer, tagPlayerID, worshipType, worshipValue, 3) return moneyType = ipyData.GetMoneyType() moneyRange = ipyData.GetMoneyRange() if len(moneyRange) != 2: return moneyValue = random.randint(moneyRange[0], moneyRange[1]) GameWorld.DebugLog("Ĥ°Ý: tagPlayerID=%s,worshipType=%s,worshipValue=%s,moneyType=%s,moneyValue=%s" % (tagPlayerID, worshipType, worshipValue, moneyType, moneyValue), playerID) playerRecMgr = PyDataManager.GetDBPlayerRecDataManager() worshipRecData = playerRecMgr.GetPlayerRecDataFirst(ShareDefine.Def_PlayerRecType_WorshipDaily, playerID) SetWorshipRecordToday(worshipRecData, tagPlayerID, worshipType, worshipValue) __SyncWorshipResult(curPlayer, tagPlayerID, worshipType, worshipValue, 0, moneyType, moneyValue) # ͬ²½µØÍ¼·¢·Å»õ±Ò PlayerControl.MapServerGiveAward(curPlayer, "Worship", {moneyType:moneyValue}) return def __CheckPlayerCanWorship(curPlayer, recData): ## ¼ì²éÍæ¼ÒÊÇ·ñ¿ÉĤ°Ý¸Ã¶ÔÏó playerID = curPlayer.GetPlayerID() recPlayerID = recData.GetPlayerID() playerInfo = recData.GetUserDataByKey(ChConfig.Def_RecDataKey_PlayerInfo, {}) if not playerInfo: GameWorld.DebugLog("ûÓÐÍâ¹ÛչʾµÄ²»Í¬²½! recPlayerID=%s" % recPlayerID, playerID) return accID = playerInfo.get("AccID", "") if not accID: return serverID = GameWorld.GetAccIDServerID(accID) playerServerID = GameWorld.GetPlayerServerID(curPlayer) worshipType = GetWorshipType(recData) worshipValue = GetWorshipValue(recData) if worshipType == ShareDefine.Def_WorshipType_ServerNaming: #ֻͬ²½¸øÍ¬ServerIDµÄ if serverID != playerServerID: GameWorld.DebugLog("ֻͬ²½¸øÍ¬ServerIDµÄ! recPlayerID=%s,accID=%s,serverID=%s != playerServerID=%s" % (recPlayerID, accID, serverID, playerServerID), playerID) return else: serverIDList = recData.GetUserDataByKey(ChConfig.Def_RecDataKey_ServerIDList) if not GameWorld.CheckServerIDInList(playerServerID, serverIDList): GameWorld.DebugLog("¸ÃÍæ¼Ò²»ÄÜĤ°ÝÄ¿±êÍæ¼Ò! playerServerID=%s not in %s" % (playerServerID, serverIDList), playerID) return playerRecMgr = PyDataManager.GetDBPlayerRecDataManager() worshipRecData = playerRecMgr.GetPlayerRecDataFirst(ShareDefine.Def_PlayerRecType_WorshipDaily, playerID) if HasWorshipRecordToday(worshipRecData, recPlayerID, worshipType, worshipValue): GameWorld.DebugLog("½ñÈÕÒÑĤ°Ý¹ý! recPlayerID=%s,worshipType=%s, worshipValue=%s" % (recPlayerID, worshipType, worshipValue), playerID) return return True def __SyncWorshipResult(curPlayer, tagPlayerID, worshipType, worshipValue, result, moneyType=0, moneyValue=0): ## ͬ²½Ä¤°Ý½á¹û # @param result: Ĥ°Ý½á¹û£º0-³É¹¦£»1-²»´æÔÚ¸ÃĤ°Ý£»2-²»ÄÜĤ°ÝÄ¿±ê clientPack = ChPyNetSendPack.tagGCWorshipResult() clientPack.PlayerID = tagPlayerID clientPack.WorshipType = worshipType clientPack.WorshipValue = worshipValue clientPack.Result = result clientPack.MoneyType = moneyType clientPack.MoneyValue = moneyValue NetPackCommon.SendFakePack(curPlayer, clientPack) return def CrossServerMsg_Worship(msgData): ## ×Ó·þÊÕµ½¿ç·þÐÅÏ¢ msgType = msgData["msgType"] if msgType == "AddCrossWorship": __Client_AddCrossWorship(msgData) elif msgType == "AllCrossWorship": __Client_AllCrossWorship(msgData) elif msgType == "DelCrossWorship": __Client_DelCrossWorship(msgData) return def __Client_AllCrossWorship(msgData): ## ×Ó·þ¸üÐÂËùÓпç·þĤ°Ý worshipDataList = msgData["worshipDataList"] GameWorld.Log("×Ó·þ¸üÐÂËùÓпç·þĤ°Ý: count=%s" % len(worshipDataList)) playerRecMgr = PyDataManager.GetDBPlayerRecDataManager() for crossWorshipType in ShareDefine.Def_WorshipTypeCross: playerRecMgr.DelRecDataByTypeValue(ShareDefine.Def_PlayerRecType_WorshipPlayer, [crossWorshipType]) sysnList = [] for attrDict in worshipDataList: recData = playerRecMgr.AddPlayerRecDataByDict(attrDict) playerID = recData.GetPlayerID() # Èç¹û´æÔÚ±¾·þµÄ×îÐÂÍâ¹ÛÊý¾ÝÔòÒѱ¾·þµÄΪ׼ playerInfo = GetPlayerViewInfo(playerID) if playerInfo: recData.SetUserDataByKey(ChConfig.Def_RecDataKey_PlayerInfo, playerInfo) sysnList.append(recData) serverIDList = recData.GetUserDataByKey(ChConfig.Def_RecDataKey_ServerIDList) GameWorld.Log(" ¸üпç·þĤ°Ý: worshipType=%s,worshipValue=%s,playerID=%s,days=%s,%s" % (GetWorshipType(recData), GetWorshipValue(recData), playerID, GetWorshipDays(recData), serverIDList)) #¸üÐÂÊý¾ÝµÄ¿É²»Í¬²½£¬Ã¿¸öÈ˵ÄĤ°Ý¼Ç¼¶¼²»Ò»Ñù£¬ÓɵǼ´¥·¢¼°Ìí¼ÓÐÂĤ°Ý´¥·¢¼´¿É #Sync_UnWorshipInfo(None, sysnList) return def __Client_AddCrossWorship(msgData): ## ×Ó·þÌí¼Ó¿ç·þĤ°Ý worshipDataList = msgData["worshipDataList"] GameWorld.Log("×Ó·þÌí¼Ó¿ç·þĤ°Ý: addCount=%s" % len(worshipDataList)) playerRecMgr = PyDataManager.GetDBPlayerRecDataManager() tempData = PlayerRecData.PlayerRecDataTemp sysnList = [] for attrDict in worshipDataList: tempData.SetAttr(attrDict, True) playerID = tempData.GetPlayerID() worshipType = GetWorshipType(tempData) worshipValue = GetWorshipValue(tempData) if not playerID or not worshipType: continue # Èç¹ûÒѾ­´æÔÚ¸ÃĤ°ÝÔòÖ±½Ó¸üÐÂÊý¾Ý£¬·ñÔòÌí¼ÓÐÂÊý¾Ý recData = playerRecMgr.GetPlayerRecData(ShareDefine.Def_PlayerRecType_WorshipPlayer, playerID, [worshipType, worshipValue]) if recData: recData.SetAttr(attrDict, True) else: recData = playerRecMgr.AddPlayerRecDataByDict(attrDict) sysnList.append(recData) serverIDList = recData.GetUserDataByKey(ChConfig.Def_RecDataKey_ServerIDList) GameWorld.Log(" Ìí¼Ó¿ç·þĤ°Ý: worshipType=%s,worshipValue=%s,playerID=%s,days=%s,%s" % (GetWorshipType(recData), GetWorshipValue(recData), playerID, GetWorshipDays(recData), serverIDList)) Sync_UnWorshipInfo(None, sysnList) return def __Client_DelCrossWorship(msgData): ## ×Ó·þɾ³ý¿ç·þĤ°Ý worshipType = msgData["worshipType"] worshipValue = msgData["worshipValue"] delPlayerID = msgData["delPlayerID"] GameWorld.Log("×Ó·þɾ³ý¿ç·þĤ°Ý: worshipType=%s,worshipValue=%s,delPlayerID=%s" % (worshipType, worshipValue, delPlayerID)) DelWorshipPlayer(worshipType, worshipValue, delPlayerID) return def Sync_UnWorshipInfo(curPlayer, unWorshipList): ## curPlayer ¿ÉÄÜΪNone if not unWorshipList: return infoList = [] for recData in unWorshipList: recPlayerID = recData.GetPlayerID() playerInfo = GetPlayerViewInfo(recPlayerID) if playerInfo: # ¸üб¾·þ×îеÄÍâ¹ÛÏÔʾ£¬¿ç·þÍæ¼ÒÓÉ¿ç·þÿÈÕͬ²½¸üР__UpdWorshipByDay recData.SetUserDataByKey(ChConfig.Def_RecDataKey_PlayerInfo, playerInfo) else: playerInfo = recData.GetUserDataByKey(ChConfig.Def_RecDataKey_PlayerInfo) if not playerInfo: # ûÓÐÍâ¹ÛչʾµÄ²»Í¬²½ continue if curPlayer: if not __CheckPlayerCanWorship(curPlayer, recData): continue infoPack = ChPyNetSendPack.tagGCWorshipInfo() infoPack.PlayerID = recPlayerID infoPack.WorshipType = GetWorshipType(recData) infoPack.WorshipValue = GetWorshipValue(recData) infoPack.PlayerInfo = json.dumps(playerInfo, ensure_ascii=False).replace(" ", "") infoPack.InfoLen = len(infoPack.PlayerInfo) if curPlayer: infoList.append(infoPack) else: infoList.append([recData, infoPack]) if not infoList: return clientPack = ChPyNetSendPack.tagGCWorshipInfoList() if not curPlayer: # È«·þ¹ã²¥ÔÚÏßÍæ¼Ò£¬Ã¿¸öÈËͬ²½µÄ¿ÉÄܲ»Ò»Ñù playerManager = GameWorld.GetPlayerManager() for i in range(0, playerManager.GetPlayerCount()): curPlayer = playerManager.GetPlayerByIndex(i) if curPlayer == None or not curPlayer.GetInitOK(): continue clientPack.WorshipInfoList = [] for info in infoList: recData, infoPack = info if not __CheckPlayerCanWorship(curPlayer, recData): continue clientPack.WorshipInfoList.append(infoPack) if not clientPack.WorshipInfoList: continue clientPack.WorshipCount = len(clientPack.WorshipInfoList) NetPackCommon.SendFakePack(curPlayer, clientPack) else: clientPack.WorshipInfoList = infoList clientPack.WorshipCount = len(clientPack.WorshipInfoList) NetPackCommon.SendFakePack(curPlayer, clientPack) return ##-------------------------------------------------------------------------------------------------- def Sync_CrossWorshipToClientServer(serverGroupID=0): ''' ͬ²½¿ç·þĤ°ÝÊý¾Ýµ½×Ó·þÎñÆ÷ @param serverGroupID: Ϊ0ʱͬ²½ËùÓÐ×Ó·þ ''' GameWorld.Log("ͬ²½¸ø×Ó·þĤ°ÝÊý¾Ý: syncServerGroupID=%s" % (serverGroupID)) playerRecMgr = PyDataManager.GetDBPlayerRecDataManager() recDataDict = playerRecMgr.GetPlayerRecDataDict(ShareDefine.Def_PlayerRecType_WorshipPlayer) worshipDataList = [] for recDataList in recDataDict.values(): for recData in recDataList: if not recData: continue if GetWorshipType(recData) not in ShareDefine.Def_WorshipTypeCross: continue worshipDataList.append(recData.GetString()) dataMsg = {"msgType":"AllCrossWorship", "worshipDataList":worshipDataList} CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_Worship, dataMsg) return def SyncAddCrossWorship(addRecDataList): # ͬ²½×Ó·þ worshipDataList = [] for recData in addRecDataList: if not recData: continue worshipDataList.append(recData.GetString()) if not worshipDataList: return dataMsg = {"msgType":"AddCrossWorship", "worshipDataList":worshipDataList} CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_Worship, dataMsg) return