xdh
2018-09-20 d3dd7b36e8b7bc96d0c6134cfa4773a020621bcd
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerDogz.py
@@ -125,6 +125,7 @@
    # 助战状态换装需要刷属性
    if GetDogzIsHelpFight(curPlayer, dogzID):
        RefreshDogzAttr(curPlayer)
        PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
        
    return
@@ -201,6 +202,7 @@
    if GetDogzIsHelpFight(curPlayer, dogzID):
        SetDogzIsHelpFight(curPlayer, dogzID, False) # 因为脱下了状态,所以必须设置为非助战状态
        RefreshDogzAttr(curPlayer)
        PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
        
    return
@@ -262,6 +264,7 @@
    GameWorld.DebugLog("神兽助战状态变更!dogzID=%s,isFight=%s" % (dogzID, isFight), playerID)
    SetDogzIsHelpFight(curPlayer, dogzID, isFight)
    RefreshDogzAttr(curPlayer)
    PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
    return
@@ -311,6 +314,7 @@
#    BYTE        EquipIndex;    //神兽装备背包中索引
#    BYTE        IndexCount;        //材料所在神兽物品背包索引的数量
#    BYTE        IndexList[IndexCount];    //材料所在神兽物品背包索引列表
#    BYTE        IndexUseCountList[IndexCount];    //材料所在神兽物品背包索引对应使用个数列表
#    BYTE        IsDouble;        //是否双倍强化
#};
def OnDogzEquipPlus(index, clientData, tick):
@@ -318,8 +322,14 @@
    playerID = curPlayer.GetPlayerID()
    equipIndex = clientData.EquipIndex
    indexList = clientData.IndexList
    indexUseCountList = clientData.IndexUseCountList
    isDouble = clientData.IsDouble
    GameWorld.DebugLog("神兽装备强化: equipIndex=%s,indexList=%s,isDouble=%s" % (equipIndex, indexList, isDouble), playerID)
    GameWorld.DebugLog("神兽装备强化: equipIndex=%s,indexList=%s,indexUseCountList=%s,isDouble=%s"
                       % (equipIndex, indexList, indexUseCountList, isDouble), playerID)
    if len(indexList) != len(indexUseCountList):
        GameWorld.DebugLog("    指定消耗的个数数据长度错误!")
        return
    
    dogzEquipPack = curPlayer.GetItemManager().GetPack(ShareDefine.rptDogzEquip)
    curEquip = dogzEquipPack.GetAt(equipIndex)
@@ -328,24 +338,26 @@
                           % (equipIndex, curEquip.GetItemTypeID()), playerID)
        return
    
    equipColor = curEquip.GetItemColor()
    colorPlusMaxLVDict = IpyGameDataPY.GetFuncEvalCfg("DogzAssist", 4) # {颜色:等级上限, ...}
    if equipColor not in colorPlusMaxLVDict:
        return
    maxPlusLV = colorPlusMaxLVDict[equipColor]
    equipPlace = curEquip.GetEquipPlace()
    curPlusLV = curEquip.GetUserAttrByIndex(ShareDefine.Def_IudetDogzEquipPlus, 0)
    curPlusExpTotal = curEquip.GetUserAttrByIndex(ShareDefine.Def_IudetDogzEquipPlus, 1)
    if curPlusLV >= maxPlusLV:
        GameWorld.Log("神兽装备已满级, 无法强化!equipColor=%s,curPlusLV=%s,maxPlusLV=%s" % (equipColor, curPlusLV, maxPlusLV), playerID)
        return
    
    ipyData = IpyGameDataPY.GetIpyGameData("DogzEquipPlus", equipPlace, curPlusLV)
    if not ipyData:
        return
    curLVUPTotalExp = ipyData.GetPlusLVUPTotalExp()
    if not curLVUPTotalExp:
    lvUPTotalExp = ipyData.GetPlusLVUPTotalExp()
    if not lvUPTotalExp:
        GameWorld.Log("神兽装备升级所需总经验为0, 无法强化!equipPlace=%s,curPlusLV=%s" % (equipPlace, curPlusLV), playerID)
        return
    nextLVIpyData = None
    if curPlusExpTotal >= curLVUPTotalExp:
        nextLVIpyData = IpyGameDataPY.GetIpyGameDataNotLog("DogzEquipPlus", equipPlace, curPlusLV + 1)
        if not nextLVIpyData:
            GameWorld.Log("神兽装备已满级, 无法强化!equipPlace=%s,curPlusLV=%s" % (equipPlace, curPlusLV), playerID)
            return
        
    costGoldTotal = 0
    addExpTotal = 0
