ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/ChEquip.py
@@ -144,9 +144,9 @@
    curPlayer.SetDict(ChConfig.Def_PlayerKey_AttrActivatyNotify, ChConfig.Def_AttrActivatyNotify_Equip)
    
    #先刷装备BUFF 再计算属性
    if changeItemEquipPlace == ShareDefine.retWing:
        PlayerWing.CalcWingAttr(curPlayer)
    else:
    if changeItemEquipPlace in ChConfig.EquipPlace_LingQi:
        RefreshPlayerLingQiEquipAttr(curPlayer)
    elif itemClassLV:
        RefreshPlayerEquipAttribute(curPlayer, itemClassLV)
    
    #刷新所有属性
@@ -158,7 +158,6 @@
    return True
## 刷新装备对人物属性的改变
#  @param self 类实例
#  @return 返回值无意义
@@ -180,6 +179,152 @@
        if classLV not in classLVList:
            classLVList.append(classLV)
            #GameWorld.DebugLog("添加装备缓存变更阶: classLV=%s, %s" % (classLV, classLVList), playerID)
    return
def OnPlayerEquipLoginLogic(curPlayer):
    ''' 玩家登录统一处理装备,只遍历一次装备背包,通知信息、更新一次数据,防止总等级统计异常
                    装备品质橙装及以上数量、装备总星数、强化总等级、进化总等级、洗练总等级、宝石总等级
    '''
    #NotifyEquipPartPlusLV(curPlayer)
    #NotifyEquipPartStar(curPlayer)
    #Operate_EquipWash.OnEquipWashLogin(curPlayer)
    #通知套装信息
    #ChEquip.SyncAllEquipAttrActiveInfo(curPlayer)
    #装备位宝石镶嵌通知
    #Operate_EquipStone.OnLogin(curPlayer)
    ePartStarLVPack = ChPyNetSendPack.tagMCEquipPartStarInfo() # A3 B1 装备部位星数信息 #tagMCEquipPartStarInfo
    ePartPlusLVPack = ChPyNetSendPack.tagMCEquipPartPlusInfo() # A3 B3 装备部位强化信息 #tagMCEquipPartPlusInfo
    ePartXLPack = ChPyNetSendPack.tagMCEquipPartXLAttrInfo() # A3 BB 装备位洗练属性信息 #tagMCEquipPartXLAttrInfo
    ePartStonePack = ChPyNetSendPack.tagMCStoneInfo() # A3 BC 通知装备位孔位宝石ID #tagMCStoneInfo
    orangeEquipCount = 0
    totalStar = 0
    totalPlusLV = 0
    totalEvolveLV = 0
    totalWashLV = 0
    totalStoneLV = 0
    holeIndexList = Operate_EquipStone.GetAllEquipPlaceHoleIndex()
    gameData = GameWorld.GetGameData()
    packType = IPY_GameWorld.rptEquip
    equipPack = curPlayer.GetItemManager().GetPack(packType)
    for index in xrange(equipPack.GetCount()):
        ipyData = IpyGameDataPY.GetIpyGameDataByCondition('EquipPlaceIndexMap', {'GridIndex':index}, isLogNone=False)
        if not ipyData:
            continue
        # 只计算有阶的境界装备
        if not ipyData.GetClassLV():
            continue
        curEquip = equipPack.GetAt(index)
        if not curEquip.IsEmpty():
            if curEquip.GetItemColor() >= ShareDefine.Def_Item_Color_Orange:
                orangeEquipCount += 1
        # 星级
        starLV = GetEquipPartStar(curPlayer, index)
        totalStar += starLV
        # 强化等级
        plusProficiency = GetEquipPartProficiency(curPlayer, packType, index)
        plusLV = GetEquipPartPlusLV(curPlayer, packType, index)
        totalPlusLV += plusLV
        # 进化等级
        evolveLV = GetEquipPartPlusEvolveLV(curPlayer, packType, index)
        totalEvolveLV += evolveLV
        # 洗练等级
        washLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_EquipWashLV % index)
        totalWashLV += washLV
        # 宝石等级
        stoneIDList, stoneIsBindList = [], []
        for holeIndex in holeIndexList:
            stoneID, stoneIsBind = Operate_EquipStone.GetEquipIndexStoneIDAndIsBand(curPlayer, index, holeIndex)
            stoneIDList.append(stoneID)
            stoneIsBindList.append(stoneIsBind)
            if stoneID == 0:
                continue
            curStone = gameData.GetItemByTypeID(stoneID)
            stoneLV = 0 if not curStone else curStone.GetEffectByIndex(0).GetEffectValue(1)
            totalStoneLV += stoneLV
        # 星级信息包
        if starLV:
            ePartStarLV = ChPyNetSendPack.tagMCEquipPartStar()
            ePartStarLV.Clear()
            ePartStarLV.EquipPackIndex = index
            ePartStarLV.Star = starLV
            ePartStarLVPack.InfoList.append(ePartStarLV)
        # 强化、进化信息包
        if plusLV or plusProficiency or evolveLV:
            ePartPlusLV = ChPyNetSendPack.tagMCEquipPartPlusLV()
            ePartPlusLV.Clear()
            ePartPlusLV.PackType = packType
            ePartPlusLV.EquipIndex = index
            ePartPlusLV.EquipPartStarLV = plusLV
            ePartPlusLV.Proficiency = plusProficiency
            ePartPlusLV.EvolveLV = evolveLV
            ePartPlusLVPack.InfoList.append(ePartPlusLV)
        # 洗练信息包
        hasXLValue = False
        xlAttrList = []
        for attrNum in xrange(1, Operate_EquipWash.Def_EquipWashMaxAttrCount + 1):
            washValue = ChPyNetSendPack.tagMCEquipPartXLAttrValue()
            washValue.XLAttrValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_EquipWashValue % (index, attrNum))
            washValue.XLAttrChange = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_EquipWashValueTemp % (index, attrNum))
            xlAttrList.append(washValue)
            if washValue.XLAttrValue or washValue.XLAttrChange:
                hasXLValue = True
        if hasXLValue or washLV:
            ePartXLAttr = ChPyNetSendPack.tagMCEquipPartXLAttr()
            ePartXLAttr.EquipPlace = index
            ePartXLAttr.XLAttrLV = washLV
            ePartXLAttr.XLAttrList = xlAttrList
            ePartXLAttr.XLAttrCnt = len(ePartXLAttr.XLAttrList)
            ePartXLPack.InfoList.append(ePartXLAttr)
        # 宝石信息包
        stoneCount = len(stoneIDList)
        if stoneIDList.count(0) != stoneCount:
            stoneMsg = ChPyNetSendPack.tagMCStoneMsg()
            stoneMsg.EquipPlace = index
            stoneMsg.MaxStoneCount = stoneCount
            stoneMsg.StoneInfo = stoneIDList
            stoneMsg.StoneBind = stoneIsBindList
            ePartStonePack.InfoList.append(stoneMsg)
    # 通知封包,有值时才通知
    if ePartStarLVPack.InfoList:
        ePartStarLVPack.Count = len(ePartStarLVPack.InfoList)
        NetPackCommon.SendFakePack(curPlayer, ePartStarLVPack)
    if ePartPlusLVPack.InfoList:
        ePartPlusLVPack.Count = len(ePartPlusLVPack.InfoList)
        NetPackCommon.SendFakePack(curPlayer, ePartPlusLVPack)
    if ePartXLPack.InfoList:
        ePartXLPack.Count = len(ePartXLPack.InfoList)
        NetPackCommon.SendFakePack(curPlayer, ePartXLPack)
    if ePartStonePack.InfoList:
        ePartStonePack.EquipCount = len(ePartStonePack.InfoList)
        NetPackCommon.SendFakePack(curPlayer, ePartStonePack)
    # 更新统计汇总值
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PlayerKey_EquipOrangeCount, orangeEquipCount)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TotalEquipStar, totalStar)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TotalPlusLV, totalPlusLV)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TotalPlusEvolveLV, totalEvolveLV)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TotalEquipWashLV, totalWashLV)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TotalStoneLV, totalStoneLV)
    GameWorld.DebugLog("登录更新装备相关值汇总: orangeEquipCount=%s,totalStar=%s,totalPlusLV=%s,totalEvolveLV=%s,totalWashLV=%s,totalStoneLV=%s"
                       % (orangeEquipCount, totalStar, totalPlusLV, totalEvolveLV, totalWashLV, totalStoneLV))
    return
