ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerFamilyTaofa.py
@@ -24,6 +24,7 @@
import ItemControler
import PlayerControl
import PlayerFamily
import CrossPlayer
import GameWorld
import DBDataMgr
@@ -64,34 +65,15 @@
#UserDict {"atkList":[[atkTime, 本次贡献箱子数, 本次总伤害, atkType], ...], ...}
#atkList = actionData.GetUserDict().get("atkList", [])
#actionData.GetUserDict().update({"atkList":atkList})
#UserDict 存储的key定义
UserKey_AtkList = "atkList" # 攻击记录
UserKey_Info = "info" # 离开玩家基本信息
AtkType_Normal = 0 # 常规斩杀
AtkType_Anger = 1 # 怒气斩杀
def OnDay(family):
    OnTaofaReset(family)     
    return
def PlayerOnDay(curPlayer):
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaCnt, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaItemAddCnt, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBuZhenState, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaAnger, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxUnGetCnt, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxTotalGetCnt, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxLastTime, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxContribCnt, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxHurt, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxHurtEx, 0)
    SyncTaofaInfo(curPlayer)
    return
def OnPlayerLogin(curPlayer):
    familyID = curPlayer.GetFamilyID()
    curFamily = DBDataMgr.GetFamilyMgr().FindFamily(familyID)
    RefreshPlayerAwardBoxCnt(curFamily, curPlayer, unSyncIDList=[curPlayer.GetPlayerID()])
    SyncTaofaInfo(curPlayer)
    PlayerFamily.SendFamilyActionInfo(curPlayer, familyID, ActionType)
    return
def OnTaofaReset(family):
@@ -105,172 +87,35 @@
    PlayerFamily.SendFamilyAction(gActionData)
    return
def OnTaofaResetPlayer(curPlayer):
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaCnt, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaItemAddCnt, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBuZhenState, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaAnger, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxUnGetCnt, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxTotalGetCnt, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxLastTime, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxContribCnt, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxHurt, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxHurtEx, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxHurtHis, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxHurtHisEx, 0)
    SyncTaofaInfo(curPlayer)
def OnCrossPlayerLogin(crossPlayer):
    familyID = crossPlayer.GetFamilyID()
    if not familyID:
        return
    curFamily = DBDataMgr.GetFamilyMgr().FindFamily(familyID)
    if not curFamily:
        return
    playerID = crossPlayer.GetPlayerID()
    PlayerFamily.SendFamilyActionInfo(crossPlayer, familyID, ActionType)
    memContribDict = GetMemContriBoxInfo(curFamily)
    if memContribDict:
        SyncMemContribInfo(curFamily, [playerID])
    return
def OnFamilyMemberLeave(family, leavePlayerID, leavePlayer=None):
def OnCrossPlayerEnterFamily(crossPlayer):
    ## 玩家进入新公会
    familyID = crossPlayer.GetFamilyID()
    PlayerFamily.SendFamilyActionInfo(crossPlayer, familyID, ActionType)
    return
def OnFamilyMemberLeave(family, leavePlayerID):
    ## 公会成员删除,针对公会的处理
    familyAction = DBDataMgr.GetFamilyActionMgr().GetFamilyAction(family.GetID(), ActionType)
    actionData = familyAction.GetActionDataByValue1(leavePlayerID, False)
    if not actionData:
        return
    memInfo = PlayerViewCache.GetPlayerBaseViewInfo(leavePlayerID, leavePlayer)
    actionData.GetUserDict().update({"info":memInfo})
    memInfo = PlayerViewCache.GetPlayerBaseViewInfo(leavePlayerID)
    actionData.GetUserDict().update({UserKey_Info:memInfo})
    PlayerFamily.SendFamilyAction([actionData])
    return
def OnPlayerLeaveFamily(curPlayer):
    ## 玩家退出了公会,针对玩家个人的处理
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaAnger, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxUnGetCnt, 0)
    SyncTaofaInfo(curPlayer)
    return
def OnPlayerEnterFamily(curPlayer):
    ## 玩家进入新公会
    familyID = curPlayer.GetFamilyID()
    PlayerFamily.SendFamilyActionInfo(curPlayer, familyID, ActionType)
    return
