ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerFamily.py
@@ -30,7 +30,6 @@
import IPY_GameWorld
import ItemControler
import GameFuncComm
import ItemCommon
import DBDataMgr
import DirtyList
import ObjPool
@@ -156,6 +155,7 @@
    curMember.SetOffTime(0) # 在线0,脱机1,>1离线时间
    curMember.RefreshMember(curPlayer)
    Sync_FamilyInfo(curPlayer)
    SendFamilyActionInfo(curPlayer, familyID, ShareDefine.Def_ActionType_FamilyData)
    
    #通知招人
    if GetFamilyMemberHasPow(curMember, FamilyPowerID_Call):
@@ -195,6 +195,13 @@
        return
    member.RefreshMember(curPlayer)
    return
def GetRenameTime(dataAction): return dataAction.GetValue1()
def SetRenameTime(dataAction, setTime): dataAction.SetValue1(setTime)
def GetFamilyDataAction(familyID):
    ## 家族额外数据存储的行为数据,可以视为Family公共数据的一个扩展
    action = DBDataMgr.GetFamilyActionMgr().GetFamilyAction(familyID, ShareDefine.Def_ActionType_FamilyData)
    return action.GetOneAction(True)
#// A6 04 创建家族 #tagCMCreateFamily
#
@@ -387,9 +394,10 @@
            setFunc(value)
    return True
def MapServer_FamilyRefresh(curPlayer, refreshFamilyID):
def MapServer_FamilyRefresh(curPlayer, refreshFamilyID, isVoluntarily=0):
    ''' 相当于GameServer调用 curPlayer.MapServer_FamilyRefresh()
    @param familyID: 玩家更新的familyID
    @param isVoluntarily: 是否自愿离开的,仅离开刷新时有效
    '''
    
    tick = GameWorld.GetGameWorld().GetTick()
@@ -436,7 +444,7 @@
        
    if lastFamilyID != 0 and curPlayer.GetFamilyID() == 0:
        #玩家离开家族
        __OnLeaveFamily(curPlayer, tick)
        __OnLeaveFamily(curPlayer, isVoluntarily, tick)
        
    elif lastFamilyID == 0 and curPlayer.GetFamilyID() != 0:
        #刚进家族并为族长,触发建家族事件
@@ -457,7 +465,7 @@
    Sync_RequestAddFamilyInfo(curPlayer)
    return
def __OnLeaveFamily(curPlayer, tick):
def __OnLeaveFamily(curPlayer, isVoluntarily, tick):
    ## 退出家族触发事件
    #---清空家族相关信息---
    curPlayer.SetPerExp(0)
@@ -466,7 +474,29 @@
    curPlayer.SetLastWeekFamilyActiveValue(0)
    curPlayer.SetFamilyLV(0)
    PlayerControl.SetLeaveFamilyTimeEx(curPlayer, int(time.time()))
    leaveCnt, kickedCnt, _ = PlayerControl.GetLeaveFamilyInfo(curPlayer)
    GameWorld.DebugLog("__OnLeaveFamily: isVoluntarily=%s,leaveCnt=%s,kickedCnt=%s" % (isVoluntarily, leaveCnt, kickedCnt))
    delMoneyType, delMoneyPer = IpyGameDataPY.GetFuncCfg("FamilyLeave", 3), 0
    if isVoluntarily:
        delMoneyPerList = IpyGameDataPY.GetFuncEvalCfg("FamilyLeave", 4)
        if delMoneyPerList:
            delMoneyPer = delMoneyPerList[leaveCnt] if len(delMoneyPerList) > leaveCnt else delMoneyPerList[-1]
        leaveCnt += 1
        GameWorld.DebugLog("    增加主动离开次数: leaveCnt=%s" % (leaveCnt))
    else:
        delMoneyPerList = IpyGameDataPY.GetFuncEvalCfg("FamilyLeave", 5)
        if delMoneyPerList:
            delMoneyPer = delMoneyPerList[kickedCnt] if len(delMoneyPerList) > kickedCnt else delMoneyPerList[-1]
        kickedCnt += 1
        GameWorld.DebugLog("    增加被踢离开次数: kickedCnt=%s" % (kickedCnt))
    PlayerControl.SetLeaveFamilyInfo(curPlayer, leaveCnt, kickedCnt, isVoluntarily)
    if delMoneyType and delMoneyPer:
        nowMoney = PlayerControl.GetMoney(curPlayer, delMoneyType)
        delMoney = int(nowMoney * delMoneyPer / 100.0)
        GameWorld.DebugLog("    扣除货币: delMoneyType=%s,delMoneyPer=%s,nowMoney=%s,delMoney=%s" % (delMoneyType, delMoneyPer, nowMoney, delMoney))
        PlayerControl.PayMoney(curPlayer, delMoneyType, delMoney, "LeaveFamily")
    FBLogic.OnLeaveFamily(curPlayer, tick)
    return