@@ -365,24 +377,25 @@
            GameWorld.ErrLog("神兽背包物品无经验效果,无法强化!i=%s,itemID=%s" % (i, curItem.GetItemTypeID()), playerID)
            return
        
        delCount = max(1, min(curItem.GetCount(), indexUseCountList[i]))
        baseExp = effect.GetEffectValue(0)
        doubleCostGold = effect.GetEffectValue(1)
        
        addExp = baseExp
        addExp = baseExp * delCount
        plusInfoCount = curItem.GetUserAttrCount(ShareDefine.Def_IudetDogzEquipPlus)
        if not plusInfoCount:
            if isDouble and doubleCostGold:
                addExp = (baseExp * 2)
                costGoldTotal += doubleCostGold
            GameWorld.DebugLog("    强化: addExp=%s,baseExp=%s,isDouble=%s,doubleCostGold=%s,costGoldTotal=%s"
                               % (addExp, baseExp, isDouble, doubleCostGold, costGoldTotal), playerID)
                addExp = (baseExp * 2 * delCount)
                costGoldTotal += doubleCostGold * delCount
            GameWorld.DebugLog("    强化: addExp=%s,delCount=%s,baseExp=%s,isDouble=%s,doubleCostGold=%s,costGoldTotal=%s"
                               % (addExp, delCount, baseExp, isDouble, doubleCostGold, costGoldTotal), playerID)
        else:
            #plusLV = curItem.GetUserAttrByIndex(ShareDefine.Def_IudetDogzEquipPlus, 0)
            plusExpTotal = curItem.GetUserAttrByIndex(ShareDefine.Def_IudetDogzEquipPlus, 1)
            addExp += plusExpTotal
            GameWorld.DebugLog("    强化: addExp=%s,baseExp=%s,plusExpTotal=%s" % (addExp, baseExp, plusExpTotal), playerID)
            GameWorld.DebugLog("    强化: addExp=%s,delCount=%s,baseExp=%s,plusExpTotal=%s" % (addExp, delCount, baseExp, plusExpTotal), playerID)
        addExpTotal += addExp
        delItemList.append(curItem)
        delItemList.append([curItem, delCount])
        
    if not delItemList:
        GameWorld.DebugLog("    没有材料可强化!", playerID)
@@ -396,20 +409,23 @@
                                      ChConfig.Def_Cost_DogzEquipPlus, infoDict):
            return
        
    for delItem in delItemList:
        ItemCommon.DelItem(curPlayer, delItem, curItem.GetCount(), False, ChConfig.ItemDel_DogzEquipPlus, infoDict)
    for delItem, delCount in delItemList:
        ItemCommon.DelItem(curPlayer, delItem, delCount, False, ChConfig.ItemDel_DogzEquipPlus, infoDict)
        
    updPlusLV = curPlusLV
    if updPlusExpTotal >= curLVUPTotalExp:
        doCount = 0
        while nextLVIpyData and updPlusExpTotal >= nextLVIpyData.GetPlusLVUPTotalExp() and doCount < 100:
            doCount += 1
            nextLV = updPlusLV + 1
            nextLVIpyData = IpyGameDataPY.GetIpyGameDataNotLog("DogzEquipPlus", equipPlace, nextLV)
            if not nextLVIpyData:
                break
            updPlusLV = nextLV
    doCount, maxDoCount = 0, maxPlusLV * 2
    while updPlusExpTotal >= lvUPTotalExp and updPlusLV < maxPlusLV and doCount < maxDoCount:
        doCount += 1
        nextLV = updPlusLV + 1
        nextLVIpyData = IpyGameDataPY.GetIpyGameDataNotLog("DogzEquipPlus", equipPlace, nextLV)
        if not nextLVIpyData:
            GameWorld.DebugLog("    没有下一级数据,不能升级!nextLV=%s" % (nextLV), playerID)
            break
        updPlusLV = nextLV
        lvUPTotalExp = nextLVIpyData.GetPlusLVUPTotalExp()
        GameWorld.DebugLog("    升级: equipPlace=%s,maxPlusLV=%s,updPlusLV=%s,updPlusExpTotal=%s,lvUPTotalExp=%s"
                           % (equipPlace, maxPlusLV, updPlusLV, updPlusExpTotal, lvUPTotalExp), playerID)
    isRefreshAtrr = False
    # 未强化过
    if not curPlusExpTotal:
@@ -427,12 +443,36 @@
    
    if isRefreshAtrr:
        RefreshDogzAttr(curPlayer)
        PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
        
    return
def GetDogzEquipPlusLVExpInfo(equipColor, equipPlace, totalExp):
    ## 获取当前神兽装备最高强化等级的强化熟练度
    retLV, retExp = 0, 0
    colorPlusMaxLVDict = IpyGameDataPY.GetFuncEvalCfg("DogzAssist", 4) # {颜色:等级上限, ...}
    if equipColor not in colorPlusMaxLVDict:
        return retLV, retExp
    maxPlusLV = colorPlusMaxLVDict[equipColor]
    for lv in xrange(maxPlusLV + 1):
        ipyData = IpyGameDataPY.GetIpyGameDataNotLog("DogzEquipPlus", equipPlace, lv)
        if lv and not ipyData:
            break
        lvUPTotalExp = ipyData.GetPlusLVUPTotalExp()
        if not lvUPTotalExp:
            break
        if totalExp < lvUPTotalExp:
            return lv, totalExp
        retLV, retExp = lv, lvUPTotalExp
    return retLV, retExp
def RefreshDogzAttr(curPlayer):
    ## 刷新神兽属性
    
    fightPowerEx = 0
    allAttrList = [{} for _ in range(4)]
    
    dogzEquipPack = curPlayer.GetItemManager().GetPack(ShareDefine.rptDogzEquip)
@@ -493,8 +533,12 @@
            ChEquip.CalcAttr_LegendAttr(curPlayer, curEquip, allAttrList)
            #GameWorld.DebugLog("    装备传奇: itemID=%s,%s" % (itemID, allAttrList))
            
        # 附加战力
        fightPowerEx += ipyData.GetFightPowerEx()
    # 保存计算值
    PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_Dogz, allAttrList)
    curPlayer.SetDict(ChConfig.Def_PlayerKey_MFPEx % ShareDefine.Def_MFPType_Dogz, fightPowerEx)
    return
def Sync_DogzInfo(curPlayer):