From aba770321dd1bf504f0389bd655ca43188c35d68 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期四, 20 二月 2020 17:11:18 +0800
Subject: [PATCH] 4664 【主干】筋斗云传送改灵石

---
 ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFamily.py |  368 ++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 281 insertions(+), 87 deletions(-)

diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFamily.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFamily.py
index fe9b667..cb145d1 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFamily.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFamily.py
@@ -40,7 +40,10 @@
 import PlayerFamilySWRH
 import PlayerViewCache
 import GameWorldBoss
+import AuctionHouse
+import PlayerAssist
 import PlayerTalk
+import PlayerTeam
 
 import copy
 import random
@@ -82,6 +85,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)
@@ -127,7 +133,7 @@
             if not lackCnt:
                 break
     elif lackCnt < 0:
-        GameWorld.ErrLog('    随机假仙盟异常 已存在的随机数大于还需要的随机个数lackFakeCnt=%s,fakeIDList=%s'%(lackFakeCnt, fakeIDList))
+        #GameWorld.DebugLog('    随机假仙盟异常 已存在的随机数大于还需要的随机个数lackFakeCnt=%s,fakeIDList=%s'%(lackFakeCnt, fakeIDList))
         return []
     return fakeIDList
 
@@ -155,6 +161,28 @@
         if PlayerControl.GetIsTJG(curPlayer):
             return
         NetPackCommon.SendFakePack(curPlayer, fakeFamilyPack)
+    return
+
+def SyncCreatFamilyTimes(curPlayer=None):
+    # 通知建盟次数
+    packData = ChPyNetSendPack.tagGCServerCreatFamilyTimes()
+    packData.Clear()
+    packData.Times = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ServerCreatFamilyTimes)
+    if not curPlayer:
+        # 全服广播在线玩家
+        playerManager = GameWorld.GetPlayerManager()
+        for i in range(0, playerManager.GetPlayerCount()):
+            curPlayer = playerManager.GetPlayerByIndex(i)
+            if curPlayer == None or not curPlayer.GetInitOK():
+                continue
+            
+            if PlayerControl.GetIsTJG(curPlayer):
+                continue
+            NetPackCommon.SendFakePack(curPlayer, packData)
+    else:
+        if PlayerControl.GetIsTJG(curPlayer):
+            return
+        NetPackCommon.SendFakePack(curPlayer, packData)
     return
 
 #输入家族名称
@@ -235,13 +263,18 @@
     curFamily.SetAcceptJoin(ShareDefine.FamilyAcceptJoin_Agree)     #设置收人方式为直接通过申请
     PyDataManager.GetFamilyStoreItemManager().DelFamilyStoreItemAll(curFamily.GetID())
     
+    #新创建的仙盟默认设置已处理过合服
+    SetFamilyMixServerDay(curFamily, PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_LastMixServerDay))
+    
     #-设置家族成员属性
     DoPlayerJionFamily(curFamily, curPlayer, IPY_GameServer.fmlLeader)
-    
+    creatFamilyTimes = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ServerCreatFamilyTimes)
     #扣道具(前N个战盟并且假编号在随机编号里不要钱)
     if fakeIndex and fakeIndex in fakeIndexList:
         PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_FakeFamilyIndex % fakeIndexList.index(fakeIndex), 0)
-        GameWorld.DebugLog('    创建前3个仙盟不扣钱! 假仙盟索引%s'%fakeIndexList.index(fakeIndex))
+        GameWorld.Log('    创建前n个假仙盟不扣钱! 假仙盟索引%s'%fakeIndexList.index(fakeIndex))
+    elif creatFamilyTimes < IpyGameDataPY.GetFuncCfg('CreateFamilyNeedMoney', 3):
+        GameWorld.Log('    创建前n个仙盟不扣钱! creatFamilyTimes=%s' % creatFamilyTimes)
     else:
         for i, findex in enumerate(fakeIndexList):
             if findex:
@@ -251,7 +284,9 @@
         needMoney = IpyGameDataPY.GetFuncCfg('CreateFamilyNeedMoney')
         if needMoney:
             moneyType = IpyGameDataPY.GetFuncCfg('CreateFamilyNeedMoney', 2)
-            curPlayer.MapServer_PayMoney(moneyType, needMoney)
+            sendMsg = str([moneyType, needMoney])
+            curPlayer.MapServer_QueryPlayerResult(0, 0, "CreateFamilyPayMoney", sendMsg, len(sendMsg))
+            #curPlayer.MapServer_PayMoney(moneyType, needMoney)
             #玩家创建家族费用转化为家族初始资金
             #PlayerAddFamilyMoney(curPlayer, curFamily, needMoney)
   
@@ -277,12 +312,13 @@
     
     #XW_JZ_EstablishSud <n color="255,255,0">恭喜您,家族建立成功!</n>    25  -   -
     PlayerControl.NotifyCode(curPlayer, "XW_JZ_EstablishSud")
-    
+    PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ServerCreatFamilyTimes, min(creatFamilyTimes + 1, ShareDefine.Def_UpperLimit_DWord))
+    SyncCreatFamilyTimes()
     #帮会创建流向
     DataRecordPack.DR_CreateFamily(curPlayer.GetAccID(), curPlayerID, curPlayer.GetName(),
-                                   fullFamilyName, curFamily.GetID())
+                                   fullFamilyName, curFamily.GetID(), creatFamilyTimes+1)
 
-    GameWorld.Log('创建家族 : %s(%s), fakeIndex=%s' % (fullFamilyName, curFamily.GetID(), fakeIndex), curPlayerID)
+    GameWorld.Log('创建家族 : %s(%s), fakeIndex=%s, creatFamilyTimes=%s' % (fullFamilyName, curFamily.GetID(), fakeIndex, creatFamilyTimes+1), curPlayerID)
     PlayerControl.WorldNotify(0, "jiazu_liubo_671654", [curPlayer.GetName(), fullFamilyName, curFamily.GetID()])
     return
 
@@ -348,7 +384,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)
@@ -359,7 +397,8 @@
     PlayerFamilyBoss.NotifyFamilyBossFBInfo(jionPlayer)
     #通知家族仓库
     PyDataManager.GetFamilyStoreItemManager().SyncFamilyStoreItem(jionPlayer, curFamily.GetID())
-    
+    #仙盟拍品
+    AuctionHouse.Sync_FamilyAuctionItemInfo(jionPlayer, curFamily.GetID())
     SetMemberFightPower(familyMember, jionPlayer.GetFightPower())
     AddFamilyIDToFightPowerChangeList(curFamily.GetID())
     
@@ -367,6 +406,8 @@
     PlayerFamilyParty.NotifyFamilyPartyQuestion(jionPlayer)
     #通知守卫人皇信息
     PlayerFamilySWRH.NotifySWRHInfo(jionPlayer, curFamily.GetID())
+    #通知仙盟协助信息
+    PlayerAssist.SyncFamilyAssist(jionPlayer)
     #oss记录加入家族信息
     DataRecordPack.DR_PlayerJoinFamily(jionPlayer, curFamily.GetID(), curFamily.GetName(), curFamily.GetCount())
     return
@@ -376,8 +417,6 @@
     GameWorld.DebugLog('    玩家战盟名变更处理, newFamilyName=%s' % familyName, playerID)
     #不处理排行榜
     needChangeFamilyBillboardList = [
-                                     #ShareDefine.Def_BT_MixCampaign_Recharge,  # 累计充值(合服活动)
-                                     #ShareDefine.Def_BT_RechargeTeHui,  # 充值特惠活动排行榜-当前期记录
                                      ]
     billboardMgr = GameWorld.GetBillboard()
     for billboardIndex in needChangeFamilyBillboardList:
@@ -572,7 +611,7 @@
     #===============================================================================================
     return
 
