hxp
2018-08-16 8f476186cf97ffc569a9ba2845c53e15a392c442
Merge remote-tracking branch 'remotes/origin/master'
1个文件已修改
65 ■■■■■ 已修改文件
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerEquipDecompose.py 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerEquipDecompose.py
@@ -70,15 +70,14 @@
# 吞噬物品, 返回被吞数量
def EatItems(curPlayer, eatIndexList):
    eatItemList, totalAddExp = __GetCanEatItemInfo(curPlayer, eatIndexList)
    drDelItemList, totalAddExp, delAllCnt = __GetCanEatItemInfo(curPlayer, eatIndexList)
    if not totalAddExp:
        GameWorld.DebugLog("    装备吸收 没有可吞噬物品!")
        return 0, 0
    LV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_EquipDecomposeLV)
    Exp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_EquipDecomposeExp)
    reduceTotalExp, updLV, updExp = __GetEatItemResult(curPlayer, LV, Exp, totalAddExp)
    # 扣除吞噬物品
    drDelItemList, delAllCnt = __DelEatItem(curPlayer, reduceTotalExp, eatItemList)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_EquipDecomposeExp, updExp)
    if LV != updLV:
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_EquipDecomposeLV, updLV)
@@ -129,6 +128,7 @@
def __GetCanEatItemInfo(curPlayer, expIndexList):
    eatItemList = []
    totalAddExp = 0
    allitemCnt = 0
    petEatItemAddExpPer = PlayerVip.GetPrivilegeValue(curPlayer, ChConfig.VIPPrivilege_EatItem)
    itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
    for index in expIndexList:
@@ -149,19 +149,24 @@
                GameWorld.DebugLog("    tagPetEatEquip.txt,未配置该物品! eatItemID=%s, EquipColor=%s,EquipClass=%s" % (eatItemID, itemColor, itemClass))
                continue
            baseExp = ipyData.GetExp()
        if petEatItemAddExpPer:
            baseExp += baseExp * petEatItemAddExpPer / ChConfig.Def_MaxRateValue
        itemCnt = eatItem.GetCount() # 装备一般默认1,如是经验道具则一般可叠加
        addExp = baseExp * itemCnt
        
        totalAddExp += addExp
        allitemCnt += itemCnt
        ItemCommon.DelItem(curPlayer, eatItem, itemCnt, True, ChConfig.ItemDel_EquipDecompose)
        
        GameWorld.DebugLog("    i=%s,baseExp=%s,itemCnt=%s,addExp=%s,totalAddExp=%s"
        GameWorld.DebugLog("    吸收 删除物品 i=%s,baseExp=%s,itemCnt=%s,addExp=%s,totalAddExp=%s"
                           % (index, baseExp, itemCnt, addExp, totalAddExp))
        # 先检索可吃列表,防止升级过程中吃掉原来不可吃的[index, 物品实例, 基础经验]
        eatItemList.append([index, eatItem, baseExp])
    return eatItemList, totalAddExp
        eatItemList.append([eatItemID, itemCnt, baseExp, addExp])
    if petEatItemAddExpPer:
        totalAddExp += totalAddExp * petEatItemAddExpPer / ChConfig.Def_MaxRateValue
    PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_DecomposeEquip, allitemCnt)
    return eatItemList, totalAddExp, allitemCnt
##获取吞噬结果
@@ -170,12 +175,17 @@
def __GetEatItemResult(curPlayer, LV, Exp, totalAddExp):
    remainExp = totalAddExp # 剩余可用经验
    reduceTotalExp = 0 # 真正需要扣除的经验
    ipyMgr = IpyGameDataPY.IPY_Data()
    maxLV = ipyMgr.GetEquipDecomposeByIndex(ipyMgr.GetEquipDecomposeCount()-1).GetLV()
    # 经验检查
    while remainExp > 0:
        if LV +1 >= maxLV:
            break
        maxExp = __GetLvUpNeedExp(LV)
        
        if not maxExp:
            break
        needExp = max(0, maxExp - Exp)
        if remainExp >= needExp:
            Exp = 0
@@ -187,46 +197,19 @@
            reduceTotalExp += remainExp
            remainExp = 0
            
    #等级满后也可以分解加经验,故所有装备都分解
    Exp += remainExp
    reduceTotalExp = totalAddExp
    GameWorld.DebugLog("总可加经验=%s,实际总扣除经验=%s,newLV=%s,最终经验=%s" % 
                       (totalAddExp, reduceTotalExp, LV, Exp))
    return reduceTotalExp, LV, Exp
##扣除吞噬物品
#  @param curPlayer: 玩家实例
#  @return
def __DelEatItem(curPlayer, reduceTotalExp, eatItemList):
    drDelItemList = []
    delAllCnt = 0 #删除物品总个数
    # 扣物品
    for index, eatItem, baseExp in eatItemList:
        eatItemID = eatItem.GetItemTypeID()
        curItemCnt = eatItem.GetCount()
        curItemTotalExp = baseExp * curItemCnt
        if reduceTotalExp >= curItemTotalExp:
            delCnt = curItemCnt
            reduceTotalExp -= curItemTotalExp
        else:
            delCnt = int(math.ceil(reduceTotalExp / float(baseExp)))
            reduceTotalExp = 0
        addExp = delCnt * baseExp
        delAllCnt += delCnt
        # 这里不记录流向, 在外部统一记录
        ItemCommon.DelItem(curPlayer, eatItem, delCnt, True, ChConfig.ItemDel_EquipDecompose)
        GameWorld.DebugLog("        吸收 删除物品 i=%s,delCnt=%s,addExp=%s" % (index, delCnt, addExp))
        PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_DecomposeEquip, delCnt)
        drDelItemList.append((eatItemID, delCnt, baseExp, addExp))
        if reduceTotalExp <= 0:
            break
    return drDelItemList, delAllCnt
def __GetLvUpNeedExp(lv):
    """获取装备分解升级需要经验"""
    lv += 1 #配置的等级从1开始
    ipyData = IpyGameDataPY.GetIpyGameData("EquipDecompose", lv)
    #配置的等级从1开始
    ipyData = IpyGameDataPY.GetIpyGameData("EquipDecompose", lv+1)
    if not ipyData:
        return 0
    return ipyData.GetUpNeedExp()