def RefreshFamilyBuZhenInfo(family):
    ## 刷新公会公共布阵信息
    familyID = family.GetID()
    curTime = int(time.time())
    bzDuration = IpyGameDataPY.GetFuncCfg("FamilyTaofaBuzhen", 4) * 60 # 有效时长秒
    maxLayer = IpyGameDataPY.GetFuncCfg("FamilyTaofaBuzhen", 3)
    gLayer = 0
    gEndTime = 0
    gActionData = None
    familyAction = DBDataMgr.GetFamilyActionMgr().GetFamilyAction(familyID, ActionType)
    for index in range(0, familyAction.Count()):
        actionData = familyAction.At(index)
        dataID = GetFAPlayerID(actionData)
        if dataID == ActionGlobalID:
            gActionData = actionData
            continue
        bzTime = GetFABuzhenTime(actionData)
        if not bzTime:
            continue
        endTime = bzTime + bzDuration
        if endTime <= curTime:
            continue
        if not maxLayer or gLayer < maxLayer:
            gLayer += 1
        if gEndTime < endTime:
            gEndTime = endTime
    GameWorld.DebugLog("刷新公会公共布阵信息: familyID=%s,gLayer=%s,gEndTime=%s" % (familyID, gLayer, GameWorld.ChangeTimeNumToStr(gEndTime)))
    if not gActionData:
        gActionData = familyAction.AddAction()
        SetFAPlayerID(gActionData, ActionGlobalID)
    SetFABuzhenEndTime(gActionData, gEndTime)
    SetFABuzhenLayer(gActionData, gLayer)
    PlayerFamily.SendFamilyAction(gActionData)
    return
def RefreshPlayerAwardBoxCnt(family, curPlayer=None, unSyncIDList=[]):
    ## 刷新玩家可领取的宝箱数
    # @param curPlayer: None时刷新所有成员
    if not family:
        return
    familyID = family.GetID()
    memContribDict = {}
    familyAction = DBDataMgr.GetFamilyActionMgr().GetFamilyAction(familyID, ActionType)
    for index in range(0, familyAction.Count()):
        actionData = familyAction.At(index)
        memID = GetFAPlayerID(actionData)
        if memID == ActionGlobalID:
            continue
        contribList = []
        atkList = actionData.GetUserDict().get("atkList", [])
        for atkInfo in atkList:
            atkTime = atkInfo[AtkIndex_AtkTime]
            contribBoxCnt = atkInfo[AtkIndex_ContribBoxCnt]
            if contribBoxCnt > 0:
                contribList.append([atkTime, contribBoxCnt])
        if contribList:
            memContribDict[memID] = contribList
    awardBoxMax = IpyGameDataPY.GetFuncCfg("FamilyTaofaBox", 3)
    GameWorld.DebugLog("刷新公会成员可领取的宝箱数: familyID=%s,memContribDict=%s" % (familyID, memContribDict))
    if curPlayer:
        member = family.FindMember(curPlayer.GetPlayerID())
        if not member:
            return
        __doUpdPlayerAwardBoxCnt(curPlayer, member, memContribDict, awardBoxMax, unSyncIDList)
        return
    playerManager = GameWorld.GetPlayerManager()
    for index in xrange(family.GetCount()):
        member = family.GetAt(index)
        playerID = member.GetPlayerID()
        curPlayer = playerManager.FindPlayerByID(playerID)
        if not curPlayer:
            continue
        __doUpdPlayerAwardBoxCnt(curPlayer, member, memContribDict, awardBoxMax, unSyncIDList)
    return
def __doUpdPlayerAwardBoxCnt(curPlayer, member, memContribDict, awardBoxMax, unSyncIDList):
    playerID = curPlayer.GetPlayerID()
    joinTime = member.GetJoinTime()
    boxLastTime = max(curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTaofaBoxLastTime), joinTime) # 与加入时间取最大
    boxTotalGetCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTaofaBoxTotalGetCnt) # 已领取宝箱数
    boxUnGetCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTaofaBoxUnGetCnt) # 未领取宝箱数
    canAddBoxMax = awardBoxMax - boxTotalGetCnt - boxUnGetCnt # 还可领取的箱子数
    if canAddBoxMax <= 0:
        GameWorld.DebugLog("    成员可领取宝箱已达上限不刷新: playerID=%s,boxLastTime=%s,boxTotalGetCnt(%s)+boxUnGetCnt(%s) >= %s"
                           % (playerID, boxLastTime, boxTotalGetCnt, boxUnGetCnt, awardBoxMax))
        return
    updBoxLastTime = boxLastTime
    addUnGetBox = 0
    for contribList in memContribDict.values():
        if addUnGetBox >= canAddBoxMax:
            break
        for atkTime, contribBoxCnt in contribList:
            if boxLastTime >= atkTime:
                continue
            updBoxLastTime = max(updBoxLastTime, atkTime)
            addUnGetBox += contribBoxCnt
            if addUnGetBox >= canAddBoxMax:
                break
    if addUnGetBox <= 0:
        GameWorld.DebugLog("    成员当前没有可领取的宝箱不刷新: playerID=%s,boxLastTime=%s,boxTotalGetCnt=%s,boxUnGetCnt=%s,awardBoxMax=%s,canAddBoxMax=%s"
                           % (playerID, boxLastTime, boxTotalGetCnt, boxUnGetCnt, awardBoxMax, canAddBoxMax))
        return
    updBoxUnGetCnt = boxUnGetCnt + addUnGetBox
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxUnGetCnt, updBoxUnGetCnt)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxLastTime, updBoxLastTime)
    GameWorld.DebugLog("    成员可领取的宝箱数: playerID=%s,addUnGetBox=%s,updBoxUnGetCnt=%s,updBoxLastTime=%s,boxLastTime=%s,boxTotalGetCnt=%s,boxUnGetCnt=%s,awardBoxMax=%s,canAddBoxMax=%s"
                       % (playerID, addUnGetBox, updBoxUnGetCnt, updBoxLastTime, boxLastTime, boxTotalGetCnt, boxUnGetCnt, awardBoxMax, canAddBoxMax))
    if not unSyncIDList or playerID not in unSyncIDList:
        SyncTaofaInfo(curPlayer)
    return