-def SendFamilyFakePack(familyID, clientPack):
+def SendFamilyFakePack(familyID, clientPack, excludePlayerIDList=[]):
     ## 广播家族成员PY封包
     family = GameWorld.GetFamilyManager().FindFamily(familyID)
     if not family:
@@ -581,8 +620,11 @@
     for index in xrange(family.GetCount()):
         member = family.GetAt(index)
         memPlayer = member.GetPlayer()
-        if memPlayer:
-            NetPackCommon.SendFakePack(memPlayer, clientPack)
+        if not memPlayer:
+            continue
+        if excludePlayerIDList and memPlayer.GetPlayerID() in excludePlayerIDList:
+            continue
+        NetPackCommon.SendFakePack(memPlayer, clientPack)
     return
 
 def Sync_PyAllFamilyInfo(curPlayer, allPageCnt, viewPage, startIndex, endIndex):
@@ -665,6 +707,47 @@
     NetPackCommon.SendFakePack(curPlayer, familyViewPack)
     return
 
+#// A4 12 搜索家族 #tagCGPySearchFamily
+#
+#struct    tagCGPySearchFamily
+#{
+#    tagHead        Head;
+#    BYTE        MsgLen;        //模糊搜索家族,如果输入为空,则为不限制该条件
+#    char        Msg[MsgLen];    //size = MsgLen
+#    BYTE        LV;        //最低家族等级,如果为0,则不限制该条件
+#    BYTE        MaxCount;    //搜索结果所需最大条数,后端限制最多返回20条
+#    BYTE        IsSearching;    //默认1,如果有指定其他值,则返回指定值
+#};
+def PySearchFamily(index, clientData, tick):
+    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
+    
+    msg = clientData.Msg
+    minFamilyLV = clientData.LV
+    maxCount = min(20, clientData.MaxCount)
+    IsSearching = clientData.IsSearching
+    
+    familyMgr = GameWorld.GetFamilyManager()
+    familyViewPack = ChPyNetSendPack.tagGCPyAllFamilyView()
+    familyViewPack.Clear()
+    familyViewPack.IsSearching = IsSearching
+    familyViewPack.TotalCount = 1
+    #familyViewPack.CurPage = viewPage
+    familyViewPack.Family = []
+    for i, familyID in enumerate(PyGameData.g_sortFamilyIDList):
+        family = familyMgr.FindFamily(familyID)
+        if not family:
+            continue
+        if msg not in family.GetName():
+            continue
+        if minFamilyLV and family.GetLV() < minFamilyLV:
+            continue
+        familyViewPack.Family.append(__GetFamilyView(i, family))
+        if len(familyViewPack.Family) >= maxCount:
+            break
+    familyViewPack.PageCount = len(familyViewPack.Family)
+    NetPackCommon.SendFakePack(curPlayer, familyViewPack)
+    return
+
 #class   IPY_CFamilyChangeBroadcast
 #{
 #public:
@@ -708,7 +791,7 @@
     pack = IPY_GameServer.IPY_CFamilyChangeBroadcast()
     #更改家族公告
     curFamily.SetBroadcast(pack.GetMsg())
-    
+    GameWorld.Log('更改仙盟公告 Family=%s,公告=%s'%(GameWorld.CodeToGBK(curFamily.GetName()), GameWorld.CodeToGBK(pack.GetMsg())), curPlayerID)
     #通知客户端家族信息改变
     curFamily.Broadcast_FamilyChange()
     playerManager = GameWorld.GetPlayerManager()
@@ -1153,10 +1236,11 @@
     if pack_FamilyLv not in ChConfig.Def_Family_MemberLVList:
         GameWorld.Log("更改家族成员等级->封包异常->等级 = %s不存在" % (pack_FamilyLv), curPlayerID)
         return
