|  |  | 
 |  |  |     
 | 
 |  |  |     # 玩家战盟名变更处理
 | 
 |  |  |     __OnFamilyNameChange(jionPlayer.GetPlayerID(), curFamily.GetName())
 | 
 |  |  |      | 
 |  |  |     #玩家缓存
 | 
 |  |  |     PlayerViewCache.OnPlayerFamilyChange(jionPlayer.GetPlayerID(), curFamily.GetID(), curFamily.GetName())
 | 
 |  |  |     #加入仙盟联赛成员
 | 
 |  |  |     GameWorldFamilyWar.AddFamilyWarMem(jionPlayer.GetPlayerID(), curFamily.GetID())
 | 
 |  |  |     GameWorldFamilyWar.CheckPlayerJoinFamilyWarInfo(jionPlayer)
 | 
 |  |  | 
 |  |  |     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:
 | 
 |  |  | 
 |  |  |     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()
 | 
 |  |  | 
 |  |  |     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()  # 家族名字
 | 
 |  |  | 
 |  |  |         if GetFamilyMemberHasPow(tagMember, ChConfig.Def_PurviewDictKey_CanCall):
 | 
 |  |  |             tagPlayer.Sync_FamilyInfo()
 | 
 |  |  |             PlayerFamilyAction.ViewFamilyRequestInfo(tagPlayer)
 | 
 |  |  |      | 
 |  |  |     if isGMOP:
 | 
 |  |  |         curFamily.SetBroadcast('')
 | 
 |  |  |     curFamily.Broadcast_FamilyChange()
 | 
 |  |  |     return True
 | 
 |  |  | #---------------------------------------------------------------------
 | 
 |  |  | 
 |  |  |     # 玩家战盟名变更处理
 | 
 |  |  |     __OnFamilyNameChange(leavePlayerID, '')
 | 
 |  |  |     AddFamilyIDToFightPowerChangeList(curFamily.GetID())
 | 
 |  |  |     PlayerViewCache.OnPlayerLeaveFamily(leavePlayerID)
 | 
 |  |  |     PlayerViewCache.OnPlayerFamilyChange(leavePlayerID, 0, "")
 | 
 |  |  |     return
 | 
 |  |  | 
 | 
 |  |  | #//////////////////////////////////////////////////////////////
 | 
 |  |  | 
 |  |  | #        if useMoney > 0:
 | 
 |  |  | #            #帮会日常维持消耗{%S1%}银两帮会资金
 | 
 |  |  | #            PlayerControl.FamilyNotify(family.GetID(), 'jiazu_lhs_272921', [useMoney])
 | 
 |  |  |         #自动传位
 | 
 |  |  |         __AutoChangeLeader(family)
 | 
 |  |  |         
 | 
 |  |  |         #通知客户端刷新
 | 
 |  |  |         family.Broadcast_FamilyChange()
 | 
 |  |  | 
 |  |  |         SetFamilyBroadcastCnt(family, 0)
 | 
 |  |  |         #清除本周任务已获得资金数量
 | 
 |  |  |         SetCurWeekMissionMoney(family, 0)
 | 
 |  |  |         for j in xrange(family.GetCount()):
 | 
 |  |  |             member = family.GetAt(j)
 | 
 |  |  |             #原先是地图玩家上线后重置,导致玩家不上线周贡献显示之前的,固在此重置
 | 
 |  |  |             member.SetFamilyActiveValue(0)
 | 
 |  |  |          | 
 |  |  |          | 
 |  |  |         #通知地图服务器刷新家族属性
 | 
 |  |  |         SendPack_MapServer_PlayerFamilyRefresh(family)
 | 
 |  |  |         #oss记录上周家族信息
 | 
 |  |  | 
 |  |  |         
 | 
 |  |  |     return
 | 
 |  |  | 
 | 
 |  |  | def FamilyOnHour():
 | 
 |  |  |     familyManager = GameWorld.GetFamilyManager()
 | 
 |  |  |     for i in xrange(familyManager.GetCount()):
 | 
 |  |  |         family = familyManager.GetAt(i)
 | 
 |  |  |         #自动传位
 | 
 |  |  |         __AutoChangeLeader(family)
 | 
 |  |  |     return
 | 
 |  |  | #---------------------------------------------------------------------
 | 
 |  |  | ##通知地图服务器, 玩家家族属性刷新
 | 
 |  |  | # @param curFamily 家族实例
 | 
 |  |  | 
 |  |  |         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):
 | 
 |  |  | 
 |  |  |     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)
 | 
 |  |  | 
 |  |  |     '''自动传位'''
 | 
 |  |  |     # 获得帮主下线了多久(小时)
 | 
 |  |  |     leaderOffLineTime = GetLeaderOfflineTime(curFamily)
 | 
 |  |  |     GameWorld.DebugLog('帮主下线了%s小时'%leaderOffLineTime)
 | 
 |  |  |     GameWorld.DebugLog('帮主下线了%s小时'%leaderOffLineTime, curFamily.GetID())
 | 
 |  |  |     if leaderOffLineTime < IpyGameDataPY.GetFuncCfg('AutoChangeLeader'):
 | 
 |  |  |         return
 | 
 |  |  |     
 | 
 |  |  | 
 |  |  |         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
 | 
 |  |  | #
 |