ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerAttrFruit.py
@@ -39,6 +39,7 @@
import PlayerPet
import PlayerRefineStove
import PlayerSuccess
import SkillShell
(
Def_LimitType_Cnt, # 按个数限制
@@ -98,7 +99,7 @@
        if not ipyData:
            continue
        
        maxEatCnt = ipyData.GetMaxUseCnt()
        maxEatCnt = GetMaxEatCnt(curPlayer, itemID)
        eatCntKey = ChConfig.Def_PDict_AttrFruitEatCnt % itemID
        limitType = Def_LimitType_Cnt
        if limitType == Def_LimitType_Attr:
@@ -199,7 +200,6 @@
    
    # 刷新属性
    __RefreshAttr(curPlayer, funcIndex)
    return True, hasUseCnt
## 玩家使用属性果实
@@ -216,7 +216,7 @@
    funcIndex = ipyData.GetFuncID()
    limitType = Def_LimitType_Cnt
    maxEatCnt = ipyData.GetMaxUseCnt()
    maxEatCnt = GetMaxEatCnt(curPlayer, itemID)
    
    if funcIndex not in ShareDefine.Def_AttrFruitFuncList:
        GameWorld.ErrLog("该属性果实功能未开放!funcIndex=%s"%funcIndex)
@@ -266,6 +266,18 @@
    if funcIndex == ShareDefine.Def_AttrFruitFunc_Stove:
        PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_UseStoveBylv, hasUseCnt, [item.GetLV()])
        
    effect = item.GetEffectByIndex(0)
    effID = effect.GetEffectID()
    ## 特殊属性ID处理,此属性ID做一次性处理,不做属性计算
    if effID == ShareDefine.Def_Effect_FreePoint:
        effValue = effect.GetEffectValue(0)
        addFreePoint = effValue * hasUseCnt
        freePoint = curPlayer.GetFreePoint()
        updFreePoint = freePoint + addFreePoint
        curPlayer.SetFreePoint(updFreePoint)
        GameWorld.DebugLog("丹药增加自由属性点: freePoint=%s,addFreePoint=%s(%s*%s),updFreePoint=%s"
                           % (freePoint, addFreePoint, effValue, hasUseCnt, updFreePoint))
    ItemCommon.DelItem(curPlayer, item, hasUseCnt, True, ChConfig.ItemDel_AttrFruit)
    return addValue, hasUseCnt
@@ -289,11 +301,11 @@
def __AddFruitAttr(curPlayer, fruitItemID, funcIndex, addValue):
    
    if addValue < 1:
        return
        return []
    
    itemData = GameWorld.GetGameData().GetItemByTypeID(fruitItemID)
    if not itemData:
        return
        return []
    
    
    limitType = Def_LimitType_Cnt #默认按个数
@@ -306,14 +318,14 @@
    fightPowerEx = fightPowerEx + addFightPowerEx * addValue
    curPlayer.SetDict(fightPowerExfigKey, fightPowerEx)
    GameWorld.DebugLog("    Add funcIndex=%s,addFightPowerEx=%s,addValue=%s,fightPowerEx=%s" % (funcIndex, addFightPowerEx, addValue, fightPowerEx))
    attrIDList = []
    for i in range(itemData.GetEffectCount()):
        curEffect = itemData.GetEffectByIndex(i)
        effectID = curEffect.GetEffectID()
        
        if not effectID or effectID not in ChConfig.ItemEffect_AttrDict:
        if not effectID or effectID not in ChConfig.ItemEffect_AttrDict or effectID == ShareDefine.Def_Effect_FreePoint:
            continue
        attrIDList.append(effectID)
        attrKey = ChConfig.Def_PlayerKey_FruitAttr % (funcIndex, effectID)
        curValue = curPlayer.GetDictByKey(attrKey)
        effValueA = curEffect.GetEffectValue(0)
@@ -326,7 +338,7 @@
        curPlayer.SetDict(attrKey, updValue)
        GameWorld.DebugLog("    Add funcIndex=%s,effID=%s,curValue=%s,effA=%s,effB=%s,count=%s,updV=%s" 
                           % (funcIndex, effectID, curValue, effValueA, effValueB, addValue, updValue))
    return
    return attrIDList
## 加载果实增加的属性缓存,一般是登录或切地图后
# @param curPlayer
@@ -396,7 +408,7 @@
    
    #[属性索引, 是否基础属性,(非)线性]
    attrInfo = ChConfig.ItemEffect_AttrDict.get(effPerID, [])
    if attrInfo == []:
    if attrInfo is []:
        return
    
    addAttrList = attrInfo[0]