def AddTaofaCntByItem(curPlayer, addCnt):
    ## 物品增加副本次数
    itemAddCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTaofaItemAddCnt)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaItemAddCnt, itemAddCnt + addCnt)
    SyncTaofaInfo(curPlayer)
    return
#// A6 13 公会讨伐 #tagCSFamilyTaofaOP
@@ -287,46 +132,73 @@
    familyID = curPlayer.GetFamilyID()
    if not familyID:
        GameWorld.DebugLog("没有仙盟无法操作!", playerID)
        return
        return
    reqDataEx = {}
    # 布阵
    if opType == 1:
        __doBuzhen(curPlayer)
        if curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTaofaBuZhenState):
            GameWorld.DebugLog("已布阵过!", playerID)
            return
    # նɱ
    else:
        __doZhanshaAtk(curPlayer)
        _, _, maxAnger = IpyGameDataPY.GetFuncEvalCfg("FamilyTaofaAtk", 4)
        anger = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTaofaAnger)
        atkType = AtkType_Anger if anger >= maxAnger else AtkType_Normal
        atkCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTaofaCnt)
        if atkType == AtkType_Normal:
            itemAddCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTaofaItemAddCnt)
            freeCnt = IpyGameDataPY.GetFuncCfg("FamilyTaofaAtk", 1)
            canAtkCnt = freeCnt + itemAddCnt - atkCnt
            if canAtkCnt <= 0:
                GameWorld.DebugLog("公会讨伐没有斩杀次数: atkCnt=%s >= freeCnt(%s) + itemAddCnt(%s)" % (atkCnt, freeCnt, itemAddCnt), playerID)
                return
        fightPower = PlayerControl.GetFightPower(curPlayer)
        boxContribCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTaofaBoxContribCnt)
        boxHurt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTaofaBoxHurt)
        boxHurtEx = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTaofaBoxHurtEx)
        boxHurtTotal = boxHurt + boxHurtEx * ChConfig.Def_PerPointValue
        boxHurtHis = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTaofaBoxHurtHis)
        boxHurtHisEx = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTaofaBoxHurtHisEx)
        boxHurtTotalHis = boxHurtHis + boxHurtHisEx * ChConfig.Def_PerPointValue
        reqDataEx = {"anger":anger, "atkType":atkType, "atkCnt":atkCnt, "fightPower":fightPower,
                     "boxContribCnt":boxContribCnt, "boxHurtTotal":boxHurtTotal, "boxHurtTotalHis":boxHurtTotalHis}
    PlayerFamily.FamilyPyPackForwarding(curPlayer, clientData, tick, "PlayerFamilyTaofa.__OnFamilyTaofaOP", True, 20, reqDataEx=reqDataEx)
    return
def __OnFamilyTaofaOP(crossPlayer, clientData, tick, fromServerID=0, reqDataEx=None):
    opType = clientData.OpType
    # 布阵
    if opType == 1:
        __doBuzhen(crossPlayer)
    else:
        __doZhanshaAtk(crossPlayer, reqDataEx)
    return True
def __OnFamilyTaofaOP_Ret(curPlayer, clientData, isOK):
    if not isOK:
        return
    SyncTaofaInfo(curPlayer)
    return
