ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFamily.py
@@ -29,13 +29,17 @@
import DataRecordPack
import PlayerFamilyBoss
import IpyGameDataPY
import PlayerFamilyZhenbaoge
import PlayerFamilyRedPacket
import GameWorldFamilyWar
import ChPyNetSendPack
import NetPackCommon
import PyDataManager
import PyGameData
import PlayerBillboard
import PlayerActBossTrial
import PlayerCompensation
import PlayerFamilyEmblem
import PlayerFamilyParty
import PlayerFamilySWRH
import PlayerViewCache
@@ -73,6 +77,9 @@
    if not family:
        return 0
    return GetFamilyTotalFightPower(family)
# 徽章ID
def GetFamilyEmblemID(curFamily): return curFamily.GetExtra6()
def SetFamilyEmblemID(curFamily, emblemID): return curFamily.SetExtra6(emblemID)
# 公告修改次数
def GetFamilyBroadcastCnt(curFamily): return curFamily.GetExtra3()
@@ -98,6 +105,53 @@
def GetMemberJoinTime(curMember): return curMember.GetExattr4()
def SetMemberJoinTime(curMember, joinTime): return curMember.SetExattr4(joinTime)
#----------------------------------------------------------------------
def OnGameServerInitOK():
    ## 服务器启动成功处理
    DoFamilySort()
    return
def OnMixServerInit():
    ## 合服后首次启动成功处理
    # 仙盟联赛重置
    GameWorldFamilyWar.DoFamilyWarReset()
    # 重置所有仙盟联赛评级
    familyManager = GameWorld.GetFamilyManager()
    for i in xrange(familyManager.GetCount()):
        family = familyManager.GetAt(i)
        SetFamilyWarRank(family, 0)
        # 仙盟榜相关榜单重新上榜
        familyID = family.GetID()
        familyBillInfo = GetFamilyBillboardInfo(family)
        familySubmitTotal = PlayerActBossTrial.GetFamilySubmitTotalByID(familyID)
        PlayerBillboard.UpdateFamilyBillboard(ShareDefine.Def_BT_BossTrialSubmitFamily, familyBillInfo, familySubmitTotal)
    DoFamilySort()
    return
def OnLoadDBPlayerOK():
    ## 服务器启动加载DB玩家成功处理
    # 检查仙盟ServerID
    familyManager = GameWorld.GetFamilyManager()
    for i in xrange(familyManager.GetCount()):
        family = familyManager.GetAt(i)
        if family.GetServerID():
            continue
        familyID = family.GetID()
        # 没有则默认取盟主的
        leaderID = family.GetLeaderID()
        leaderAccID = PlayerControl.GetDBPlayerAccIDByID(leaderID)
        if not leaderAccID:
            continue
        serverID = GameWorld.GetAccIDServerID(leaderAccID)
        family.SetServerID(serverID)
        GameWorld.Log("启动更新仙盟所属服务器ID: familyID=%s,serverID=%s,leaderID=%s,%s" % (familyID, serverID, leaderID, leaderAccID))
    return
def RandomFakeFamily():
    '''随机3个假仙盟'''
@@ -218,7 +272,7 @@
#  @param tick 当前时间
#  @return None
#  @remarks 函数详细说明.
def DoCreateFamily(curPlayer, familyName, fakeIndex, tick):
def DoCreateFamily(curPlayer, familyName, fakeIndex, tick, emblemID=0):
    #---验证玩家属性---
    curPlayerID = curPlayer.GetPlayerID()
@@ -275,11 +329,16 @@
    if curFamily == None:
        GameWorld.ErrLog("家族创建数目已满, 创建家族失败", curPlayerID)
        return
    GameWorld.Log("创建仙盟: familyID=%s,playerID=%s" % (curFamily.GetID(), curPlayerID))
    emblemIDList = PlayerFamilyEmblem.GetDefaultFamilyEmblemIDList()
    if not emblemID or emblemID not in emblemIDList:
        emblemID = random.choice(emblemIDList) # 从默认徽章中随机选择一个
    GameWorld.Log("创建仙盟: familyID=%s,playerID=%s,emblemID=%s" % (curFamily.GetID(), curPlayerID, emblemID))
    #---创建家族---
    curFamily.SetServerID(GameWorld.GetAccIDServerID(curPlayer.GetAccID()))
    curFamily.SetCreateTime(GameWorld.GetCurrentDataTimeStr())
    curFamily.SetLV(1)
    curFamily.SetAcceptJoin(ShareDefine.FamilyAcceptJoin_Agree)     #设置收人方式为直接通过申请
    SetFamilyEmblemID(curFamily, emblemID)
    PyDataManager.GetFamilyStoreItemManager().DelFamilyStoreItemAll(curFamily.GetID())
    
    #新创建的仙盟默认设置已处理过合服
