|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #非VIP权限 | 
|---|
|  |  |  | Def_GeTui_FMT = -2 # 封魔坛 | 
|---|
|  |  |  | Def_GeTui_ZhuXianBoss = -3 # 诛仙BOSS | 
|---|
|  |  |  |  | 
|---|
|  |  |  | # 新玩家还没有脱机时间 有利于挽回流失玩家 | 
|---|
|  |  |  | g_NewGuyNoTJGTime = {} # {playerID:[playername,getuiid, tick]} | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | # 检查是否可以个推,geTuiType小于0的代表默认可推,无VIP限制 | 
|---|
|  |  |  | def CheckCanGeTui(playerCache, geTuiType=-1): | 
|---|
|  |  |  | if not playerCache.get("GeTuiClientID", ""): | 
|---|
|  |  |  | return False | 
|---|
|  |  |  |  | 
|---|
|  |  |  | # 离线超过24小时不再推送,目前极光推送的特点是推送ID同机器不同包都是同一个ID | 
|---|
|  |  |  | if not playerCache.get("Time", 0): | 
|---|
|  |  |  | return False | 
|---|
|  |  |  | if time.time() - playerCache.get("Time", 0) > 24*60*60: | 
|---|
|  |  |  | return False | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if not playerCache.get("VIPLV", 0): | 
|---|
|  |  |  | if geTuiType < 0: | 
|---|
|  |  |  | return True | 
|---|
|  |  |  | return False | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if geTuiType == Def_GeTui_FMT: | 
|---|
|  |  |  | if geTuiType in [Def_GeTui_FMT, Def_GeTui_ZhuXianBoss]: | 
|---|
|  |  |  | # 封魔坛受VIP的关注BOSS开关影响 | 
|---|
|  |  |  | geTuiType = Def_Onoff_Boss | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | return False | 
|---|
|  |  |  |  | 
|---|
|  |  |  | g_FMTGeTuiLimit[playerID][bossID] = int(time.time()) | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | elif geTuiType == Def_GeTui_ZhuXianBoss: | 
|---|
|  |  |  | if not cacheDict.get("CntMark_%s"%ChConfig.Def_FBMapID_ZhuXianBoss, 0): | 
|---|
|  |  |  | return False | 
|---|
|  |  |  |  | 
|---|
|  |  |  | # 比较频繁默认1小时通知一次 | 
|---|
|  |  |  | if playerID not in g_FMTGeTuiLimit: | 
|---|
|  |  |  | g_FMTGeTuiLimit[playerID] = {} | 
|---|
|  |  |  |  | 
|---|
|  |  |  | lastTime = g_FMTGeTuiLimit[playerID].get(bossID, 0) | 
|---|
|  |  |  | if lastTime != 0 and time.time() - lastTime < 3600: | 
|---|
|  |  |  | # 离上次通知还没超过1小时 | 
|---|
|  |  |  | return False | 
|---|
|  |  |  |  | 
|---|
|  |  |  | g_FMTGeTuiLimit[playerID][bossID] = int(time.time()) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | elif geTuiType == Def_Onoff_Boss: | 
|---|
|  |  |  | #重生boss | 
|---|
|  |  |  | killBossCntLimitDict = IpyGameDataPY.GetFuncEvalCfg('KillBossCntLimit', 1, {}) | 
|---|
|  |  |  | 
|---|
|  |  |  | return True | 
|---|
|  |  |  | return True | 
|---|
|  |  |  |  | 
|---|
|  |  |  | # 个推基础判定 | 
|---|
|  |  |  | def CanGeTuiByCache(curCache): | 
|---|
|  |  |  | if not curCache.GeTuiID: | 
|---|
|  |  |  | return False | 
|---|
|  |  |  |  | 
|---|
|  |  |  | # 离线超过24小时不再推送,目前极光推送的特点是推送ID同机器不同包都是同一个ID | 
|---|
|  |  |  | if time.time() - curCache.OffTime > 24*60*60: | 
|---|
|  |  |  | return False | 
|---|
|  |  |  | return True | 
|---|
|  |  |  |  | 
|---|
|  |  |  | def BossAttentionGeTui(bossData, bossID): | 
|---|
|  |  |  | if bossData.GetMapID() == ChConfig.Def_FBMapID_SealDemon: | 
|---|
|  |  |  | # 非VIP玩家 封魔坛个推 | 
|---|
|  |  |  | geTuiType = Def_GeTui_FMT | 
|---|
|  |  |  | elif bossData.GetMapID() == ChConfig.Def_FBMapID_ZhuXianBoss: | 
|---|
|  |  |  | # 非VIP玩家 诛仙BOSS个推 | 
|---|
|  |  |  | geTuiType = Def_GeTui_ZhuXianBoss | 
|---|
|  |  |  | else: | 
|---|
|  |  |  | geTuiType = Def_Onoff_Boss | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID) | 
|---|
|  |  |  | if curPlayer and not PlayerControl.GetIsTJG(curPlayer): | 
|---|
|  |  |  | continue | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | # 离线玩家 | 
|---|
|  |  |  | curCache = PlayerViewCache.FindViewCache(playerID) | 
|---|
|  |  |  | if not curCache: | 
|---|
|  |  |  | continue | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if not CanGeTuiByCache(curCache): | 
|---|
|  |  |  | #无推送资格,减少检索和eval | 
|---|
|  |  |  | continue | 
|---|
|  |  |  |  | 
|---|
|  |  |  | recordDict = eval(bossAttentionData.RecordData) | 
|---|
|  |  |  | if recordDict.get(bossID, 0) in [0, 9]: | 
|---|
|  |  |  | #0-默认未关注, 1-主动关注, 2-自动关注, 9-主动取消关注 | 
|---|
|  |  |  | continue | 
|---|
|  |  |  | curCache = PlayerViewCache.ViewCacheMgr.FindCache(playerID) | 
|---|
|  |  |  | if not curCache: | 
|---|
|  |  |  | continue | 
|---|
|  |  |  | cacheDict = eval(curCache.GetPropData()) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | cacheDict = PlayerViewCache.GetCachePropDataDict(curCache) | 
|---|
|  |  |  | if not CheckCanGeTui(cacheDict, geTuiType): | 
|---|
|  |  |  | # 过滤个推 | 
|---|
|  |  |  | # 个推逻辑检查 | 
|---|
|  |  |  | continue | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if not CheckBossGeTuiCnt(playerID, bossID, geTuiType, cacheDict): | 
|---|
|  |  |  | # 判断BOSS剩余次数, 避免通知频繁 | 
|---|
|  |  |  | continue | 
|---|
|  |  |  |  | 
|---|
|  |  |  | appID = GameWorld.GetPlayerPlatform(cacheDict.get("AppID", "")) | 
|---|
|  |  |  | appID = cacheDict.get("AppID", "") | 
|---|
|  |  |  | if appID not in appIDDict: | 
|---|
|  |  |  | appIDDict[appID] = [] | 
|---|
|  |  |  |  | 
|---|
|  |  |  | appIDDict[appID].append([cacheDict.get("GeTuiClientID", ""), cacheDict.get("Name", "")]) | 
|---|
|  |  |  | appIDDict[appID].append([curCache.GeTuiID, cacheDict.get("Name", "")]) | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if not appIDDict: | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if geTuiType == Def_GeTui_FMT: | 
|---|
|  |  |  | showStr = GameWorld.GbkToCode(IpyGameDataPY.GetFuncCfg("GeTuiOffLine", 1)%(npcName, npcLV))    # 文字信息 | 
|---|
|  |  |  | elif geTuiType == Def_GeTui_ZhuXianBoss: | 
|---|
|  |  |  | showStr = GameWorld.GbkToCode(IpyGameDataPY.GetFuncCfg("GeTuiOffLine", 5)%(npcName, npcLV))    # 文字信息 | 
|---|
|  |  |  | elif geTuiType == Def_Onoff_Boss: | 
|---|
|  |  |  | showStr = GameWorld.GbkToCode(IpyGameDataPY.GetFuncCfg("GeTuiOffLine", 2)%(bossData.GetSourceName(), npcName, npcLV))    # 文字信息 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | # 私聊 | 
|---|
|  |  |  | def ChatMiGeTui(playerID, playerName, tagPlayerName): | 
|---|
|  |  |  | curCache = PlayerViewCache.ViewCacheMgr.FindCache(playerID) | 
|---|
|  |  |  | curCache = PlayerViewCache.FindViewCache(playerID) | 
|---|
|  |  |  | if not curCache: | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | cacheDict = eval(curCache.GetPropData()) | 
|---|
|  |  |  | if not CanGeTuiByCache(curCache): | 
|---|
|  |  |  | #无推送资格,基础判定 | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | cacheDict = PlayerViewCache.GetCachePropDataDict(curCache) | 
|---|
|  |  |  | if not CheckCanGeTui(cacheDict, Def_Onoff_Chat): | 
|---|
|  |  |  | # 过滤个推 | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | showStr = GameWorld.GbkToCode(IpyGameDataPY.GetFuncCfg("GeTuiOffLine", 3))%(tagPlayerName)    # 文字信息 | 
|---|
|  |  |  | GeTuiNotify({GameWorld.GetPlayerPlatform(cacheDict.get("AppID", "")):[[cacheDict.get("GeTuiClientID", ""), playerName]]}, showStr) | 
|---|
|  |  |  | GeTuiNotify({cacheDict.get("AppID", ""):[[curCache.GeTuiID, playerName]]}, showStr) | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | # 下线时,低级玩家没有离线时间的玩家提示, 上线清空 | 
|---|