@@ -638,12 +668,43 @@
        
    return
def CheckInJoinCD(curPlayer):
    ## 检查是否加入仙盟CD中
    leaveFamilyTime = PlayerControl.GetLeaveFamilyTimeEx(curPlayer)
    if not leaveFamilyTime:
        return False
    leaveCnt, kickedCnt, lastVoluntarily = PlayerControl.GetLeaveFamilyInfo(curPlayer)
    joinCDMinute = 0
    if lastVoluntarily:
        if leaveCnt <= 0:
            return False
        joinCDMinuteList = IpyGameDataPY.GetFuncEvalCfg("FamilyLeave", 1)
        if joinCDMinuteList:
            joinCDMinute = joinCDMinuteList[leaveCnt - 1] if len(joinCDMinuteList) >= leaveCnt else joinCDMinuteList[-1]
    else:
        if kickedCnt <= 0:
            return False
        joinCDMinuteList = IpyGameDataPY.GetFuncEvalCfg("FamilyLeave", 2)
        if joinCDMinuteList:
            joinCDMinute = joinCDMinuteList[kickedCnt - 1] if len(joinCDMinuteList) >= kickedCnt else joinCDMinuteList[-1]
    if joinCDMinute:
        cdTimes = joinCDMinute * 60
        passTimes = int(time.time()) - leaveFamilyTime
        if passTimes < cdTimes:
            GameWorld.DebugLog("加入仙盟CD中: leaveCnt=%s,kickedCnt=%s,lastVoluntarily=%s,leaveFamilyTime=%s(%s),passTimes=%s < %s"
                   % (leaveCnt, kickedCnt, lastVoluntarily, leaveFamilyTime, GameWorld.ChangeTimeNumToStr(leaveFamilyTime), passTimes, cdTimes))
            return True
    return False
def AutoJoinFamily(curPlayer):
    if curPlayer.GetFamilyID():
        return
    playerID = curPlayer.GetPlayerID()
    playerLV = curPlayer.GetLV()
    GameWorld.DebugLog("玩家一键自动加入家族! playerLV=%s" % playerLV, playerID)
    realmLV = curPlayer.GetOfficialRank()
    GameWorld.DebugLog("玩家一键自动加入家族! realmLV=%s" % realmLV, playerID)
    if CheckInJoinCD(curPlayer):
        return
    
    familyMgr = DBDataMgr.GetFamilyMgr()
    indexList = range(familyMgr.GetCount())
@@ -654,8 +715,8 @@
            continue
        familyID = family.GetID()
        lvMin = family.GetJoinLVMin()
        if lvMin and playerLV < lvMin:
            GameWorld.DebugLog("    等级不足的不处理! familyID=%s,lvMin=%s" % (familyID, lvMin), playerID)
        if lvMin and realmLV < lvMin:
            GameWorld.DebugLog("    官职不足的不处理! familyID=%s,lvMin=%s" % (familyID, lvMin), playerID)
            continue
        if family.GetJoinReview():
            GameWorld.DebugLog("    需要审核的不处理! familyID=%s" % familyID, playerID)
@@ -687,6 +748,8 @@
def RequestJoinTagFamily(curPlayer, familyID):
    ## 申请加入
    if CheckInJoinCD(curPlayer):
        return
    playerID = curPlayer.GetPlayerID()
    if curPlayer.GetFamilyID():
        GameWorld.DebugLog('已经有仙盟不能再申请加入! familyID=%s' % curPlayer.GetFamilyID(), playerID)
@@ -707,8 +770,8 @@
        return
    
    lvMin = tagFamily.GetJoinLVMin()
    if curPlayer.GetLV() < lvMin:
        GameWorld.DebugLog('等级未达到该仙盟加入最低等级限制! lv=%s < %s' % (curPlayer.GetLV(), lvMin), playerID)
    if curPlayer.GetOfficialRank() < lvMin:
        GameWorld.DebugLog('官职未达到该仙盟加入最低限制! realmLV=%s < %s' % (curPlayer.GetOfficialRank(), lvMin), playerID)
        return
    
    # 需要审核,满员后端不限制申请,由前端自行决定是否可申请