## 刷新所有装备对人物属性的改变
@@ -370,9 +515,9 @@
        return
    
    #先刷装备BUFF 再计算属性
    if equipPlace == ShareDefine.retWing:
        PlayerWing.CalcWingAttr(curPlayer)
    else:
    if equipPlace in ChConfig.EquipPlace_LingQi:
        RefreshPlayerLingQiEquipAttr(curPlayer)
    elif itemClassLV:
        RefreshPlayerEquipAttribute(curPlayer, itemClassLV)
    
    #刷新所有属性
@@ -426,6 +571,45 @@
        PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_774045")
        return
    
    return
def RefreshPlayerLingQiEquipAttr(curPlayer):
    ''' 刷新玩家灵器装备属性
    '''
    classLV = 0 # 灵器阶默认为0
    allAttrList = [{} for _ in range(4)]
    equipPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptEquip)
    for equipPlace in ChConfig.EquipPlace_LingQi:
        if equipPlace == ShareDefine.retWing:
            PlayerWing.CalcWingAttr(curPlayer)
            continue
        ipyData = IpyGameDataPY.GetIpyGameData('EquipPlaceIndexMap', classLV, equipPlace)
        if not ipyData:
            continue
        equipIndex = ipyData.GetGridIndex()
        curEquip = equipPack.GetAt(equipIndex)
        if not curEquip or curEquip.IsEmpty():
            continue
        if not ItemCommon.CheckItemCanUseByExpireTime(curEquip):
            # 过期
            continue
        #基础属性效果
        for effIndex in xrange(curEquip.GetEffectCount()):
            curEff = curEquip.GetEffectByIndex(effIndex)
            effID = curEff.GetEffectID()
            if effID == 0:
                break
            PlayerControl.CalcAttrDict_Type(effID, curEff.GetEffectValue(0), allAttrList)
    #GameWorld.DebugLog("灵器属性: %s" % allAttrList)
    PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_LingQi, allAttrList)
    return
