From c04a87b2679e8561dcbe3fad845e169a27f1ec46 Mon Sep 17 00:00:00 2001 From: xdh <xiefantasy@qq.com> Date: 星期五, 22 二月 2019 17:11:37 +0800 Subject: [PATCH] 6256 子 【开发】【2.0】神秘商店开发 / 【后端】【2.0】神秘商店 --- ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFamily.py | 176 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 150 insertions(+), 26 deletions(-) diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFamily.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFamily.py index 8afd776..3894633 100644 --- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFamily.py +++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFamily.py @@ -41,6 +41,7 @@ import PlayerViewCache import GameWorldBoss import PlayerTalk +import PlayerTeam import copy import random @@ -82,6 +83,9 @@ def GetCurWeekMissionMoney(curFamily): return curFamily.GetExtra2() def SetCurWeekMissionMoney(curFamily, value): return curFamily.SetExtra2(min(value, ChConfig.Def_UpperLimit_DWord)) +# 仙盟上次处理的合服天 +def GetFamilyMixServerDay(curFamily): return curFamily.GetExtra1() +def SetFamilyMixServerDay(curFamily, value): return curFamily.SetExtra1(value) ## ------------------ 成员 ---------------------- def GetMemberFightPower(curMember): return curMember.GetExattr3() def SetMemberFightPower(curMember, fightPower): return curMember.SetExattr3(fightPower) @@ -235,6 +239,9 @@ curFamily.SetAcceptJoin(ShareDefine.FamilyAcceptJoin_Agree) #设置收人方式为直接通过申请 PyDataManager.GetFamilyStoreItemManager().DelFamilyStoreItemAll(curFamily.GetID()) + #新创建的仙盟默认设置已处理过合服 + SetFamilyMixServerDay(curFamily, PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_LastMixServerDay)) + #-设置家族成员属性 DoPlayerJionFamily(curFamily, curPlayer, IPY_GameServer.fmlLeader) @@ -348,7 +355,9 @@ # 玩家战盟名变更处理 __OnFamilyNameChange(jionPlayer.GetPlayerID(), curFamily.GetName()) - + #玩家缓存 + PlayerViewCache.OnPlayerFamilyChange(jionPlayer.GetPlayerID(), curFamily.GetID(), curFamily.GetName()) + PlayerTeam.OnTeamMemFamilyRefresh(jionPlayer, curFamily.GetID()) #加入仙盟联赛成员 GameWorldFamilyWar.AddFamilyWarMem(jionPlayer.GetPlayerID(), curFamily.GetID()) GameWorldFamilyWar.CheckPlayerJoinFamilyWarInfo(jionPlayer) @@ -376,7 +385,6 @@ GameWorld.DebugLog(' 玩家战盟名变更处理, newFamilyName=%s' % familyName, playerID) #不处理排行榜 needChangeFamilyBillboardList = [ - #ShareDefine.Def_BT_MixCampaign_Recharge, # 累计充值(合服活动) #ShareDefine.Def_BT_RechargeTeHui, # 充值特惠活动排行榜-当前期记录 ] billboardMgr = GameWorld.GetBillboard() @@ -1247,7 +1255,10 @@ if tagMember.GetFamilyLV() != pack_FamilyLv: #XW_JZ_AppointFamily <n color="255,255,0">恭喜</n><n color="0,190,255">{%S1%}</n><n color="255,255,0">,被任命为{%S2%}!</n> 25 - - NotifyAllFamilyMemberMsg(curFamily, curPlayer, "XW_JZ_AppointFamily", [tagMember.GetName(), pack_FamilyLv]) - + if tagMember.GetFamilyLV() == IPY_GameServer.fmlViceLeader and tagMember.GetPlayerID() in PyGameData.g_autoViceleaderDict.get(familyID, []): + #自动安排的副盟主被撤职则该盟不再自动安排 + if familyID not in PyGameData.g_forbidAutoViceleaderFamily: + PyGameData.g_forbidAutoViceleaderFamily.append(familyID) #更改家族等级 ChangeFamilyMemberLv(tagMember, pack_FamilyLv) @@ -1489,6 +1500,20 @@ if GameWorld.GetGameWorld().GetDictByKey(ShareDefine.Def_Notify_WorldKey_DailyActionState % ShareDefine.DailyActionID_FamilyRobBoss): PlayerControl.NotifyCode(curPlayer, "FairyGrabBossExitError") return + #判断退出时间间隔 + curTime = int(time.time()) + lastLeaveFamilyTime = PlayerControl.GetLeaveFamilyTime(curPlayer) + if lastLeaveFamilyTime > 100: + remainTime = IpyGameDataPY.GetFuncCfg('ExitFairyTime', 2) - (curTime - lastLeaveFamilyTime) + if remainTime > 0: + PlayerControl.NotifyCode(curPlayer, "ExitFairyTime", [remainTime*1000]) + return + updTime = 1 if IpyGameDataPY.GetFuncCfg('ExitFairyTime') > 1 else curTime + elif lastLeaveFamilyTime >= IpyGameDataPY.GetFuncCfg('ExitFairyTime')-1: + updTime = curTime + else: + updTime = lastLeaveFamilyTime+1 + PlayerControl.SetLeaveFamilyTime(curPlayer, updTime) #XW_JZ_LeaveFamily <n color="0,190,255">{%S1%}</n><n color="255,255,0">退出了家族!</n> 25 - - NotifyAllFamilyMemberMsg(curFamily, curPlayer, "XW_JZ_LeaveFamily", [curPlayer.GetName()]) @@ -1504,7 +1529,7 @@ __DoPlayerLeaveFamilyByID(curFamily, curPlayerID) DataRecordPack.DR_PlayerLeaveFamily(curPlayer, curFamily.GetID(), curFamily.GetName(), curFamily.GetCount(), - familyLV, curPlayer.GetPlayerID(), curPlayer.GetName(), familyLV) + familyLV, curPlayer.GetPlayerID(), curPlayer.GetName(), familyLV, updTime) if curFamily.GetCount() == 0: #玩家离开后, 家族没有人了 , 删除这个家族 @@ -1524,7 +1549,9 @@ # 玩家战盟名变更处理 __OnFamilyNameChange(leavePlayerID, '') AddFamilyIDToFightPowerChangeList(curFamily.GetID()) - PlayerViewCache.OnPlayerLeaveFamily(leavePlayerID) + PlayerViewCache.OnPlayerFamilyChange(leavePlayerID, 0, "") + if leavePlayerID in PyGameData.g_autoViceleaderDict.get(curFamily.GetID(),[]): + PyGameData.g_autoViceleaderDict[curFamily.GetID()].remove(leavePlayerID) return #////////////////////////////////////////////////////////////// @@ -1787,7 +1814,6 @@ def PlayerForceLeaveFamily(curPlayer, tick): if curPlayer == None: return - #设置当天加入家族 GameWorld.GetPlayerManager().SetForbiddenEnterFamily(curPlayer.GetPlayerID(), True) # 通知map玩家不能参加家族活动 @@ -1802,6 +1828,8 @@ #弹劾信息封包 SendPackClientImpeachMsg(curPlayer, 0, 0) + PlayerTeam.OnTeamMemFamilyRefresh(curPlayer, 0) + return #--------------------------------------------------------------------- @@ -1904,6 +1932,37 @@ PlayerRefresh(curPlayer, tick) GameWorldFamilyWar.OnPlayerLogin(curFamily, curPlayer) + + # 盟主上线处理 + if curMember.GetFamilyLV() == IPY_GameServer.fmlLeader: + OnFamilyLeaderLogin(curPlayer, curFamily) + return + +def OnFamilyLeaderLogin(curPlayer, curFamily): + ## 盟主登录处理 + __DoFamilyMixServerLogicOnLeaderLogin(curPlayer, curFamily) + return + +def __DoFamilyMixServerLogicOnLeaderLogin(curPlayer, curFamily): + ## 合服仙盟盟主登录处理 + + isMixServer = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_IsMixServer) + if not isMixServer: + return + lastMixServerDay = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_LastMixServerDay) + familyID = curFamily.GetID() + familyMixServerDay = GetFamilyMixServerDay(curFamily) + if familyMixServerDay == lastMixServerDay: + GameWorld.DebugLog("已经处理过仙盟盟主合服登录逻辑! lastMixServerDay=%s" % (lastMixServerDay), familyID) + return + SetFamilyMixServerDay(curFamily, lastMixServerDay) + GameWorld.Log("处理合服仙盟盟主登录! lastMixServerDay=%s" % (lastMixServerDay), familyID) + + mailItemList = IpyGameDataPY.GetFuncEvalCfg("MixServerMail", 4) + playerID = curPlayer.GetPlayerID() + detailDict = {} + GameWorld.Log(" 发送合服盟主专属补偿邮件! familyID=%s,mailItemList=%s" % (familyID, mailItemList), playerID) + PlayerCompensation.SendMailByKey("MixServer2", [playerID], mailItemList, detail=detailDict) return #--------------------------------------------------------------------- ## 玩家下线家族刷新逻辑 @@ -2298,6 +2357,7 @@ #上面已经验证过了,家族肯定存在的 curFamily = curPlayer.GetFamily() curFamilyID = curFamily.GetID() + curPlayerID = curPlayer.GetID() # curFamilyTrig = PlayerDBGSEvent.FindDBGSTrig_ByEventID(curFamilyID , PlayerDBGSEvent.Def_Key_RenameFamily) # # if not curFamilyTrig: @@ -2332,20 +2392,20 @@ curMemberID = curMember.GetPlayerID() __OnFamilyNameChange(curMemberID, familyName) memberIDList.append(curMemberID) - curPlayer = playerManager.FindPlayerByID(curMemberID) + player = playerManager.FindPlayerByID(curMemberID) #玩家不在线 - if not curPlayer: + if not player: continue - curPlayerMapID = GameWorld.GetQueryPlayerMapID(curPlayer) + curPlayerMapID = GameWorld.GetQueryPlayerMapID(player) if not curPlayerMapID: continue - msgStr = str([curPlayer.GetPlayerID(), familyName]) + msgStr = str([curPlayerID, familyName]) playerManager.MapServer_QueryPlayer(0, 0, curMemberID, curPlayerMapID, 'FamilyNameRefresh', msgStr, len(msgStr), - curPlayer.GetRouteServerIndex()) + player.GetRouteServerIndex()) PlayerCompensation.SendMailByKey('FamilyNameChange', memberIDList, [], [oldName, familyName]) PlayerControl.WorldNotify(0, 'Family_ChangeName', [oldName, familyName]) @@ -2533,8 +2593,6 @@ # if useMoney > 0: # #帮会日常维持消耗{%S1%}银两帮会资金 # PlayerControl.FamilyNotify(family.GetID(), 'jiazu_lhs_272921', [useMoney]) - #自动传位 - __AutoChangeLeader(family) #通知客户端刷新 family.Broadcast_FamilyChange() @@ -2591,6 +2649,76 @@ PlayerFamilyBoss.FamilyBossFBOnWeek(familyID) return + +def FamilyOnHour(): + familyManager = GameWorld.GetFamilyManager() + for i in xrange(familyManager.GetCount()): + family = familyManager.GetAt(i) + #自动传位 + __AutoChangeLeader(family) + + __AutoChangeFamilyJobLV(family) + return + +def __AutoChangeFamilyJobLV(family): + ##开服2天内新创建的仙盟,系统自动为仙盟安排两位副盟主 + familyID = family.GetID() + openServerDay = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ServerDay) + if openServerDay >= IpyGameDataPY.GetFuncCfg('FairyFMZ'): + #GameWorld.DebugLog('自动为仙盟安排两位副盟主 开服天超过 familyID=%s'%familyID) + return + + if familyID in PyGameData.g_forbidAutoViceleaderFamily: + #GameWorld.DebugLog('自动为仙盟安排两位副盟主 被禁止 familyID=%s'%familyID) + return + createTime = family.GetCreateTime() + pastHour = GameWorld.GetPastHour(createTime) + if pastHour < IpyGameDataPY.GetFuncCfg('FairyFMZ', 2): + #GameWorld.DebugLog('自动为仙盟安排两位副盟主 建盟未超过X小时 familyID=%s,pastHour=%s'%(familyID, pastHour)) + return + if (pastHour - IpyGameDataPY.GetFuncCfg('FairyFMZ', 2)) % IpyGameDataPY.GetFuncCfg('FairyFMZ', 3) != 0: + GameWorld.DebugLog('自动为仙盟安排两位副盟主 间隔没到 familyID=%s,pastHour=%s'%(familyID, pastHour)) + return + + tofmlv = IPY_GameServer.fmlViceLeader + viceLeaderCnt = 0 #副盟主数量 + changeMemberList = [] + for i in xrange(family.GetCount()): + familyMember = family.GetAt(i) + if familyMember.GetFamilyLV() == tofmlv: + viceLeaderCnt += 1 + continue + if familyMember.GetFamilyLV() < tofmlv: + changeMemberList.append(familyMember) + + maxCnt = GetFamilySetting(family, ChConfig.Def_FamilyPowLvChangeFamilySettingDict[tofmlv]) + #GameWorld.DebugLog('自动为仙盟安排两位副盟主 familyID=%s,viceLeaderCnt=%s,changeMemberList=%s'%(familyID, viceLeaderCnt, changeMemberList)) + if viceLeaderCnt >= maxCnt or not changeMemberList: + return + + if familyID not in PyGameData.g_autoViceleaderDict: + PyGameData.g_autoViceleaderDict[familyID] = [] + + changeMemberList.sort(cmp=CmpAutoMemberSort) + for i, member in enumerate(changeMemberList): + if viceLeaderCnt + i >= maxCnt: + break + ChangeFamilyMemberLv(member, tofmlv) + playerID = member.GetPlayerID() + if playerID not in PyGameData.g_autoViceleaderDict[familyID]: + PyGameData.g_autoViceleaderDict[familyID].append(playerID) + GameWorld.Log('自动为仙盟安排副盟主 familyID=%s,playerID=%s'%(familyID, playerID)) + + return + +def CmpAutoMemberSort(member1, member2): + ## 排序规则: 等级>战力>入盟先后 + ret = -cmp(member1.GetLV(), member2.GetLV()) + if ret == 0: + ret = -cmp(GetMemberFightPower(member1), GetMemberFightPower(member2)) + if ret == 0: + return cmp(GetMemberJoinTime(member1), GetMemberJoinTime(member2)) + return ret #--------------------------------------------------------------------- ##通知地图服务器, 玩家家族属性刷新 @@ -2710,16 +2838,15 @@ return 0 leaderID = curFamily.GetLeaderID() - # 帮主在线 - if GameWorld.GetPlayerManager().FindPlayerByID(leaderID) != None: - return 0 curMember = curFamily.FindMember(leaderID) if curMember == None: GameWorld.Log("GetLeaderOfflineTime->FindMember, None;%s" % leaderID) return 0 - - offLineTime = GameWorld.ChangeTimeNumToStr(curMember.GetExattr2()) + offLineTimeNum = curMember.GetExattr2() + if not offLineTimeNum: + return 0 + offLineTime = GameWorld.ChangeTimeNumToStr(offLineTimeNum) return GameWorld.GetPastHour(offLineTime) def GetLastOnlineMemberOfflineTime(family): @@ -2727,17 +2854,14 @@ offLineTime = 0 for i in range(0, family.GetCount()): member = family.GetAt(i) - playerID = member.GetPlayerID() - tagPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID) - if tagPlayer: - return 0 - if not member.GetExattr2(): + offLineTimeNum = member.GetExattr2() + if not offLineTimeNum: #有人在线直接返回 return 0 if not offLineTime: - offLineTime = member.GetExattr2() + offLineTime = offLineTimeNum else: - offLineTime = max(offLineTime, member.GetExattr2()) + offLineTime = max(offLineTime, offLineTimeNum) if not offLineTime: return 0 offLineTime = GameWorld.ChangeTimeNumToStr(offLineTime) @@ -2747,7 +2871,7 @@ '''自动传位''' # 获得帮主下线了多久(小时) leaderOffLineTime = GetLeaderOfflineTime(curFamily) - GameWorld.DebugLog('帮主下线了%s小时'%leaderOffLineTime) + GameWorld.DebugLog('帮主下线了%s小时'%leaderOffLineTime, curFamily.GetID()) if leaderOffLineTime < IpyGameDataPY.GetFuncCfg('AutoChangeLeader'): return -- Gitblit v1.8.0