-    if curMember.GetFamilyLV() != IPY_GameServer.fmlLeader:
-        if tagMember.GetFamilyLV() >= curMember.GetFamilyLV() or pack_FamilyLv >= curMember.GetFamilyLV():
-            GameWorld.Log("更改家族成员等级->目标职位比自己的高或者对方的当前职位比自己高", curPlayerID)
-            return
+    if not isGMOP:
+        if curMember.GetFamilyLV() != IPY_GameServer.fmlLeader:
+            if tagMember.GetFamilyLV() >= curMember.GetFamilyLV() or pack_FamilyLv >= curMember.GetFamilyLV():
+                GameWorld.Log("更改家族成员等级->目标职位比自己的高或者对方的当前职位比自己高", curPlayerID)
+                return
     
     familyID = curFamily.GetID()  # 家族ID
     familyName = curFamily.GetName()  # 家族名字
@@ -1205,7 +1289,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)
     
@@ -1223,7 +1310,8 @@
         if GetFamilyMemberHasPow(tagMember, ChConfig.Def_PurviewDictKey_CanCall):
             tagPlayer.Sync_FamilyInfo()
             PlayerFamilyAction.ViewFamilyRequestInfo(tagPlayer)
-    
+    if isGMOP:
+        curFamily.SetBroadcast('')
     curFamily.Broadcast_FamilyChange()
     return True
 #---------------------------------------------------------------------
@@ -1367,7 +1455,12 @@
     if GameWorld.GetGameWorld().GetDictByKey(ShareDefine.Def_Notify_WorldKey_DailyActionState % ShareDefine.DailyActionID_FamilyRobBoss):        
         PlayerControl.NotifyCode(curPlayer, "FairyGrabBossExitError")
         return
-    
+    if PlayerFamilyBoss.IsInAllFamilyBoss():
+        PlayerControl.NotifyCode(curPlayer, "LeagueBOSSExitError1")
+        return
+    if AuctionHouse.IsFamilyMemberBiddingAuctionItem(curFamily.GetID(), tagMemberID):
+        PlayerControl.NotifyCode(curPlayer, "Paimai7")
+        return
     tagPlayerName = curTagMember.GetName()  # 被踢玩家名
     tagPlayerID = curTagMember.GetPlayerID()  # 被踢玩家ID
     tagFamilyLV = curTagMember.GetFamilyLV()  # 被踢玩家职位
@@ -1378,10 +1471,10 @@
     PlayerFamilyAction.AddFamilyActionNote(tagPlayerName, curFamily.GetID(), ShareDefine.Def_ActionType_FamilyEvent,
                                            [ShareDefine.Def_FamilyActionEvent_MemberChange, ShareDefine.Def_FamilyMemberChange_KickOut], tick)
     #删除玩家
-    curFamily.DeleteMember(tagPlayerID)
-    __DoPlayerLeaveFamilyByID(curFamily, tagPlayerID)
-    
+    curFamily.DeleteMember(tagPlayerID)    
     tagPlayer = playerManager.FindPlayerByID(tagMemberID)
+    
+    __DoPlayerLeaveFamilyByID(curFamily, tagPlayerID, tagPlayer)
     #玩家在线, 设置这个玩家的属性
     PlayerForceLeaveFamily(tagPlayer, tick)
     
@@ -1446,6 +1539,26 @@
     if GameWorld.GetGameWorld().GetDictByKey(ShareDefine.Def_Notify_WorldKey_DailyActionState % ShareDefine.DailyActionID_FamilyRobBoss):        
         PlayerControl.NotifyCode(curPlayer, "FairyGrabBossExitError")
         return
+    if PlayerFamilyBoss.IsInAllFamilyBoss():
+        PlayerControl.NotifyCode(curPlayer, "LeagueBOSSExitError1")
+        return
+    if AuctionHouse.IsFamilyMemberBiddingAuctionItem(curFamily.GetID(), curMember.GetPlayerID()):
+        PlayerControl.NotifyCode(curPlayer, "Paimai8")
+        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()])
@@ -1458,10 +1571,10 @@
     curFamily.DeleteMember(curMember.GetPlayerID())
     #玩家在线, 设置这个玩家的属性
     PlayerForceLeaveFamily(curPlayer, tick)  