def GetFamilyBuzhenLayer(familyID):
    ## 获取并刷新当前公会有效布阵层数
    familyAction = DBDataMgr.GetFamilyActionMgr().GetFamilyAction(familyID, ActionType)
    gActionData = familyAction.GetActionDataByValue1(ActionGlobalID, True)
    gEndTime = GetFABuzhenEndTime(gActionData)
    gLayer = GetFABuzhenLayer(gActionData)
    if (gEndTime or gLayer) and int(time.time()) > gEndTime:
        SetFABuzhenEndTime(gActionData, 0)
        SetFABuzhenLayer(gActionData, 0)
        #PlayerFamily.SendFamilyAction(gActionData) 失效不用同步,前端根据EndTime判断即可
        gEndTime = 0
        gLayer = 0
    return gLayer, gActionData
def __doBuzhen(curPlayer):
def __doBuzhen(crossPlayer):
    ## 布阵
    playerID = curPlayer.GetPlayerID()
    if curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTaofaBuZhenState):
        GameWorld.DebugLog("已布阵过!", playerID)
        return
    familyID = curPlayer.GetFamilyID()
    playerID = crossPlayer.GetPlayerID()
    familyID = crossPlayer.GetFamilyID()
    curFamily = DBDataMgr.GetFamilyMgr().FindFamily(familyID)
    if not curFamily:
        return
    gLayer, gActionData = GetFamilyBuzhenLayer(familyID)
    bzDuration = IpyGameDataPY.GetFuncCfg("FamilyTaofaBuzhen", 4) * 60 # 有效时长秒
    maxLayer = IpyGameDataPY.GetFuncCfg("FamilyTaofaBuzhen", 3)
    gEndTime = int(time.time()) + bzDuration # 直接覆盖更新
    if not maxLayer or gLayer < maxLayer:
        gLayer += 1
    gLayer += 1 # 布阵不限制次数,直接加
    #if not maxLayer or gLayer < maxLayer:
    #    gLayer += 1
    GameWorld.DebugLog("公会讨伐布阵: gLayer=%s,gEndTime=%s" % (gLayer, GameWorld.ChangeTimeNumToStr(gEndTime)), playerID)
    # 公共信息
    SetFABuzhenEndTime(gActionData, gEndTime)
@@ -340,36 +212,34 @@
    PlayerFamily.SendFamilyAction([gActionData, actionData])
    
    # 个人记录
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBuZhenState, 1)
    SyncTaofaInfo(curPlayer)
    CrossPlayer.SetPlayerNomalDict(crossPlayer, {ChConfig.Def_Player_Dict_FamilyTaofaBuZhenState:1}, True)
    return
def __doZhanshaAtk(curPlayer):
def __doZhanshaAtk(crossPlayer, reqDataEx):
    ## 斩杀攻击
    playerID = curPlayer.GetPlayerID()
    familyID = curPlayer.GetFamilyID()
    if not reqDataEx:
        return
    playerID = crossPlayer.GetPlayerID()
    familyID = crossPlayer.GetFamilyID()
    curFamily = DBDataMgr.GetFamilyMgr().FindFamily(familyID)
    if not curFamily:
        return
    
    commAddAnger, superAddAnger, maxAnger = IpyGameDataPY.GetFuncEvalCfg("FamilyTaofaAtk", 4)
    anger = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTaofaAnger)
    atkType = AtkType_Anger if anger >= maxAnger else AtkType_Normal
    if atkType == AtkType_Normal:
        atkCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTaofaCnt)
        itemAddCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTaofaItemAddCnt)
        freeCnt = IpyGameDataPY.GetFuncCfg("FamilyTaofaAtk", 1)
        canAtkCnt = freeCnt + itemAddCnt - atkCnt
        if canAtkCnt <= 0:
            GameWorld.DebugLog("公会讨伐没有斩杀次数: atkCnt=%s >= freeCnt(%s) + itemAddCnt(%s)" % (atkCnt, freeCnt, itemAddCnt), playerID)
            return
    atkTime = int(time.time())
    fightPower = reqDataEx.get("fightPower", 1)
    anger = reqDataEx.get("anger", 0)
    atkCnt = reqDataEx.get("atkCnt", 0)
    atkType = reqDataEx.get("atkType", AtkType_Normal)
    boxContribCnt = reqDataEx.get("boxContribCnt", 0)
    boxHurtTotal = reqDataEx.get("boxHurtTotal", 0)
    boxHurtTotalHis = reqDataEx.get("boxHurtTotalHis", 0)
    
    # 计算属性
    gLayer, _ = GetFamilyBuzhenLayer(familyID)
    fightPower = PlayerControl.GetFightPower(curPlayer)
    maxLayer = IpyGameDataPY.GetFuncCfg("FamilyTaofaBuzhen", 3)
    gLayer = min(gLayer, maxLayer) # 限制生效的最大布阵层数
    superRate = IpyGameDataPY.GetFuncCfg("FamilyTaofaBuzhen", 1)
    superRatio = IpyGameDataPY.GetFuncCfg("FamilyTaofaAtk", 3) # 暴击伤害倍值
    addSuperRatePerLayer, addDamPerLayer = IpyGameDataPY.GetFuncEvalCfg("FamilyTaofaBuzhen", 2)
