#!/usr/bin/python # -*- coding: GBK -*- #------------------------------------------------------------------------------- # ##@package Player.PlayerActHeroAppear # # @todo:Î佫µÇ³¡ # @author hxp # @date 2026-02-26 # @version 1.0 # # ÏêϸÃèÊö: Î佫µÇ³¡ # #------------------------------------------------------------------------------- #"""Version = 2026-02-26 16:00""" #------------------------------------------------------------------------------- import PyGameData import ShareDefine import PlayerControl import IpyGameDataPY import PlayerActSign import ChPyNetSendPack import FunctionNPCCommon import PlayerBillboard import PlayerTreasure import NetPackCommon import ItemControler import PlayerHero import PlayerCoin import GameWorld import DBDataMgr import ChConfig def OnActIDChange(actNum, ipyData, state, dbActCfgID): ## »î¶¯ID±ä¸ü if dbActCfgID: __onActEnd(actNum, dbActCfgID) if state: __onActStart(actNum, ipyData) return def OnActInStateRefresh(actNum, ipyData): ## »î¶¯ÖÐˢУ¬Ã¿´Î¶¼ÐèҪˢеÄÂß¼­£¬°üº¬ÖضÁÅäÖÃµÈ if not ipyData: return templateID = ipyData.GetBillTempID() # Ë¢ÐÂÅÅÃû¹æÔò PlayerBillboard.SetOrderRuleListByActTempID(ShareDefine.Def_BT_ActHeroAppear, templateID, groupValue1=actNum) return def __onActStart(actNum, ipyData): ## »î¶¯¿ªÆô billboardMgr = DBDataMgr.GetBillboardMgr() billboardObj = billboardMgr.GetBillboard(ShareDefine.Def_BT_ActHeroAppear, groupValue1=actNum) billboardObj.ClearData() # ÐÂ»î¶¯ÖØÖðñµ¥Êý¾Ý return def __onActEnd(actNum, dbActCfgID): ## »î¶¯½áÊø£¬Ê¹Óà dbActCfgID ´¦Àí½áË㣬֧³Ö½áÊøÇ°Î¬»¤£¬½áÊøºóÆô¶¯µÄÇé¿ö ipyData = IpyGameDataPY.GetIpyGameData("ActHeroAppear", dbActCfgID) if not ipyData: return templateID = ipyData.GetBillTempID() mailKey = ipyData.GetBillAwardMail() funcName = "ActHeroAppear_%s_%s" % (dbActCfgID, actNum) PlayerBillboard.DoGiveBillboardAwardByActTempID(ShareDefine.Def_BT_ActHeroAppear, funcName, templateID, mailKey, groupValue1=actNum, isClearData=True) return ## ------------------------------------------------------------------------------------------------- def OnPlayerLogin(curPlayer): for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_HeroAppear, {}).values(): actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0) isReset = __CheckPlayerActHeroAppearAction(curPlayer, actNum) # »î¶¯ÖÐͬ²½»î¶¯ÐÅÏ¢ if not isReset and actInfo.get(ShareDefine.ActKey_State): Sync_ActHeroAppearActionInfo(curPlayer, actNum) Sync_ActHeroAppearPlayerInfo(curPlayer, actNum) PlayerActSign.Sync_ActSignPlayerInfo(curPlayer, ShareDefine.OperationActionName_HeroAppear, actNum) return def RefreshActHeroAppearActionInfo(actNum): ## ˢл playerManager = GameWorld.GetPlayerManager() for index in xrange(playerManager.GetPlayerCount()): curPlayer = playerManager.GetPlayerByIndex(index) if not GameWorld.IsNormalPlayer(curPlayer): continue __CheckPlayerActHeroAppearAction(curPlayer, actNum) return def __CheckPlayerActHeroAppearAction(curPlayer, actNum): ## ¼ì²éÍæ»î¶¯Êý¾ÝÐÅÏ¢ playerID = curPlayer.GetPlayerID() actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_HeroAppear, 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_ActHeroAppearID % actNum) # Íæ¼ÒÉíÉϵĻID # »î¶¯ID ÏàͬµÄ»°²»´¦Àí if actID == playerActID: GameWorld.DebugLog("Î佫µÇ³¡»î¶¯ID²»±ä£¬²»´¦Àí£¡ actNum=%s,cfgID=%s,actID=%s" % (actNum, cfgID, actID), playerID) return lastCfgID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActHeroAppearCfgID % actNum) GameWorld.DebugLog("Î佫µÇ³¡»î¶¯ÖØÖÃ! actNum=%s,cfgID=%s,actID=%s,playerActID=%s,state=%s,lastCfgID=%s" % (actNum, cfgID, actID, playerActID, state, lastCfgID), playerID) if lastCfgID: __resetActByCfgID(curPlayer, lastCfgID) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActHeroAppearCfgID % actNum, cfgID) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActHeroAppearID % actNum, actID) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActHeroAppearStarIndex % actNum, 0) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActHeroAppearStarAward % actNum, 0) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActHeroAppearCallIndex % actNum, 0) if state: Sync_ActHeroAppearActionInfo(curPlayer, actNum) Sync_ActHeroAppearPlayerInfo(curPlayer, actNum) __resetActByCfgID(curPlayer, cfgID) return True def __resetActByCfgID(curPlayer, cfgID): if not cfgID: return ipyData = IpyGameDataPY.GetIpyGameData("ActHeroAppear", cfgID) if not ipyData: return actNum = ipyData.GetActNum() # Ç©µ½ PlayerActSign.ResetActSign(curPlayer, ShareDefine.OperationActionName_HeroAppear, actNum) # Ѱ±¦ PlayerTreasure.ResetTreasureType(curPlayer, [ipyData.GetActTreasureType()]) # É̵ê shopTypeList = [ipyData.GetGiftShopType(), ipyData.GetExShopType()] FunctionNPCCommon.ResetShopItemBuyCountByShopType(curPlayer, shopTypeList, ipyData.GetExShopRecycleMail()) # ³äÖµ resetCTGIDList = [] resetCTGIDList += ipyData.GetSkinCTGIDList() resetCTGIDList += ipyData.GetGiftCTGIDList() PlayerCoin.DoResetCTGCountByIDList(curPlayer, "ActHeroAppear", resetCTGIDList) return def GetActNumByTreasureType(curPlayer, treasureType): ## ¸ù¾ÝѰ±¦ÀàÐÍ»ñÈ¡»î¶¯ÖеÄÎ佫µÇ³¡actNum # @return: 0-·Ç»î¶¯ÖУ»>0-»î¶¯ÖеÄactNum for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_HeroAppear, {}).values(): if not actInfo.get(ShareDefine.ActKey_State): continue cfgID = actInfo.get(ShareDefine.ActKey_CfgID) ipyData = IpyGameDataPY.GetIpyGameData("ActHeroAppear", cfgID) if not ipyData: continue if treasureType != ipyData.GetActTreasureType(): continue actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0) return actNum return 0 def IsActCanTreasureHero(curPlayer, treasureType, heroID, gridNum): ## ÊÇ·ñ»î¶¯Öпɲú³öµÄÎ佫 actOnlyHeroLibList = IpyGameDataPY.GetFuncEvalCfg("HeroAppear", 1) if gridNum not in actOnlyHeroLibList: #GameWorld.DebugLog("·ÇµÇ³¡Î佫¸ñ×ӵĿÉÖ±½Ó²ú³ö! heroID=%s,gridNum=%s" % (heroID, gridNum)) return True #GameWorld.DebugLog("ÑéÖ¤¿É·ñ²ú³ö»î¶¯Î佫! heroID=%s,gridNum=%s" % (heroID, gridNum)) for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_HeroAppear, {}).values(): if not actInfo.get(ShareDefine.ActKey_State): continue cfgID = actInfo.get(ShareDefine.ActKey_CfgID) ipyData = IpyGameDataPY.GetIpyGameData("ActHeroAppear", cfgID) if not ipyData: continue if treasureType != ipyData.GetActTreasureType(): continue actHeroIDList = ipyData.GetActHeroIDList() actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0) callHeroIndex = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActHeroAppearCallIndex % actNum) if not actHeroIDList or len(actHeroIDList) <= callHeroIndex: return False callHeroID = actHeroIDList[callHeroIndex] if heroID != callHeroID: #GameWorld.DebugLog("·ÇÑ¡ÔñµÄµÇ³¡Î佫£¬²»¿É²ú³ö! heroID=%s != %s,callHeroIndex=%s,%s" % (heroID, callHeroID, callHeroIndex, actHeroIDList)) return False return True return False #// AA 01 Î佫µÇ³¡ÉýÐÇÎ佫ѡÔñ #tagCSActHeroAppearStarHeroSelect # #struct tagCSActHeroAppearStarHeroSelect #{ # tagHead Head; # BYTE ActNum; // »î¶¯±àºÅ # BYTE StarHeroIndex; // ÉýÐǼƻ®Ñ¡ÔñµÄÎ佫IDË÷Òý #}; def OnStarHeroSelect(index, clientData, tick): curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) playerID = curPlayer.GetPlayerID() actNum = clientData.ActNum starHeroIndex = clientData.StarHeroIndex actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_HeroAppear, actNum) if not actInfo or not actInfo.get(ShareDefine.ActKey_State): GameWorld.DebugLog("¸ÃÎ佫µÇ³¡·Ç»î¶¯ÖÐ: actNum=%s" % actNum, playerID) return cfgID = actInfo.get(ShareDefine.ActKey_CfgID) ipyData = IpyGameDataPY.GetIpyGameData("ActHeroAppear", cfgID) if not ipyData: return actHeroIDList = ipyData.GetActHeroIDList() if not actHeroIDList or len(actHeroIDList) <= starHeroIndex: GameWorld.DebugLog("Î佫µÇ³¡ÐǼ¶¼Æ»®Î佫ѡÔñË÷Òý·Ç·¨: actNum=%s,cfgID=%s,starHeroIndex=%s,actHeroIDList=%s" % (actNum, cfgID, starHeroIndex, actHeroIDList), playerID) return starAward = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActHeroAppearStarAward % actNum) if starAward: GameWorld.DebugLog("Î佫µÇ³¡ÐǼ¶¼Æ»®ÒѾ­Áì¹ý½±ÎÞ·¨ÐÞ¸ÄÐǼ¶¼Æ»®Î佫: actNum=%s" % actNum, playerID) return starHeroID = actHeroIDList[starHeroIndex] GameWorld.DebugLog("Î佫µÇ³¡ÐǼ¶¼Æ»®Î佫ÐÞ¸Ä: actNum=%s,cfgID=%s,starHeroIndex=%s,starHeroID=%s,actHeroIDList=%s" % (actNum, cfgID, starHeroIndex, starHeroID, actHeroIDList), playerID) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActHeroAppearStarIndex % actNum, starHeroIndex) Sync_ActHeroAppearPlayerInfo(curPlayer, actNum) return #// AA 02 Î佫µÇ³¡ÕÐļÎ佫ѡÔñ #tagCSActHeroAppearCallHeroSelect # #struct tagCSActHeroAppearCallHeroSelect #{ # tagHead Head; # BYTE ActNum; // »î¶¯±àºÅ # BYTE CallHeroIndex; // ÕÐļѡÔñµÄÎ佫IDË÷Òý #}; def OnCallHeroSelect(index, clientData, tick): curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) playerID = curPlayer.GetPlayerID() actNum = clientData.ActNum callHeroIndex = clientData.CallHeroIndex actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_HeroAppear, actNum) if not actInfo or not actInfo.get(ShareDefine.ActKey_State): GameWorld.DebugLog("¸ÃÎ佫µÇ³¡·Ç»î¶¯ÖÐ: actNum=%s" % actNum, playerID) return cfgID = actInfo.get(ShareDefine.ActKey_CfgID) ipyData = IpyGameDataPY.GetIpyGameData("ActHeroAppear", cfgID) if not ipyData: return actHeroIDList = ipyData.GetActHeroIDList() if not actHeroIDList or len(actHeroIDList) <= callHeroIndex: GameWorld.DebugLog("Î佫µÇ³¡ÕÐļÎ佫ѡÔñË÷Òý·Ç·¨: actNum=%s,cfgID=%s,callHeroIndex=%s,actHeroIDList=%s" % (actNum, cfgID, callHeroIndex, actHeroIDList), playerID) return starHeroID = actHeroIDList[callHeroIndex] GameWorld.DebugLog("Î佫µÇ³¡ÕÐļÎ佫ÐÞ¸Ä: actNum=%s,cfgID=%s,callHeroIndex=%s,starHeroID=%s,actHeroIDList=%s" % (actNum, cfgID, callHeroIndex, starHeroID, actHeroIDList), playerID) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActHeroAppearCallIndex % actNum, callHeroIndex) Sync_ActHeroAppearPlayerInfo(curPlayer, actNum) return def GetHeroAppearStarFreeAward(curPlayer, dataEx): ## ÁìÈ¡ÉýÐǼƻ®Ãâ·Ñ½±Àø actNum = dataEx playerID = curPlayer.GetPlayerID() actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_HeroAppear, actNum) if not actInfo or not actInfo.get(ShareDefine.ActKey_State): GameWorld.DebugLog("¸ÃÎ佫µÇ³¡·Ç»î¶¯ÖÐ: actNum=%s" % actNum) return cfgID = actInfo.get(ShareDefine.ActKey_CfgID) ipyData = IpyGameDataPY.GetIpyGameData("ActHeroAppear", cfgID) if not ipyData: return starGiftTempID = ipyData.GetStarGiftTempID() actHeroIDList = ipyData.GetActHeroIDList() starHeroIndex = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActHeroAppearStarIndex % actNum) if starHeroIndex >= len(actHeroIDList): return starHeroID = actHeroIDList[starHeroIndex] awardIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActHeroAppearStar", starGiftTempID) if not awardIpyDataList: return heroStar = PlayerHero.GetHeroIDStar(curPlayer, starHeroID) awardItemList = [] updStarAward = starAward = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActHeroAppearStarAward % actNum) for awardIpyData in awardIpyDataList: if heroStar < awardIpyData.GetNeedStar(): continue awardIndex = awardIpyData.GetAwardIndex() if starAward&pow(2, awardIndex): continue awardItemList += awardIpyData.GetFreeAwardItemList() updStarAward |= pow(2, awardIndex) GameWorld.DebugLog("Î佫µÇ³¡ÐǼ¶¼Æ»®Ãâ·Ñ½±ÀøÁìÈ¡! actNum=%s,cfgID=%s,starHeroIndex=%s,starHeroID=%s,heroStar=%s,starAward=%s" % (actNum, cfgID, starHeroIndex, starHeroID, heroStar, starAward), playerID) if not awardItemList: GameWorld.DebugLog("ûÓпÉÁìÃâ·Ñ½±Àø!", playerID) return GameWorld.DebugLog("updStarAward=%s,awardItemList=%s" % (updStarAward, awardItemList), playerID) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActHeroAppearStarAward % actNum, updStarAward) ItemControler.GivePlayerItemOrMail(curPlayer, awardItemList, event=["HeroAppearStar", False, {}]) Sync_ActHeroAppearPlayerInfo(curPlayer, actNum) return def GetCTGActItemList(curPlayer, ctgID): ## »î¶¯³äÖµID¶îÍâÎïÆ·Áбí # @return: [[itemID,count], ...] for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_HeroAppear, {}).values(): actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0) if not actInfo.get(ShareDefine.ActKey_State): continue cfgID = actInfo.get(ShareDefine.ActKey_CfgID) ipyData = IpyGameDataPY.GetIpyGameData("ActHeroAppear", cfgID) if not ipyData: continue starGiftTempID = ipyData.GetStarGiftTempID() actHeroIDList = ipyData.GetActHeroIDList() starHeroIndex = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActHeroAppearStarIndex % actNum) if starHeroIndex >= len(actHeroIDList): continue starHeroID = actHeroIDList[starHeroIndex] awardIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActHeroAppearStar", starGiftTempID) if not awardIpyDataList: continue for awardIpyData in awardIpyDataList: if ctgID != awardIpyData.GetStarGiftCTGID(): continue heroGiftItemInfo = awardIpyData.GetHeroGiftItemInfo() if str(starHeroID) not in heroGiftItemInfo: return [] return heroGiftItemInfo[str(starHeroID)] return [] def Sync_ActHeroAppearPlayerInfo(curPlayer, actNum): clientPack = ChPyNetSendPack.tagSCActHeroAppearPlayerInfo() clientPack.ActNum = actNum clientPack.StarHeroIndex = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActHeroAppearStarIndex % actNum) clientPack.StarFreeAward = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActHeroAppearStarAward % actNum) clientPack.CallHeroIndex = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActHeroAppearCallIndex % actNum) NetPackCommon.SendFakePack(curPlayer, clientPack) return def Sync_ActHeroAppearActionInfo(curPlayer, actNum, roundType=0): ## ֪ͨ»î¶¯ÐÅÏ¢ actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_HeroAppear, actNum) if not actInfo or not actInfo.get(ShareDefine.ActKey_State): return cfgID = actInfo.get(ShareDefine.ActKey_CfgID) ipyData = IpyGameDataPY.GetIpyGameData("ActHeroAppear", cfgID) if not ipyData: return startDateStr, endDateStr = GameWorld.GetOperationActionDateStr(ipyData) clientPack = ChPyNetSendPack.tagSCActHeroAppearInfo() clientPack.ActType = ShareDefine.OperationActTypeDict.get(ShareDefine.OperationActionName_HeroAppear, 0) clientPack.ActNum = actNum clientPack.StartDate = startDateStr clientPack.EndtDate = endDateStr clientPack.CfgID = cfgID NetPackCommon.SendFakePack(curPlayer, clientPack) return