-    __DoPlayerLeaveFamilyByID(curFamily, curPlayerID)
+    __DoPlayerLeaveFamilyByID(curFamily, curPlayerID, curPlayer)
 
     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:
         #玩家离开后, 家族没有人了 , 删除这个家族
@@ -1476,12 +1589,15 @@
 #  @param curFamily 离开的家族
 #  @param leavePlayerID 离开的玩家ID
 #  @return None
-def __DoPlayerLeaveFamilyByID(curFamily, leavePlayerID):
+def __DoPlayerLeaveFamilyByID(curFamily, leavePlayerID, tagPlayer=None):
     PlayerFamilyAction.DelFamilyOfficerModelEquip(curFamily.GetID(), leavePlayerID)
     # 玩家战盟名变更处理
     __OnFamilyNameChange(leavePlayerID, '')
     AddFamilyIDToFightPowerChangeList(curFamily.GetID())
-    PlayerViewCache.OnPlayerLeaveFamily(leavePlayerID)
+    PlayerViewCache.OnPlayerFamilyChange(leavePlayerID, 0, "")
+    PlayerAssist.OnPlayerLeaveFamily(curFamily.GetID(), leavePlayerID, tagPlayer)
+    if leavePlayerID in PyGameData.g_autoViceleaderDict.get(curFamily.GetID(),[]):
+        PyGameData.g_autoViceleaderDict[curFamily.GetID()].remove(leavePlayerID)
     return
 
 #//////////////////////////////////////////////////////////////
@@ -1744,7 +1860,6 @@
 def PlayerForceLeaveFamily(curPlayer, tick):
     if curPlayer == None:
         return
-    
     #设置当天加入家族
     GameWorld.GetPlayerManager().SetForbiddenEnterFamily(curPlayer.GetPlayerID(), True)
     # 通知map玩家不能参加家族活动
@@ -1759,6 +1874,8 @@
     
     #弹劾信息封包
     SendPackClientImpeachMsg(curPlayer, 0, 0)
+    PlayerTeam.OnTeamMemFamilyRefresh(curPlayer, 0)
+    
     return
 
 #---------------------------------------------------------------------
@@ -1791,6 +1908,7 @@
 #  @remarks 函数详细说明.
 def PlayerLoginRefreshFamily(curPlayer, tick):
     SyncFakeFamilyInfo(curPlayer)
+    SyncCreatFamilyTimes(curPlayer)
     familyID = curPlayer.GetFamilyID()
     curFamily = None
     
@@ -1861,6 +1979,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
 #---------------------------------------------------------------------
 ## 玩家下线家族刷新逻辑
@@ -2255,6 +2404,7 @@
     #上面已经验证过了,家族肯定存在的
     curFamily = curPlayer.GetFamily()
     curFamilyID = curFamily.GetID()
+    curPlayerID = curPlayer.GetID()
 #    curFamilyTrig = PlayerDBGSEvent.FindDBGSTrig_ByEventID(curFamilyID , PlayerDBGSEvent.Def_Key_RenameFamily)
 #    
 #    if not curFamilyTrig:
@@ -2289,20 +2439,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])
@@ -2464,13 +2614,13 @@
             
         familyMoney = family.GetMoney()
         
-        useMoney = GetFamilySetting(family, ChConfig.Def_FamilySetting_SystemLostMoney)
-        
-        #家族资金不足, 解散
-        if familyMoney < useMoney:
-            family.SetMoney(0)
-            delFamilyList.append(family)
-            continue
+#        useMoney = GetFamilySetting(family, ChConfig.Def_FamilySetting_SystemLostMoney)
+#        
+#        #家族资金不足, 解散
+#        if familyMoney < useMoney:
+#            family.SetMoney(0)
+#            delFamilyList.append(family)
+#            continue
         #多久没人上线,解散
         offlineDay = GetLastOnlineMemberOfflineTime(family)
         GameWorld.DebugLog('    仙盟%s %s天没人上线了'%(family.GetID(), offlineDay))