@@ -388,13 +258,6 @@
    faHurtTotal = GetFAHurtTotal(actionData) + GetFAHurtTotalEx(actionData) * ChConfig.Def_PerPointValue
    GameWorld.DebugLog("faAtkCnt=%s,faHurtTotal=%s,faContribBoxCnt=%s" % (faAtkCnt, faHurtTotal, faContribBoxCnt), playerID)
    
    boxContribCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTaofaBoxContribCnt)
    boxHurt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTaofaBoxHurt)
    boxHurtEx = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTaofaBoxHurtEx)
    boxHurtTotal = boxHurt + boxHurtEx * ChConfig.Def_PerPointValue
    boxHurtHis = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTaofaBoxHurtHis)
    boxHurtHisEx = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTaofaBoxHurtHisEx)
    boxHurtTotalHis = boxHurtHis + boxHurtHisEx * ChConfig.Def_PerPointValue
    GameWorld.DebugLog("boxContribCnt=%s,boxHurtTotal=%s,boxHurtTotalHis=%s" % (boxContribCnt, boxHurtTotal, boxHurtTotalHis), playerID)
    
    calcHurtCnt = 1 # 计算伤害次数
@@ -436,28 +299,36 @@
        updContribBoxCnt = min(updContribBoxCnt + loopContribBoxCnt, contribBoxMax)
        GameWorld.DebugLog("计算循环贡献宝箱: updContribBoxCnt=%s,loopHurtTotal=%s,loopNeedHurt=%s,loopContribBoxCnt=%s,contribBoxMax=%s" 
                           % (updContribBoxCnt, loopHurtTotal, loopNeedHurt, loopContribBoxCnt, contribBoxMax), playerID)
    setPlayerDict = {} # 更新玩家永久的字典值
    setPlayerDayDict = {} # 更新玩家每日重置的字典值
    addContribCnt = 0
    if updContribBoxCnt > boxContribCnt:
        addContribCnt = updContribBoxCnt - boxContribCnt
        faContribBoxCnt += addContribCnt
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxContribCnt, updContribBoxCnt)
        setPlayerDayDict[ChConfig.Def_Player_Dict_FamilyTaofaBoxContribCnt] = updContribBoxCnt
        GameWorld.DebugLog("更新增加贡献宝箱: addContribCnt=%s,updContribBoxCnt=%s,faContribBoxCnt=%s" % (addContribCnt, updContribBoxCnt, faContribBoxCnt), playerID)
        
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaAnger, anger)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxHurt, boxHurtTotal % ChConfig.Def_PerPointValue)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxHurtEx, boxHurtTotal / ChConfig.Def_PerPointValue)
    setPlayerDayDict[ChConfig.Def_Player_Dict_FamilyTaofaAnger] = anger
    setPlayerDayDict[ChConfig.Def_Player_Dict_FamilyTaofaBoxHurt] = boxHurtTotal % ChConfig.Def_PerPointValue
    setPlayerDayDict[ChConfig.Def_Player_Dict_FamilyTaofaBoxHurtEx] = boxHurtTotal / ChConfig.Def_PerPointValue
    if boxHurtTotal > boxHurtTotalHis:
        boxHurtTotalHis = boxHurtTotal
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxHurtHis, boxHurtTotalHis % ChConfig.Def_PerPointValue)
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxHurtHisEx, boxHurtTotalHis / ChConfig.Def_PerPointValue)
        setPlayerDict[ChConfig.Def_Player_Dict_FamilyTaofaBoxHurtHis] = boxHurtTotalHis % ChConfig.Def_PerPointValue
        setPlayerDict[ChConfig.Def_Player_Dict_FamilyTaofaBoxHurtHisEx] = boxHurtTotalHis / ChConfig.Def_PerPointValue
        
    awardItemList = []
    # 常规攻击: 给斩杀攻击奖励,加次数
    if atkType == AtkType_Normal:
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaCnt, atkCnt + 1)
        setPlayerDayDict[ChConfig.Def_Player_Dict_FamilyTaofaCnt] = atkCnt + 1
        atkItemAwardList = IpyGameDataPY.GetFuncEvalCfg("FamilyTaofaAtk", 2) # 每次斩杀获得个人奖励列表 [[物品ID,个数], ...]
        awardItemList += atkItemAwardList
        ItemControler.GivePlayerItemOrMail(curPlayer, awardItemList, event=["FamilyTaofa", False, {}], isNotifyAward=False)
    CrossPlayer.SetPlayerNomalDict(crossPlayer, setPlayerDayDict, True)
    if setPlayerDict:
        CrossPlayer.SetPlayerNomalDict(crossPlayer, setPlayerDayDict, False)
    if awardItemList:
        CrossPlayer.GivePlayerResources(crossPlayer, awardItemList, eventName="FamilyTaofa", isNotifyAward=False)
        
    # 更新Action记录
    SetFAAtkTime(actionData, atkTime)
