#!/usr/bin/python # -*- coding: GBK -*- #------------------------------------------------------------------------------- # ##@package Player.PlayerActYunshi # # @todo:ÔËÊƻ # @author hxp # @date 2024-11-08 # @version 1.0 # # ÏêϸÃèÊö: ÔËÊƻ # #------------------------------------------------------------------------------- #"""Version = 2024-11-08 15:00""" #------------------------------------------------------------------------------- import PyGameData import ShareDefine import PlayerControl import IpyGameDataPY import ChPyNetSendPack import PlayerTreasure import NetPackCommon import GameWorld import ChConfig def OnPlayerLogin(curPlayer): for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_Yunshi, {}).values(): actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0) isReset = __CheckPlayerActYunshiAction(curPlayer, actNum) # »î¶¯ÖÐͬ²½»î¶¯ÐÅÏ¢ if not isReset and actInfo.get(ShareDefine.ActKey_State): Sync_ActYunshiActionInfo(curPlayer, actNum) return def RefreshActYunshiActionInfo(actNum): ## ÊÕµ½GameServerͬ²½µÄ»î¶¯ÐÅÏ¢£¬Ë¢Ð»ÐÅÏ¢ playerManager = GameWorld.GetPlayerManager() for index in xrange(playerManager.GetPlayerCount()): curPlayer = playerManager.GetPlayerByIndex(index) if not GameWorld.IsNormalPlayer(curPlayer): continue __CheckPlayerActYunshiAction(curPlayer, actNum) return def __CheckPlayerActYunshiAction(curPlayer, actNum): ## ¼ì²éÍæ»î¶¯Êý¾ÝÐÅÏ¢ playerID = curPlayer.GetPlayerID() actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_Yunshi, actNum) actID = actInfo.get(ShareDefine.ActKey_ID, 0) state = actInfo.get(ShareDefine.ActKey_State, 0) cfgID = actInfo.get(ShareDefine.ActKey_CfgID) playerActID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActYunshiID % actNum) # Íæ¼ÒÉíÉϵĻID lastTreasureType = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActYunshiTreasureType % actNum) # »î¶¯ID ÏàͬµÄ»°²»´¦Àí if actID == playerActID: GameWorld.DebugLog("ÔËÊƻID²»±ä£¬²»´¦Àí£¡ actNum=%s,cfgID=%s,actID=%s" % (actNum, cfgID, actID), playerID) return GameWorld.DebugLog("ÔËÊƻÖØÖÃ! actNum=%s,cfgID=%s,actID=%s,playerActID=%s,state=%s,lastTreasureType=%s" % (actNum, cfgID, actID, playerActID, state, lastTreasureType), playerID) if lastTreasureType: PlayerTreasure.ResetTreasureType(curPlayer, [lastTreasureType]) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActYunshiID % actNum, actID) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActYunshiTreasureType % actNum, 0) if state: ipyData = IpyGameDataPY.GetIpyGameData("ActYunshi", cfgID) if ipyData: treasureType = ipyData.GetTreasureType() PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActYunshiTreasureType % actNum, treasureType) PlayerTreasure.ResetTreasureType(curPlayer, [treasureType]) Sync_ActYunshiActionInfo(curPlayer, actNum) return True def IsActTreasureType(curPlayer, treasureType): ## ÊÇ·ñ»î¶¯ÖеÄÑ°±¦ÀàÐÍ for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_Yunshi, {}).values(): actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0) if not actInfo.get(ShareDefine.ActKey_State): continue if treasureType == curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActYunshiTreasureType % actNum): return True return False def Sync_ActYunshiActionInfo(curPlayer, actNum): ## ֪ͨ»î¶¯ÐÅÏ¢ actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_Yunshi, actNum) if not actInfo: return if not actInfo.get(ShareDefine.ActKey_State): return cfgID = actInfo.get(ShareDefine.ActKey_CfgID) ipyData = IpyGameDataPY.GetIpyGameData("ActYunshi", cfgID) if not ipyData: return startDateStr, endDateStr = GameWorld.GetOperationActionDateStr(ipyData) actPack = ChPyNetSendPack.tagMCActYunshiInfo() actPack.Clear() actPack.ActNum = actNum actPack.StartDate = startDateStr actPack.EndtDate = endDateStr actPack.ResetType = ipyData.GetResetType() actPack.LimitLV = ipyData.GetLVLimit() actPack.TreasureType = ipyData.GetTreasureType() NetPackCommon.SendFakePack(curPlayer, actPack) return