#!/usr/bin/python # -*- coding: GBK -*- #------------------------------------------------------------------------------- # ##@package Player.PlayerActFamilyCTGAssist # # @todo:ÏÉÃ˳äֵЭÖú # @author hxp # @date 2024-06-21 # @version 1.0 # # ÏêϸÃèÊö: ÏÉÃ˳äֵЭÖú # #------------------------------------------------------------------------------- #"""Version = 2024-06-21 19:30""" #------------------------------------------------------------------------------- import PyGameData import ShareDefine import PlayerControl import IpyGameDataPY import ChPyNetSendPack import DataRecordPack import NetPackCommon import ItemControler import IPY_GameWorld import GameWorld import ChConfig import PlayerCoin import FunctionNPCCommon def OnPlayerLogin(curPlayer): for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_FamilyCTGAssist, {}).values(): actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0) isReset = __CheckPlayerFamilyCTGAssistAction(curPlayer, actNum) # »î¶¯ÖÐͬ²½»î¶¯ÐÅÏ¢ if not isReset and actInfo.get(ShareDefine.ActKey_State): Sync_FamilyCTGAssistActionInfo(curPlayer, actNum) Sync_FamilyCTGAssistPlayerInfo(curPlayer, actNum) return def RefreshFamilyCTGAssistActionInfo(actNum): ## ÊÕµ½GameServerͬ²½µÄ»î¶¯ÐÅÏ¢£¬Ë¢Ð»ÐÅÏ¢ playerManager = GameWorld.GetPlayerManager() for index in xrange(playerManager.GetPlayerCount()): curPlayer = playerManager.GetPlayerByIndex(index) if not GameWorld.IsNormalPlayer(curPlayer): continue __CheckPlayerFamilyCTGAssistAction(curPlayer, actNum) return def __CheckPlayerFamilyCTGAssistAction(curPlayer, actNum): ## ¼ì²éÍæ»î¶¯Êý¾ÝÐÅÏ¢ playerID = curPlayer.GetPlayerID() actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_FamilyCTGAssist, actNum) actID = actInfo.get(ShareDefine.ActKey_ID, 0) state = actInfo.get(ShareDefine.ActKey_State, 0) cfgID = actInfo.get(ShareDefine.ActKey_CfgID, 0) #dayIndex = actInfo.get(ShareDefine.ActKey_DayIndex, 0) playerActID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FamilyCTGAssistID % actNum) # Íæ¼ÒÉíÉϵĻID # »î¶¯ID ÏàͬµÄ»°²»´¦Àí if actID == playerActID: GameWorld.DebugLog("ÏÉÃ˳äֵЭÖú»î¶¯ID²»±ä£¬²»´¦Àí£¡ actNum=%s,actID=%s" % (actNum, actID), curPlayer.GetPlayerID()) return GameWorld.DebugLog("ÏÉÃ˳äֵЭÖú»î¶¯ÖØÖÃ! actNum=%s,actID=%s,playerActID=%s,state=%s" % (actNum, actID, playerActID, state), playerID) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FamilyCTGAssistID % actNum, actID) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FamilyCTGAssistAward % actNum, 0) if state: ipyData = IpyGameDataPY.GetIpyGameData("ActFamilyCTGAssist", cfgID) if ipyData: resetCTGIDList = ipyData.GetCTGIDList() PlayerCoin.DoResetCTGCountByIDList(curPlayer, "ActFamilyCTGAssist", resetCTGIDList) shopType = ipyData.GetActShopType() if shopType: FunctionNPCCommon.ResetShopItemBuyCountByShopType(curPlayer, [shopType]) Sync_FamilyCTGAssistActionInfo(curPlayer, actNum) Sync_FamilyCTGAssistPlayerInfo(curPlayer, actNum) return True def OnPlayerCTG(curPlayer, ctgID): if not curPlayer.GetFamilyID(): return actNumList = [] for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_FamilyCTGAssist, {}).values(): actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0) if not actInfo.get(ShareDefine.ActKey_State): continue cfgID = actInfo.get(ShareDefine.ActKey_CfgID, 0) ipyData = IpyGameDataPY.GetIpyGameData("ActFamilyCTGAssist", cfgID) if not ipyData: continue ctgIDList = ipyData.GetCTGIDList() if ctgIDList and ctgID not in ctgIDList: GameWorld.DebugLog("ÏÉÃ˳äֵЭÖú¸Ã³äÖµID²»´¥·¢Ð­Öú! cfgID=%s,actNum=%s,ctgID=%s not in %s" % (cfgID, actNum, ctgID, ctgIDList), curPlayer.GetPlayerID()) continue actNumList.append(actNum) if not actNumList: return SendToGameServer_FamilyCTGAssist(curPlayer, "PlayerCTG", [actNumList]) return def GetFamilyCTGAssistAward(curPlayer, ctgPlayers, actNum): '''»î¶¯Ãâ·Ñ½±Àø @param ctgPlayers: ÒªÁìÈ¡µÄ³äÖµÈËÊý½±Àø @param actNum: »î¶¯±àºÅ£¬Èç11 »ò 12 ´ú±í²»Í¬µÄ»î¶¯ ''' playerID = curPlayer.GetPlayerID() actNum = GameWorld.ToIntDef(actNum, 0) if actNum <= 0: GameWorld.Log("ûÓÐÖ¸¶¨ÁìÈ¡µÄ»î¶¯±àºÅ! actNum=%s" % actNum, playerID) return actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_FamilyCTGAssist, actNum) if not actInfo.get(ShareDefine.ActKey_State): GameWorld.Log("ÏÉÃ˳äֵЭÖú·Ç»î¶¯ÖÐÎÞ·¨ÁìÈ¡½±Àø! actNum=%s" % actNum, playerID) return cfgID = actInfo.get(ShareDefine.ActKey_CfgID) #dayIndex = actInfo.get(ShareDefine.ActKey_DayIndex, 0) ipyData = IpyGameDataPY.GetIpyGameData("ActFamilyCTGAssist", cfgID) if not ipyData: return templateID = ipyData.GetTemplateID() if not templateID: return tempIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActFamilyCTGAssistTemp", templateID) if not tempIpyDataList: return recordIndex = None awardItemList = [] for tempIpyData in tempIpyDataList: if ctgPlayers != tempIpyData.GetNeedCTGPlayers(): continue recordIndex = tempIpyData.GetRecordIndex() awardItemList = tempIpyData.GetAwardItemList() break if recordIndex == None: GameWorld.ErrLog("ÏÉÃ˳äֵЭÖú»î¶¯Ã»Óиý±ÀøÐÅÏ¢! actNum=%s,cfgID=%s,templateID=%s,ctgPlayers=%s" % (actNum, cfgID, templateID, ctgPlayers), playerID) return awardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FamilyCTGAssistAward % actNum) if awardRecord & pow(2, recordIndex): GameWorld.Log("ÏÉÃ˳äֵЭÖú»î¶¯ÒѾ­ÁìÈ¡¹ý¸ÃÃâ·Ñ½±Àø! actNum=%s,cfgID=%s,templateID=%s,ctgPlayers=%s,recordIndex=%s" % (actNum, cfgID, templateID, ctgPlayers, recordIndex), playerID) return # ¼ì²é±³°ü if not ItemControler.CheckPackSpaceEnough(curPlayer, awardItemList): return tick = GameWorld.GetGameWorld().GetTick() if not GameWorld.SetPlayerTickTime(curPlayer, ChConfig.TYPE_Player_Tick_FamilyCTGAssist, tick): GameWorld.DebugLog("ÇëÇóCDÖÐ...", playerID) return SendToGameServer_FamilyCTGAssist(curPlayer, "FamilyCTGAssistAward", [actNum, ctgPlayers, recordIndex, awardItemList]) return def __DoGiveFamilyCTGAssistAward(curPlayer, dataMsg): actNum, ctgPlayers, recordIndex, awardItemList = dataMsg playerID = curPlayer.GetPlayerID() awardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FamilyCTGAssistAward % actNum) if awardRecord & pow(2, recordIndex): GameWorld.DebugLog("·µ»ØÊ±ÏÉÃ˳äֵЭÖú»î¶¯ÒѾ­ÁìÈ¡¹ý¸ÃÃâ·Ñ½±Àø! actNum=%s,ctgPlayers=%s,recordIndex=%s" % (actNum, ctgPlayers, recordIndex), playerID) return awardRecord |= pow(2, recordIndex) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FamilyCTGAssistAward % actNum, awardRecord) Sync_FamilyCTGAssistPlayerInfo(curPlayer, actNum) for itemID, itemCount, isAuctionItem in awardItemList: ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isAuctionItem, [IPY_GameWorld.rptItem]) addDataDict = {"actNum":actNum, "ctgPlayers":ctgPlayers, "recordIndex":recordIndex, "awardItemList":awardItemList} DataRecordPack.DR_FuncGiveItem(curPlayer, "ActFamilyCTGAssist", addDataDict) GameWorld.Log("ÏÉÃ˳äֵЭÖú»î¶¯ÁìÈ¡½±Àø! actNum=%s,ctgPlayers=%s,recordIndex=%s,updAwardRecord=%s,awardItemList=%s" % (actNum, ctgPlayers, recordIndex, awardRecord, awardItemList), playerID) return def SendToGameServer_FamilyCTGAssist(curPlayer, msgType, dataMsg=""): playerID = curPlayer.GetPlayerID() msgList = str([msgType, dataMsg]) GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(playerID, 0, 0, "FamilyCTGAssist", msgList, len(msgList)) GameWorld.Log("ÏÉÃ˳äÖµ»¥Öú·¢ËÍGameServer: %s, %s" % (msgType, dataMsg), playerID) return def GameServer_FamilyCTGAssist(curPlayer, msgData, tick): msgType, dataMsg, ret = msgData if not ret: return if msgType == "FamilyCTGAssistAward": __DoGiveFamilyCTGAssistAward(curPlayer, dataMsg) return def Sync_FamilyCTGAssistPlayerInfo(curPlayer, actNum): ## Í¨ÖªÍæ¼ÒÊý¾ÝÐÅÏ¢ clientPack = ChPyNetSendPack.tagMCActFamilyCTGAssistPlayerInfo() clientPack.ActNum = actNum clientPack.AwardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FamilyCTGAssistAward % actNum) NetPackCommon.SendFakePack(curPlayer, clientPack) return def Sync_FamilyCTGAssistActionInfo(curPlayer, actNum): ## ֪ͨ»î¶¯ÐÅÏ¢ actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_FamilyCTGAssist, actNum) if not actInfo.get(ShareDefine.ActKey_State): return cfgID = actInfo.get(ShareDefine.ActKey_CfgID) #dayIndex = actInfo.get(ShareDefine.ActKey_DayIndex, 0) ipyData = IpyGameDataPY.GetIpyGameData("ActFamilyCTGAssist", cfgID) if not ipyData: return templateID = ipyData.GetTemplateID() if not templateID: return tempIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActFamilyCTGAssistTemp", templateID) if not tempIpyDataList: return startDateStr, endDateStr = GameWorld.GetOperationActionDateStr(ipyData) startDateSync = actInfo.get(ShareDefine.ActKey_StartDateSync, startDateStr) actInfo = ChPyNetSendPack.tagMCActFamilyCTGAssistInfo() actInfo.ActNum = actNum actInfo.StartDate = startDateSync actInfo.EndtDate = endDateStr actInfo.LimitLV = ipyData.GetLVLimit() actInfo.IsDayReset = ipyData.GetIsDayReset() actInfo.AwardInfoList = [] for tempIpyData in tempIpyDataList: award = ChPyNetSendPack.tagMCActFamilyCTGAssistAward() award.NeedCTGPlayers = tempIpyData.GetNeedCTGPlayers() award.RecordIndex = tempIpyData.GetRecordIndex() award.AwardItemList = [] for itemID, itemCount, isAuctionItem in tempIpyData.GetAwardItemList(): item = ChPyNetSendPack.tagMCActFamilyCTGAssistItem() item.ItemID = itemID item.ItemCount = itemCount item.IsBind = isAuctionItem award.AwardItemList.append(item) award.Count = len(award.AwardItemList) actInfo.AwardInfoList.append(award) actInfo.AwardCount = len(actInfo.AwardInfoList) actInfo.CTGIDList = ipyData.GetCTGIDList() actInfo.CTGIDCount = len(actInfo.CTGIDList) actInfo.ShopType = ipyData.GetActShopType() NetPackCommon.SendFakePack(curPlayer, actInfo) return