@@ -2486,12 +2636,10 @@
                                                    ChConfig.Def_Family_ClearRequestAddNote_Day)
         
         #此处不通知地图服务器家族资金变更
-        family.SetMoney(familyMoney - useMoney)
-        if useMoney > 0:
-            #帮会日常维持消耗{%S1%}银两帮会资金
-            PlayerControl.FamilyNotify(family.GetID(), 'jiazu_lhs_272921', [useMoney])
-        #自动传位
-        __AutoChangeLeader(family)
+#        family.SetMoney(familyMoney - useMoney)
+#        if useMoney > 0:
+#            #帮会日常维持消耗{%S1%}银两帮会资金
+#            PlayerControl.FamilyNotify(family.GetID(), 'jiazu_lhs_272921', [useMoney])
         
         #通知客户端刷新
         family.Broadcast_FamilyChange()
@@ -2532,6 +2680,12 @@
         SetFamilyBroadcastCnt(family, 0)
         #清除本周任务已获得资金数量
         SetCurWeekMissionMoney(family, 0)
+        for j in xrange(family.GetCount()):
+            member = family.GetAt(j)
+            #原先是地图玩家上线后重置,导致玩家不上线周贡献显示之前的,固在此重置
+            member.SetFamilyActiveValue(0)
+        
+        
         #通知地图服务器刷新家族属性
         SendPack_MapServer_PlayerFamilyRefresh(family)
         #oss记录上周家族信息
@@ -2542,6 +2696,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
 
 #---------------------------------------------------------------------
 ##通知地图服务器, 玩家家族属性刷新
@@ -2661,16 +2885,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):
@@ -2678,17 +2901,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)
@@ -2698,7 +2918,7 @@
     '''自动传位'''
     # 获得帮主下线了多久(小时)
     leaderOffLineTime = GetLeaderOfflineTime(curFamily)
-    GameWorld.DebugLog('帮主下线了%s小时'%leaderOffLineTime)
+    GameWorld.DebugLog('帮主下线了%s小时'%leaderOffLineTime, curFamily.GetID())
     if leaderOffLineTime < IpyGameDataPY.GetFuncCfg('AutoChangeLeader'):
         return
     
@@ -3301,32 +3521,6 @@
         return ret
     
     return 0
-
-def UpdFamilyWarRank():
-    '''更新仙盟联赛排名
-    注意:该逻辑在仙盟联赛周期中不可执行,仅在下周分组定级状态下可更新
-    仙盟联赛新一周期开始时、仙盟解散时 会触发该逻辑
-    '''
-    gameWorld = GameWorld.GetGameWorld()
-    state = gameWorld.GetDictByKey(ShareDefine.Def_Notify_WorldKey_FBFuncState % ChConfig.Def_FBMapID_FamilyWar)
-    if state != GameWorldFamilyWar.FamilyWarState_NextWeekGroupRank:
-        GameWorld.DebugLog("非下周分组定级阶段不可更新仙盟联赛排名!")
-        return
-    
-    familyMgr = GameWorld.GetFamilyManager()
-    sortFamilyIDList = GetSortFamilyIDList()
-    for rank, familyID in enumerate(sortFamilyIDList, 1):
-        family = familyMgr.FindFamily(familyID)
-        if not family:
-            continue
-        curRank = GetFamilyWarRank(family)
-        if not curRank:
-            break
-        if curRank != rank:
-            SetFamilyWarRank(family, rank)
-            GameWorld.Log("更新仙盟联赛仙盟排名: familyID=%s,rank=%s" % (family.GetID(), rank))
-            
-    return
 
 #// A4 11 一键申请入盟 #tagCGOneKeyJoinFamily
 #

--
Gitblit v1.8.0