@@ -465,19 +336,63 @@
    SetFAHurtTotal(actionData, faHurtTotal % ChConfig.Def_PerPointValue)
    SetFAHurtTotalEx(actionData, faHurtTotal / ChConfig.Def_PerPointValue)
    SetFAContribBoxCnt(actionData, faContribBoxCnt)
    atkList = actionData.GetUserDict().get("atkList", [])
    atkList = actionData.GetUserDict().get(UserKey_AtkList, [])
    atkList.append([atkTime, addContribCnt, hurtTotal, atkType])
    actionData.GetUserDict().update({"atkList":atkList})
    actionData.GetUserDict().update({UserKey_AtkList:atkList})
    PlayerFamily.SendFamilyAction([actionData])
    
    # 同步: 攻击 -> 宝箱 -> 其他
    SyncTaofaAtkRet(curPlayer, atkType, hurtList, awardItemList)
    SyncTaofaAtkRet(crossPlayer, atkType, hurtList, awardItemList)
    if addContribCnt:
        RefreshPlayerAwardBoxCnt(curFamily, unSyncIDList=[playerID])
    SyncTaofaInfo(curPlayer)
        SyncMemContribInfo(curFamily)
    return
def GMAddMemTaofaAtk(curPlayer, curFamily, playerID, hurtValue, isAnger):
def SyncMemContribInfo(curFamily, onlyIDList=[]):
    memContribDict = GetMemContriBoxInfo(curFamily)
    if not memContribDict:
        return
    CrossPlayer.SendToFamilyPlayer(curFamily.GetID(), ShareDefine.C2S_TaofaMemContrib, {"memContribDict":memContribDict},
                                   onlyIDList=onlyIDList, havePlayerCall=__doUpdPlayerAwardBoxCnt)
    return
def GetFamilyBuzhenLayer(familyID):
    ## 获取并刷新当前公会有效布阵层数
    familyAction = DBDataMgr.GetFamilyActionMgr().GetFamilyAction(familyID, ActionType)
    gActionData = familyAction.GetActionDataByValue1(ActionGlobalID, True)
    gEndTime = GetFABuzhenEndTime(gActionData)
    gLayer = GetFABuzhenLayer(gActionData)
    if (gEndTime or gLayer) and int(time.time()) > gEndTime:
        SetFABuzhenEndTime(gActionData, 0)
        SetFABuzhenLayer(gActionData, 0)
        #PlayerFamily.SendFamilyAction(gActionData) 失效不用同步,前端根据EndTime判断即可
        gEndTime = 0
        gLayer = 0
    return gLayer, gActionData
def GetMemContriBoxInfo(family):
    ## 获取公会成员贡献宝箱记录
    if not family:
        return {}
    familyID = family.GetID()
    memContribDict = {}
    familyAction = DBDataMgr.GetFamilyActionMgr().GetFamilyAction(familyID, ActionType)
    for index in range(0, familyAction.Count()):
        actionData = familyAction.At(index)
        memID = GetFAPlayerID(actionData)
        if memID == ActionGlobalID:
            continue
        contribList = []
        atkList = actionData.GetUserDict().get("atkList", [])
        for atkInfo in atkList:
            atkTime = atkInfo[AtkIndex_AtkTime]
            contribBoxCnt = atkInfo[AtkIndex_ContribBoxCnt]
            if contribBoxCnt > 0:
                contribList.append([atkTime, contribBoxCnt])
        if contribList:
            memContribDict[memID] = contribList
    return memContribDict
def GMAddMemTaofaAtk(crossPlayer, curFamily, playerID, hurtValue, isAnger):
    ## GM添加假的讨伐数据
    
    familyID = curFamily.GetID()