def __CalcEquips_Effect(curPlayer, classLV):
@@ -1069,22 +1253,29 @@
    return min(curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_EquipPartPlusLV % (packType, index)), maxStarLV)
## 获取公共部位强化星级
## 获取公共部位强化等级
def GetEquipPartPlusLV(curPlayer, packType, index):
    return curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_EquipPartPlusLV % (packType, index))
## 设置公共部位强化星级
def SetEquipPartPlusLV(curPlayer, packType, index, curEquip, starLV):
    if GetEquipPartPlusLV(curPlayer, packType, index) == starLV:
## 设置公共部位强化等级
def SetEquipPartPlusLV(curPlayer, packType, index, curEquip, setPlusLV):
    befPlusLV = GetEquipPartPlusLV(curPlayer, packType, index)
    if befPlusLV == setPlusLV:
        return
    
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_EquipPartPlusLV % (packType, index), starLV)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_EquipPartPlusLV % (packType, index), setPlusLV)
    #===========================================================================
    # if curEquip and not curEquip.IsEmpty():
    #    curEquip.SetItemStarLV(starLV)
    #===========================================================================
    # 同步更新强化总等级
    befTotalPlusLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TotalPlusLV)
    updTotalPlusLV = max(0, befTotalPlusLV + setPlusLV - befPlusLV)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TotalPlusLV, updTotalPlusLV)
    GameWorld.DebugLog("设置强化等级: index=%s,befPlusLV=%s,setPlusLV=%s,befTotalPlusLV=%s,updTotalPlusLV=%s"
                       % (index, befPlusLV, setPlusLV, befTotalPlusLV, updTotalPlusLV))
    return