@@ -905,7 +968,7 @@
def OnChangeFamilyJoin(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    joinReview = clientData.JoinReview
    joinLVMin = clientData.JoinLVMin
    joinLVMin = clientData.JoinLVMin # 官职
    
    playerID = curPlayer.GetPlayerID()
    familyID = curPlayer.GetFamilyID()
@@ -1157,7 +1220,7 @@
    #XW_JZ_LeaveFamily   <n color="0,190,255">{%S1%}</n><n color="255,255,0">退出了家族!</n>  25  -   -
    NotifyAllFamilyMemberMsg(familyID, "XW_JZ_LeaveFamily", [curPlayer.GetName()])
    
    MapServer_FamilyRefresh(curPlayer, 0)
    MapServer_FamilyRefresh(curPlayer, 0, 1)
    
    if family.GetCount() == 0:
        #玩家离开后, 家族没有人了 , 删除这个家族
@@ -1240,7 +1303,7 @@
def UpdateFamilyName(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    newName = clientData.NewName
    itemIndex = clientData.ItemIndex
    #itemIndex = clientData.ItemIndex
    
    playerID = curPlayer.GetPlayerID()
    familyID = curPlayer.GetFamilyID()
@@ -1258,18 +1321,24 @@
        GameWorld.DebugLog("非盟主不可改名!", playerID)
        return
    
    cdHours = IpyGameDataPY.GetFuncCfg("FamilyRename", 2)
    if cdHours:
        cdSeconds = cdHours * 3600
        curTime = int(time.time())
        dataAction = GetFamilyDataAction(familyID)
        lastRenameTime = GetRenameTime(dataAction)
        if lastRenameTime and (curTime - lastRenameTime) < cdSeconds:
            GameWorld.DebugLog("仙盟改名CD中! lastRenameTime=%s,cdHours=%s" % (GameWorld.ChangeTimeNumToStr(lastRenameTime), cdHours))
            return
    familyName = CheckInputFamilyName(curPlayer, newName)
    if not familyName:
        return
    
    itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
    curItem = itemPack.GetAt(itemIndex)
    if not ItemCommon.CheckItemCanUse(curItem) or curItem.GetType() != ChConfig.Def_ItemType_ChangeFamilyName:
        GameWorld.DebugLog("没有仙盟改名道具! itemIndex=%s" % itemIndex, playerID)
    moneyType, moneyValue = IpyGameDataPY.GetFuncEvalCfg("FamilyRename", 1)
    if moneyType and moneyValue and not PlayerControl.PayMoney(curPlayer, moneyType, moneyValue, "FamilyRename"):
        return
    ItemCommon.DelItem(curPlayer, curItem, 1, True, 'UpdateFamilyName')
    
    #oldName = curFamily.GetName()
    family.SetName(familyName)
    
    infoPack = GetPack_FamilyInfo(familyID)
@@ -1282,10 +1351,11 @@
            continue
        Sync_FamilyInfo(player, infoPack)
        player.SetFamilyName(familyName)
        player.Notify_FamilyNameRefresh() #//04 36    周围玩家家族名刷新#tagPlayerFamilyNameRefresh
        #player.Notify_FamilyNameRefresh() #//04 36    周围玩家家族名刷新#tagPlayerFamilyNameRefresh
        
    #PlayerCompensation.SendMailByKey('FamilyNameChange', memberIDList, [], [oldName, familyName])
    #PlayerControl.WorldNotify(0, 'Family_ChangeName', [oldName, familyName])
    if cdHours:
        SetRenameTime(dataAction, curTime)
        SendFamilyActionInfo(None, familyID, ShareDefine.Def_ActionType_FamilyData)
    return
#// A6 20 搜索家族列表 #tagCMViewFamilyPage
@@ -1341,6 +1411,7 @@
            else:
                continue
        familyView = ChPyNetSendPack.tagMCFamilyView()
        familyView.Rank = index + 1
        familyView.FamilyID = family.GetID()
        familyView.FamilyName = family.GetName()
        familyView.FamilyNameLen = len(familyView.FamilyName)