@@ -535,7 +450,7 @@
        addContribCnt = updContribBoxCnt - boxContribCnt
        faContribBoxCnt += addContribCnt
        
    GameWorld.DebugAnswer(curPlayer, "讨伐ID:%s,伤:%s,箱:%s/%s,怒:%s" % (playerID, hurtValue, addContribCnt, updContribBoxCnt, int(isAnger)))
    GameWorld.DebugAnswer(crossPlayer, "讨伐ID:%s,伤:%s,箱:%s/%s,怒:%s" % (playerID, hurtValue, addContribCnt, updContribBoxCnt, int(isAnger)))
    
    # 更新Action记录
    SetFAAtkTime(actionData, atkTime)
@@ -543,11 +458,139 @@
    SetFAHurtTotal(actionData, faHurtTotal % ChConfig.Def_PerPointValue)
    SetFAHurtTotalEx(actionData, faHurtTotal / ChConfig.Def_PerPointValue)
    SetFAContribBoxCnt(actionData, faContribBoxCnt)
    atkList = actionData.GetUserDict().get("atkList", [])
    atkList = actionData.GetUserDict().get(UserKey_AtkList, [])
    atkList.append([atkTime, addContribCnt, hurtTotal, atkType])
    actionData.GetUserDict().update({"atkList":atkList})
    actionData.GetUserDict().update({UserKey_AtkList:atkList})
    
    return actionData
def SyncTaofaAtkRet(crossPlayer, atkType, hurtList, awardItemList):
    atkHurtList = []
    for totalHurt, isSuper in hurtList:
        atkHurt = ChPyNetSendPack.tagSCFamilyTaofaAtkHurt()
        atkHurt.IsSuper = isSuper
        atkHurt.HurtValue = totalHurt % ChConfig.Def_PerPointValue
        atkHurt.HurtValueEx = totalHurt / ChConfig.Def_PerPointValue
        atkHurtList.append(atkHurt)
    itemList = []
    for itemID, itemCount in awardItemList:
        item = ChPyNetSendPack.tagSCFamilyTaofaAtkItem()
        item.ItemID = itemID
        item.Count = itemCount
        itemList.append(item)
    clientPack = ChPyNetSendPack.tagSCFamilyTaofaAtkRet()
    clientPack.AtkType = atkType
    clientPack.HurtList = atkHurtList
    clientPack.HurtCount = len(clientPack.HurtList)
    clientPack.ItemList = itemList
    clientPack.ItemCount = len(clientPack.ItemList)
    CrossPlayer.SendFakePack(crossPlayer, clientPack)
    return
## -----------------------------------以下为游戏服地图逻辑-------------------------------------------
def PlayerOnDay(curPlayer):
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaCnt, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaItemAddCnt, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBuZhenState, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaAnger, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxUnGetCnt, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaLeaveGetCnt, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxTotalGetCnt, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxContribCnt, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxHurt, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxHurtEx, 0)
    SyncTaofaInfo(curPlayer)
    return
def OnPlayerLogin(curPlayer):
    SyncTaofaInfo(curPlayer)
    return
def OnTaofaResetPlayer(curPlayer):
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaCnt, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaItemAddCnt, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBuZhenState, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaAnger, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxUnGetCnt, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaLeaveGetCnt, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxTotalGetCnt, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxContribCnt, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxHurt, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxHurtEx, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxHurtHis, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxHurtHisEx, 0)
    SyncTaofaInfo(curPlayer)
    return
def OnPlayerLeaveFamily(curPlayer):
    ## 玩家退出了公会,针对玩家个人的处理
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaAnger, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxUnGetCnt, 0)
    totalGetCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTaofaBoxTotalGetCnt)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaLeaveGetCnt, totalGetCnt)
    GameWorld.DebugLog("退出公会记录讨伐已累计领取宝箱数: totalGetCnt=%s" % totalGetCnt)
    SyncTaofaInfo(curPlayer)
    return
def C2S_TaofaMemContrib(dataMsg):
    familyID = dataMsg["familyID"]
    playerIDList = dataMsg["playerIDList"]
    playerManager = GameWorld.GetPlayerManager()
    for playerID in playerIDList:
        curPlayer = playerManager.FindPlayerByID(playerID)
        if curPlayer == None:
            continue
        __doUpdPlayerAwardBoxCnt(curPlayer, familyID, dataMsg)
    return
