#!/usr/bin/python # -*- coding: GBK -*- #------------------------------------------------------------------------------- # ##@package Player.PlayerActLoginNew # # @todo:µÇ¼»î¶¯-Р# @author hxp # @date 2024-06-03 # @version 1.0 # # ÏêϸÃèÊö: µÇ¼»î¶¯-Р# #------------------------------------------------------------------------------- #"""Version = 2024-06-03 18:00""" #------------------------------------------------------------------------------- import PyGameData import PlayerCoin import ShareDefine import PlayerControl import IpyGameDataPY import PlayerZhanling import ChPyNetSendPack import ItemControler import IPY_GameWorld import NetPackCommon import GameWorld import ChConfig import time def OnPlayerLogin(curPlayer): for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_ActLoginNew, {}).values(): actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0) isReset = __CheckPlayerActLoginAction(curPlayer, actNum) # »î¶¯ÖÐͬ²½»î¶¯ÐÅÏ¢ if not isReset and actInfo.get(ShareDefine.ActKey_State) and curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActLoginNewID % actNum): Sync_ActLoginActionInfo(curPlayer, actNum) Sync_ActLoginPlayerInfo(curPlayer, actNum) return def OnDay(curPlayer): OnCheckRelateFuncAct(curPlayer) return def OnCheckRelateFuncAct(curPlayer, openFuncIDList=None): ## ¼ì²é¹ØÁª¹¦ÄÜID¿ªÆôµÄ»î¶¯ for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_ActLoginNew, {}).values(): if not actInfo.get(ShareDefine.ActKey_State): continue cfgID = actInfo.get(ShareDefine.ActKey_CfgID) ipyData = IpyGameDataPY.GetIpyGameData("ActLoginNew", cfgID) if not ipyData: continue if not hasattr(ipyData, "GetRelateFuncID"): continue relateFuncID = ipyData.GetRelateFuncID() if not relateFuncID: continue if openFuncIDList and relateFuncID not in openFuncIDList: continue actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0) __CheckPlayerActLoginAction(curPlayer, actNum) return def RefreshActLoginActionInfo(actNum): ## ÊÕµ½GameServerͬ²½µÄ»î¶¯ÐÅÏ¢£¬Ë¢Ð»ÐÅÏ¢ playerManager = GameWorld.GetPlayerManager() for index in xrange(playerManager.GetPlayerCount()): curPlayer = playerManager.GetPlayerByIndex(index) if not GameWorld.IsNormalPlayer(curPlayer): continue __CheckPlayerActLoginAction(curPlayer, actNum) return def __CheckPlayerActLoginAction(curPlayer, actNum): ## ¼ì²éÍæ»î¶¯Êý¾ÝÐÅÏ¢ playerID = curPlayer.GetPlayerID() actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_ActLoginNew, actNum) actID = actInfo.get(ShareDefine.ActKey_ID, 0) state = actInfo.get(ShareDefine.ActKey_State, 0) playerActID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActLoginNewID % actNum) # Íæ¼ÒÉíÉϵĻID funcActInfo = GameWorld.GetActRelateFuncInfo(curPlayer, "ActLoginNew", actInfo, playerActID) if funcActInfo: isInAct, actID = funcActInfo if not isInAct: return # »î¶¯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_ActLoginNewID % actNum, actID) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActLoginNewAward % actNum, 0) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActLoginNewAwardEx % actNum, 0) if state: cfgID = actInfo.get(ShareDefine.ActKey_CfgID) ipyData = IpyGameDataPY.GetIpyGameData("ActLoginNew", cfgID) if ipyData: if ipyData.GetAwardExCTGID(): PlayerCoin.DoResetCTGCountByIDList(curPlayer, "ActLoginNew", [ipyData.GetAwardExCTGID()]) if ipyData.GetActZhanlingType(): PlayerZhanling.ResetZhanling(curPlayer, ipyData.GetActZhanlingType()) Sync_ActLoginActionInfo(curPlayer, actNum) Sync_ActLoginPlayerInfo(curPlayer, actNum) return True def OnGetActLoginAward(curPlayer, dayNum, actNum): ## ÁìÈ¡»î¶¯½±Àø isAwardEx = dayNum / 1000 dayNum = dayNum % 1000 actNum = GameWorld.ToIntDef(actNum) actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_ActLoginNew, actNum) if not actInfo: GameWorld.DebugLog("ûÓиõǼ»î¶¯£¡ actNum=%s" % actNum) return if not actInfo.get(ShareDefine.ActKey_State): GameWorld.DebugLog("·ÇµÇ¼»î¶¯ÖУ¡ actNum=%s" % actNum) return playerActID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActLoginNewID % actNum) if not playerActID: return curDayNum = GameWorld.GetDiff_Day(int(time.time()), playerActID) + 1 if curDayNum < dayNum: GameWorld.DebugLog("δµ½¿ÉÁìÈ¡µÄµÇ¼Ì죬ÎÞ·¨ÁìÈ¡£¡ actNum=%s,curDayNum=%s < %s" % (actNum, curDayNum, dayNum)) return cfgID = actInfo.get(ShareDefine.ActKey_CfgID) ipyData = IpyGameDataPY.GetIpyGameData("ActLoginNew", cfgID) if not ipyData: return templateID = ipyData.GetTemplateID() dayIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActLoginNewAward", templateID) if not dayIpyDataList: return findIpyData = None for dayIpyData in dayIpyDataList: if dayIpyData.GetDayNum() == dayNum: findIpyData = dayIpyData break if not findIpyData: GameWorld.DebugLog("ÕÒ²»µ½¶ÔÓ¦µÇ¼Ìì½±Àø! actNum=%s,cfgID=%s,templateID=%s,dayNum=%s" % (actNum, cfgID, templateID, dayNum)) return if isAwardEx: awardExCTGID = ipyData.GetAwardExCTGID() if not awardExCTGID: GameWorld.DebugLog("¸ÃµÇ¼»î¶¯Ã»ÓÐÀ©Õ¹½±Àø! actNum=%s,cfgID=%s" % (actNum, cfgID)) return if not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CTGGoodsBuyCount % awardExCTGID): GameWorld.DebugLog("¸ÃµÇ¼»î¶¯À©Õ¹½±ÀøÀñ°üδ¹ºÂò£¬ÎÞ·¨ÁìÈ¡! actNum=%s,cfgID=%s,awardExCTGID=%s" % (actNum, cfgID, awardExCTGID)) return stateKey = ChConfig.Def_PDict_ActLoginNewAwardEx awardItemList = findIpyData.GetLoginAwardItemListEx() else: stateKey = ChConfig.Def_PDict_ActLoginNewAward awardItemList = findIpyData.GetLoginAwardItemList() if not awardItemList: return awardRecord = curPlayer.NomalDictGetProperty(stateKey % actNum) if awardRecord & pow(2, dayNum): GameWorld.DebugLog("µÇ¼»î¶¯¸ÃÌìÒÑÁì½±£¡ actNum=%s,dayNum=%s,awardRecord=%s" % (actNum, dayNum, awardRecord)) return # ÅжϷǵ±ÌìÐ貹ǩ costMoneyType, costMoneyValue = 0, 0 if curDayNum != dayNum and ipyData.GetRepSignCostMoneyInfo(): costMoneyType, costMoneyValue = ipyData.GetRepSignCostMoneyInfo() if costMoneyType and costMoneyValue and not PlayerControl.HaveMoney(curPlayer, costMoneyType, costMoneyValue): return if not ItemControler.CheckPackSpaceEnough(curPlayer, awardItemList): return if costMoneyType and costMoneyValue: PlayerControl.PayMoney(curPlayer, costMoneyType, costMoneyValue, "ActLoginNew", {"actNum":actNum, "dayNum":dayNum, "isAwardEx":isAwardEx}) updAwardRecord = awardRecord | pow(2, dayNum) PlayerControl.NomalDictSetProperty(curPlayer, stateKey % actNum, updAwardRecord) Sync_ActLoginPlayerInfo(curPlayer, actNum) GameWorld.DebugLog("ÁìÈ¡µÇ¼»î¶¯½±Àø£¡ actNum=%s,dayNum=%s,isAwardEx=%s,awardItemList=%s,curDayNum=%s" % (actNum, dayNum, isAwardEx, awardItemList, curDayNum)) for itemID, itemCount, isAuctionItem in awardItemList: ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isAuctionItem, [IPY_GameWorld.rptItem], event=["ActLoginNew", False, {}]) ItemControler.NotifyGiveAwardInfo(curPlayer, awardItemList, "ActLoginNew") return def Sync_ActLoginPlayerInfo(curPlayer, actNum): ## ֪ͨ»î¶¯Íæ¼ÒÐÅÏ¢ clientPack = ChPyNetSendPack.tagMCActLoginPlayerInfoNew() clientPack.ActNum = actNum clientPack.LoginAward = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActLoginNewAward % actNum) clientPack.LoginAwardEx = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActLoginNewAwardEx % actNum) NetPackCommon.SendFakePack(curPlayer, clientPack) return def Sync_ActLoginActionInfo(curPlayer, actNum): ## ֪ͨ»î¶¯ÐÅÏ¢ actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_ActLoginNew, actNum) if not actInfo: return if not actInfo.get(ShareDefine.ActKey_State): return playerActID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActLoginNewID % actNum) if not playerActID: return cfgID = actInfo.get(ShareDefine.ActKey_CfgID) ipyData = IpyGameDataPY.GetIpyGameData("ActLoginNew", cfgID) if not ipyData: return moneyType, moneyValue = ipyData.GetRepSignCostMoneyInfo() templateID = ipyData.GetTemplateID() dayIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActLoginNewAward", templateID) if not dayIpyDataList: return if hasattr(ipyData, "GetRelateFuncID") and ipyData.GetRelateFuncID(): startDateStr, endDateStr = GameWorld.GetActRelateFuncDate(ipyData, playerActID, True) else: startDateStr, endDateStr = GameWorld.GetOperationActionDateStr(ipyData) actPack = ChPyNetSendPack.tagMCActLoginNew() actPack.Clear() actPack.ActNum = actNum actPack.StartDate = startDateStr actPack.EndtDate = endDateStr actPack.LimitLV = ipyData.GetLVLimit() actPack.RepSignMoneyType = moneyType actPack.RepSignMoneyValue = moneyValue actPack.AwardExCTGID = ipyData.GetAwardExCTGID() actPack.AwardDayList = [] for dayIpyData in dayIpyDataList: dayInfo = ChPyNetSendPack.tagMCActLoginNewDay() dayInfo.DayNum = dayIpyData.GetDayNum() dayInfo.AwardItemList = [] for itemID, itemCount, isAuctionItem in dayIpyData.GetLoginAwardItemList(): itemInfo = ChPyNetSendPack.tagMCActLoginNewItem() itemInfo.ItemID = itemID itemInfo.ItemCount = itemCount itemInfo.IsBind = isAuctionItem dayInfo.AwardItemList.append(itemInfo) dayInfo.Count = len(dayInfo.AwardItemList) dayInfo.AwardItemListEx = [] for itemID, itemCount, isAuctionItem in dayIpyData.GetLoginAwardItemListEx(): itemInfo = ChPyNetSendPack.tagMCActLoginNewItem() itemInfo.ItemID = itemID itemInfo.ItemCount = itemCount itemInfo.IsBind = isAuctionItem dayInfo.AwardItemListEx.append(itemInfo) dayInfo.CountEx = len(dayInfo.AwardItemListEx) actPack.AwardDayList.append(dayInfo) actPack.DayCount = len(actPack.AwardDayList) NetPackCommon.SendFakePack(curPlayer, actPack) return