@@ -296,6 +355,8 @@
    if fakeIndex and fakeIndex in fakeIndexList:
        PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_FakeFamilyIndex % fakeIndexList.index(fakeIndex), 0)
        GameWorld.Log('    创建前n个假仙盟不扣钱! 假仙盟索引%s'%fakeIndexList.index(fakeIndex))
        fakeAwardItemList = IpyGameDataPY.GetFuncEvalCfg("FakeFamilyName", 3)
        PlayerCompensation.SendMailByKey("FackFamilyNotice", [curPlayerID], fakeAwardItemList)
    elif creatFamilyTimes < IpyGameDataPY.GetFuncCfg('CreateFamilyNeedMoney', 3):
        GameWorld.Log('    创建前n个仙盟不扣钱! creatFamilyTimes=%s' % creatFamilyTimes)
    else:
@@ -343,6 +404,8 @@
    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()])
    PlayerFamilyZhenbaoge.OnZhenbaogeReset(curFamily)
    return
## 获取家族全名
@@ -416,8 +479,8 @@
    #通知战盟红包信息
    PlayerFamilyRedPacket.NotifyRedPacketInfo(jionPlayer)
    
    #通知战盟BOSS开启信息
    PlayerFamilyBoss.NotifyFamilyBossFBInfo(jionPlayer)
    #通知战盟BOSS
    PlayerFamilyBoss.OnPlayerJionFamily(curFamily, jionPlayer)
    #通知家族仓库
    PyDataManager.GetFamilyStoreItemManager().SyncFamilyStoreItem(jionPlayer, curFamily.GetID())
    #仙盟拍品
@@ -542,6 +605,7 @@
#    tagHead        Head;
#    char        Name[33];
#    WORD        FakeID;
#    BYTE        EmblemID; //选择徽章ID,解锁仙盟等级为1级的均为可选ID
#};
## 查看申请帮会的成员信息
#  @param index 玩家索引
@@ -552,8 +616,9 @@
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    inputName = clientPack.Name
    fakeIndex = clientPack.FakeID
    emblemID = clientPack.EmblemID
    #执行创建家族逻辑
    DoCreateFamily(curPlayer, inputName, fakeIndex, tick)
    DoCreateFamily(curPlayer, inputName, fakeIndex, tick, emblemID)
    #重置查看家族状态(仅创建家族时候重置, 其余状态由MapServer退出事件时重置)
    __ClearViewFamilyState(curPlayer)
    #玩家离开事件
@@ -689,6 +754,7 @@
    totalFightPower = GetFamilyTotalFightPower(family)
    familyView.TotalFightPower = totalFightPower % ChConfig.Def_PerPointValue
    familyView.TotalFightPowerEx = totalFightPower / ChConfig.Def_PerPointValue
    familyView.EmblemID = GetFamilyEmblemID(family)
    return familyView
## 玩家模糊查询家族,0F 0D封包
@@ -769,6 +835,19 @@
            break
    familyViewPack.PageCount = len(familyViewPack.Family)
    NetPackCommon.SendFakePack(curPlayer, familyViewPack)
    return