def __doUpdPlayerAwardBoxCnt(curPlayer, familyID, dataMsg):
    memContribDict = dataMsg["memContribDict"]
    playerFamilyID = curPlayer.GetFamilyID()
    playerID = curPlayer.GetPlayerID()
    joinTime = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyJoinTime)
    if not joinTime or not playerFamilyID or playerFamilyID != familyID or not memContribDict:
        return
    awardBoxMax = IpyGameDataPY.GetFuncCfg("FamilyTaofaBox", 3)
    leaveGetCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTaofaLeaveGetCnt) # 上次离开公会时累计领取数
    boxTotalGetCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTaofaBoxTotalGetCnt) # 已领取宝箱数
    curFamilyGetCnt = boxTotalGetCnt - leaveGetCnt # 来到本公会后累计领取数
    boxUnGetCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTaofaBoxUnGetCnt) # 未领取宝箱数
    canAddBoxMax = awardBoxMax - boxTotalGetCnt - boxUnGetCnt # 还可领取的箱子数
    if canAddBoxMax <= 0:
        GameWorld.DebugLog("    成员可领取宝箱已达上限不刷新: playerID=%s,boxTotalGetCnt(%s)+boxUnGetCnt(%s) >= %s"
                           % (playerID, boxTotalGetCnt, boxUnGetCnt, awardBoxMax))
        return
    curFamilyCanGet = 0 # 在本公会累计可领取箱子数
    for contribList in memContribDict.values():
        for atkTime, contribBoxCnt in contribList:
            if joinTime >= atkTime:
                GameWorld.DebugLog("    加入公会之前的箱子不能领取: joinTime=%s > atkTime(%s),contribBoxCnt=%s" % (joinTime, atkTime, contribBoxCnt))
                continue
            curFamilyCanGet += contribBoxCnt
    addUnGetBox = min(curFamilyCanGet - curFamilyGetCnt - boxUnGetCnt, canAddBoxMax)
    if addUnGetBox <= 0:
        GameWorld.DebugLog("    成员当前没有可领取的宝箱不刷新: playerID=%s,curFamilyCanGet=%s,curFamilyGetCnt=%s(%s-%s),boxUnGetCnt=%s,awardBoxMax=%s,canAddBoxMax=%s"
                           % (playerID, curFamilyCanGet, curFamilyGetCnt, boxTotalGetCnt, leaveGetCnt, boxUnGetCnt, awardBoxMax, canAddBoxMax))
        return
    updBoxUnGetCnt = boxUnGetCnt + addUnGetBox
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaBoxUnGetCnt, updBoxUnGetCnt)
    GameWorld.DebugLog("    成员可领取的宝箱数: playerID=%s,addUnGetBox=%s,updBoxUnGetCnt=%s,curFamilyCanGet=%s,curFamilyGetCnt=%s(%s-%s),boxUnGetCnt=%s,awardBoxMax=%s,canAddBoxMax=%s"
                       % (playerID, addUnGetBox, updBoxUnGetCnt, curFamilyCanGet, curFamilyGetCnt, boxTotalGetCnt, leaveGetCnt, boxUnGetCnt, awardBoxMax, canAddBoxMax))
    SyncTaofaInfo(curPlayer)
    return
def AddTaofaCntByItem(curPlayer, addCnt):
    ## 物品增加副本次数
    itemAddCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTaofaItemAddCnt)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTaofaItemAddCnt, itemAddCnt + addCnt)
    SyncTaofaInfo(curPlayer)
    return
def GetTaofaBoxAward(curPlayer):
    boxUnGetCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTaofaBoxUnGetCnt)
@@ -594,27 +637,3 @@
    NetPackCommon.SendFakePack(curPlayer, clientPack)
    return
def SyncTaofaAtkRet(curPlayer, atkType, hurtList, awardItemList):
    atkHurtList = []
    for totalHurt, isSuper in hurtList:
        atkHurt = ChPyNetSendPack.tagSCFamilyTaofaAtkHurt()
        atkHurt.IsSuper = isSuper
        atkHurt.HurtValue = totalHurt % ChConfig.Def_PerPointValue
        atkHurt.HurtValueEx = totalHurt / ChConfig.Def_PerPointValue
        atkHurtList.append(atkHurt)
    itemList = []
    for itemID, itemCount in awardItemList:
        item = ChPyNetSendPack.tagSCFamilyTaofaAtkItem()
        item.ItemID = itemID
        item.Count = itemCount
        itemList.append(item)
    clientPack = ChPyNetSendPack.tagSCFamilyTaofaAtkRet()
    clientPack.AtkType = atkType
    clientPack.HurtList = atkHurtList
    clientPack.HurtCount = len(clientPack.HurtList)
    clientPack.ItemList = itemList
    clientPack.ItemCount = len(clientPack.ItemList)
    NetPackCommon.SendFakePack(curPlayer, clientPack)
    return