@@ -1100,10 +1291,18 @@
## 设置公共部位强化进化等级
def SetEquipPartPlusEvolveLV(curPlayer, packType, index, evolveLV):
    if GetEquipPartPlusEvolveLV(curPlayer, packType, index) == evolveLV:
def SetEquipPartPlusEvolveLV(curPlayer, packType, index, setEvolveLV):
    befEvolveLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_EquipPartPlusEvolveLV % (packType, index))
    if befEvolveLV == setEvolveLV:
        return
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_EquipPartPlusEvolveLV % (packType, index), evolveLV)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_EquipPartPlusEvolveLV % (packType, index), setEvolveLV)
    # 同步更新进化总等级
    befTotalPlusEvolveLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TotalPlusEvolveLV)
    updTotalPlusEvolveLV = max(0, befTotalPlusEvolveLV + setEvolveLV - befEvolveLV)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TotalPlusEvolveLV, updTotalPlusEvolveLV)
    GameWorld.DebugLog("设置进化等级: index=%s,befEvolveLV=%s,setEvolveLV=%s,befTotalPlusEvolveLV=%s,updTotalPlusEvolveLV=%s"
                       % (index, befEvolveLV, setEvolveLV, befTotalPlusEvolveLV, updTotalPlusEvolveLV))
    return
## 通知公共部位强化等级
@@ -1141,18 +1340,15 @@
## 全身强化等级
def GetTotalPlusLV(curPlayer, isActive=True):
    totalPlusLV = 0
    equipPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptEquip)
    equipPartIndexList = ChConfig.Pack_EquipPart_CanPlusStar[IPY_GameWorld.rptEquip]
    for i in equipPartIndexList:
        if isActive:
            curEquip = equipPack.GetAt(i)
            if not curEquip  or curEquip.IsEmpty():
                continue
        partStarLV = GetEquipPartPlusLV(curPlayer, IPY_GameWorld.rptEquip, i)
        totalPlusLV += partStarLV
    return totalPlusLV
    return curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TotalPlusLV)
## 全身进化等级
def GetTotalPlusEvolveLV(curPlayer):
    return curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TotalPlusEvolveLV)
## 全身橙装及以上装备数
def GetEquipOrangeCount(curPlayer):
    return curPlayer.NomalDictGetProperty(ChConfig.Def_PlayerKey_EquipOrangeCount)
# 获取装备的强化类型
@@ -1187,9 +1383,20 @@
def SetEquipPartStar(curPlayer, equipPackindex, star):
def SetEquipPartStar(curPlayer, index, setStarLV):
    #设置公共部位星数
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_EquipPartStar % equipPackindex, star)
    befStarLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_EquipPartStar % index)
    if befStarLV == setStarLV:
        return
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_EquipPartStar % index, setStarLV)
    # 同步更新星级总等级
    befTotalStarLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TotalEquipStar)
    updTotalStarLV = max(0, befTotalStarLV + setStarLV - befStarLV)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TotalEquipStar, updTotalStarLV)
    GameWorld.DebugLog("设置部位星级: index=%s,befStarLV=%s,setStarLV=%s,befTotalStarLV=%s,updTotalStarLV=%s"
                       % (index, befStarLV, setStarLV, befTotalStarLV, updTotalStarLV))
    return
@@ -1203,6 +1410,9 @@
    maxStarLV = ItemCommon.GetItemMaxStar(curEquip)
    return min(GetEquipPartStar(curPlayer, equipPackindex), maxStarLV)
def GetTotalEquipStars(curPlayer):
    ##获取部位总星数
    return curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TotalEquipStar)
## 通知公共部位星数
def NotifyEquipPartStar(curPlayer, index=None):