#// A4 13 修改家族徽章 #tagCGChangeFamilyEmblem
#
#struct    tagCGChangeFamilyEmblem
#{
#    tagHead        Head;
#    BYTE        EmblemID;    // 更换的徽章ID
#};
def OnChangeFamilyEmblem(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    changeEmblemID = clientData.EmblemID
    PlayerFamilyEmblem.OnChangeFamilyEmblem(curPlayer, changeEmblemID)
    return
#class   IPY_CFamilyChangeBroadcast
@@ -1613,6 +1692,7 @@
#  @param leavePlayerID 离开的玩家ID
#  @return None
def __DoPlayerLeaveFamilyByID(curFamily, leavePlayerID, tagPlayer=None):
    PlayerCompensation.SendMailByKey("LeaveFamilyNotice", [leavePlayerID], [])
    PlayerFamilyAction.DelFamilyOfficerModelEquip(curFamily.GetID(), leavePlayerID)
    # 玩家战盟名变更处理
    __OnFamilyNameChange(leavePlayerID, '')
@@ -2078,6 +2158,8 @@
    curMember.SetJob(curPlayer.GetJob())
    curMember.SetOperateInfo(curPlayer.GetOperateInfo())
    curMember.SetOfficialRank(curPlayer.GetOfficialRank())
    curMember.SetFace(curPlayer.GetFace())
    curMember.SetFacePic(curPlayer.GetFacePic())
    return
#---------------------------------------------------------------------
## 玩家刷新
@@ -2686,6 +2768,15 @@
    __SetFamilyActivityDayStateValue(0)
    return
def FamilyOnDayEx(tick):
    familyManager = GameWorld.GetFamilyManager()
    for i in range(0, familyManager.GetCount()):
        family = familyManager.GetAt(i)
        #仙盟boss
        PlayerFamilyBoss.FamilyBossFBOnDayEx(family)
        #珍宝阁
        PlayerFamilyZhenbaoge.OnDayEx(family)
    return
#---------------------------------------------------------------------
##家族过周
@@ -2720,7 +2811,7 @@
        DataRecordPack.DR_FamilyActiveValueByOnWeek(familyID, family.GetName(), familyActiveValue)
        
        #清除家族boss副本信息
        PlayerFamilyBoss.FamilyBossFBOnWeek(familyID)
        PlayerFamilyBoss.FamilyBossFBOnWeek(family)
        
    return
@@ -2838,7 +2929,7 @@
        GameWorld.ErrLog("key = %s not in tagFamily.txt" % familyLv)
        return 0
    keyStr = ChConfig.FamilySettingDict[index]
    return getattr(curFamilyLvSetting, keyStr)
    return getattr(curFamilyLvSetting, "Get%s" % keyStr)()
#===============================================================================
@@ -3332,17 +3423,6 @@
    PlayerFamilyAction.ViewFamilyRequestInfo(curPlayer)
    return
## 开启家族boss副本
#  @param index 玩家索引
#  @param clientData 封包数据结构体
#  @param tick 时间戳
#  @return None
def OpenFamilyBossFB(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    fbMapID = clientData.MapID
    PlayerFamilyBoss.OpenFamilyBossFB(curPlayer, tick)
    return
#===============================================================================
# //A4 06 变更家族成员加入审核方式#tagCGChangeFamilyAcceptJoinType
#struct tagCGChangeFamilyAcceptJoinType
@@ -3620,3 +3700,113 @@
        
    PlayerControl.NotifyCode(curPlayer, "jiazu_pan_500807")
    return
##--------------------------------------- 仙盟传功 --------------------------------------------------
def MapServer_FamilyChuangong(curPlayer, msgList):
    msgType, msgData = msgList
    if msgType == "Invite":
        tagPlayerID = msgData[0]
        __DoChuangong_Invite(curPlayer, tagPlayerID)
        return
    if msgType == "Response":
        tagPlayerID, isOK = msgData
        __DoChuangong_Response(curPlayer, tagPlayerID, isOK)
        return
    return
def __CheckChuangongPlayer(curPlayer, tagPlayerID):
    curFamily = curPlayer.GetFamily()
    if not curFamily:
        return
    tagMember = curFamily.FindMember(tagPlayerID)
    if not tagMember:
        GameWorld.DebugLog("非盟友无法传功! tagPlayerID=%s" % tagPlayerID, curPlayer.GetPlayerID())
        return
    tagPlayer = tagMember.GetPlayer()
    if not tagPlayer:
        PlayerControl.NotifyCode(curPlayer, "FairyFeastPlayerOffline")
        return
    return tagPlayer
def __DoChuangong_Invite(curPlayer, tagPlayerID):
    ## 邀请
    playerID = curPlayer.GetPlayerID()
    tagPlayer = __CheckChuangongPlayer(curPlayer, tagPlayerID)
    if not tagPlayer:
        return
    invitePlayerIDList = PyGameData.g_chuangongPlayerDict.get(playerID, [])
    if tagPlayerID not in invitePlayerIDList:
        invitePlayerIDList.append(tagPlayerID)
        PyGameData.g_chuangongPlayerDict[playerID] = invitePlayerIDList
    clientPack = ChPyNetSendPack.tagGCChuangongInviteInfo()
    clientPack.Clear()
    clientPack.PlayerID = curPlayer.GetPlayerID()
    clientPack.Name = curPlayer.GetName()
    clientPack.NameLen = len(clientPack.Name)
    clientPack.LV = curPlayer.GetLV()
    clientPack.Job = curPlayer.GetJob()
    clientPack.RealmLV = curPlayer.GetOfficialRank()
    clientPack.Face = curPlayer.GetFace()
    clientPack.FacePic = curPlayer.GetFacePic()
    NetPackCommon.SendFakePack(tagPlayer, clientPack)
    GameWorld.DebugLog("邀请传功: tagPlayerID=%s, %s" % (tagPlayerID, PyGameData.g_chuangongPlayerDict), playerID)
    return
def __DoChuangong_Response(curPlayer, tagPlayerID, isOK):
    ## 相应
    playerID = curPlayer.GetPlayerID()
    tagPlayer = __CheckChuangongPlayer(curPlayer, tagPlayerID)
    if not tagPlayer:
        return
    invitePlayerIDList = PyGameData.g_chuangongPlayerDict.get(tagPlayerID, [])
    if not isOK:
        if playerID in invitePlayerIDList:
            invitePlayerIDList.remove(playerID)
            PyGameData.g_chuangongPlayerDict[tagPlayerID] = invitePlayerIDList
        GameWorld.DebugLog("拒绝传功: tagPlayerID=%s, %s" % (tagPlayerID, PyGameData.g_chuangongPlayerDict), playerID)
        return
    if not invitePlayerIDList:
        PlayerControl.NotifyCode(curPlayer, "TagHadFinishChuangong")
        return
    if playerID not in invitePlayerIDList:
        GameWorld.DebugLog("不在对方邀请列表了,无法传功: tagPlayerID=%s, %s" % (tagPlayerID, invitePlayerIDList), playerID)
        return
    PyGameData.g_chuangongPlayerDict.pop(tagPlayerID)
    # 通知双方开始传功
    __NotifyChuangongStart(curPlayer, tagPlayer)
    __NotifyChuangongStart(tagPlayer, curPlayer)
    return
def __NotifyChuangongStart(curPlayer, tagPlayer):
    clientPack = ChPyNetSendPack.tagGCChuangongStart()
    clientPack.Clear()
    clientPack.PlayerID = tagPlayer.GetPlayerID()
    clientPack.Name = tagPlayer.GetName()
    clientPack.NameLen = len(clientPack.Name)
    clientPack.LV = tagPlayer.GetLV()
    clientPack.Job = tagPlayer.GetJob()
    clientPack.RealmLV = tagPlayer.GetOfficialRank()
    NetPackCommon.SendFakePack(curPlayer, clientPack)
    return
##--------------------------------------------------------------------------------------------------
def GetFamilyBillboardInfo(curFamily):
    ## 获取仙盟榜单信息 区服ID、徽章、仙盟名、盟主名、仙盟总战力、仙盟等级
    familyID = curFamily.GetID()
    name = curFamily.GetName()
    id2 = curFamily.GetLeaderID()
    name2 = curFamily.GetLeaderName()
    fightPower = GetFamilyTotalFightPower(curFamily)
    value1 = fightPower / ChConfig.Def_PerPointValue
    value2 = fightPower % ChConfig.Def_PerPointValue
    value3 = GetFamilyEmblemID(curFamily)
    value4 = curFamily.GetLV()
    value5 = curFamily.GetServerID()
    return {"id":familyID, "name":name, "id2":id2, "name2":name2, "value1":value1, "value2":value2,
            "value3":value3, "value4":value4, "value5":value5}