@@ -421,12 +433,12 @@
#  @param curPlayer 
#  @param fruitItemID 
#  @return None
def Sync_AttrFruitEatCnt(curPlayer, fruitItemIDList=[]):
def Sync_AttrFruitEatCnt(curPlayer, fruitItemIDList=None):
    
    eatPack = ChPyNetSendPack.tagMCAttrFruitEatCntList()
    eatPack.Clear()
    eatPack.EatCntList = []
    if fruitItemIDList == []:
    if fruitItemIDList is None:
        itemidList = []
        ipyDataMgr = IpyGameDataPY.IPY_Data()
        maxCnt = ipyDataMgr.GetAttrFruitCount()
@@ -446,7 +458,8 @@
        eatCntPack.Clear()
        eatCntPack.ItemID = fruitItemID
        eatCntPack.EatCnt = curPlayer.NomalDictGetProperty(eatCntKey)
        #eatCntPack.AddAttr = curPlayer.NomalDictGetProperty(addValueKey)
        eatCntPack.ItemAddCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AttrFruitAddItemCnt % fruitItemID)
        eatCntPack.ItemBreakCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AttrFruitItemBreakCnt % fruitItemID)
        eatPack.EatCntList.append(eatCntPack)
    
    eatPack.count = len(eatPack.EatCntList)
@@ -480,11 +493,7 @@
def IsFruitEatFull(curPlayer, itemID):
    #使用次数是否已满
    ipyData = GetAttrFruitIpyData(itemID)
    if not ipyData:
        return
    maxEatCnt = ipyData.GetMaxUseCnt()
    maxEatCnt = GetMaxEatCnt(curPlayer, itemID)
    eatCntKey = ChConfig.Def_PDict_AttrFruitEatCnt % itemID
    limitType = Def_LimitType_Cnt
    if limitType == Def_LimitType_Attr:
@@ -492,4 +501,63 @@
    eatCnt = curPlayer.NomalDictGetProperty(eatCntKey) # 已吃次数/属性值
    if eatCnt >= maxEatCnt:
        return True
    return
    return
def GetMaxEatCnt(curPlayer, itemID):
    ##获取果实最大可用个数
    ipyData = GetAttrFruitIpyData(itemID)
    if not ipyData:
        return 0
    maxEatCntDict = ipyData.GetMaxUseCnt()
    realmLV = curPlayer.GetOfficialRank()
    orderList = sorted(maxEatCntDict.keys(), reverse=True)
    maxEatCnt = 0
    for order in orderList:
        if realmLV >= order:
            maxEatCnt = maxEatCntDict[order]
            break
    addItemUseCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AttrFruitAddItemCnt % itemID)
    maxEatCnt += addItemUseCnt
    return maxEatCnt
#// A3 17 增加果实使用上限 #tagCMAddFruitUseLimit
#
#struct    tagCMAddFruitUseLimit
#{
#    tagHead        Head;
#    DWORD        ItemID;        //果实物品ID
#};
def OnAddFruitUseLimit(index, packData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    itemID = packData.ItemID
    ipyData = GetAttrFruitIpyData(itemID)
    if not ipyData:
        return
    addItemInfoList = ipyData.GetAddItemInfo()
    if not addItemInfoList:
        return
    itemBreakCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AttrFruitItemBreakCnt % itemID)
    itemAddUseCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AttrFruitAddItemCnt % itemID)
    needUseCnt = canUpCnt = 0
    for breakCnt, useCnt, upCnt in addItemInfoList:
        if itemBreakCnt >= breakCnt:
            continue
        needUseCnt, canUpCnt = useCnt, upCnt
        break
    if not needUseCnt:
        return
    needItemID = IpyGameDataPY.GetFuncCfg('AlchemyOverLimit')
    if itemAddUseCnt + canUpCnt> ChConfig.Def_UpperLimit_DWord:
        return
    itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
    enough, indexList, hasBind, lackCnt = ItemCommon.GetItem_FromPack_ByID_ExEx(needItemID, itemPack, needUseCnt)
    if not enough:
        return
    ItemCommon.ReduceItem(curPlayer, itemPack, indexList, needUseCnt, False, "AddFruitUseLimit")
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_AttrFruitAddItemCnt % itemID, itemAddUseCnt+canUpCnt)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_AttrFruitItemBreakCnt % itemID,
                                       itemBreakCnt + 1)
    Sync_AttrFruitEatCnt(curPlayer, [itemID])
    return