xdh
2019-04-13 6feb5f6c84521cab58c523d43ba8a8fc02a5029a
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerAttrFruit.py
@@ -98,7 +98,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:
@@ -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)
@@ -446,7 +446,7 @@
        eatCntPack.Clear()
        eatCntPack.ItemID = fruitItemID
        eatCntPack.EatCnt = curPlayer.NomalDictGetProperty(eatCntKey)
        #eatCntPack.AddAttr = curPlayer.NomalDictGetProperty(addValueKey)
        eatCntPack.AddItemCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AttrFruitAddItemCnt % fruitItemID)
        eatPack.EatCntList.append(eatCntPack)
    
    eatPack.count = len(eatPack.EatCntList)
@@ -480,11 +480,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 +488,56 @@
    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)
    if addItemUseCnt:
        addItemInfo = ipyData.GetAddItemInfo()
        if addItemInfo:
            singleItemCnt, singleAddCnt = addItemInfo[1:]
            maxEatCnt += (addItemUseCnt/singleItemCnt*singleAddCnt)
    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
    addItemInfo = ipyData.GetAddItemInfo()
    if not addItemInfo:
        return
    addItemUseCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AttrFruitAddItemCnt % itemID)
    needItemID, singleItemCnt, singleAddCnt = addItemInfo
    if addItemUseCnt + singleItemCnt> ChConfig.Def_UpperLimit_DWord:
        return
    itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
    enough, indexList, hasBind, lackCnt = ItemCommon.GetItem_FromPack_ByID_ExEx(needItemID, itemPack, singleItemCnt)
    if not enough:
        return
    ItemCommon.ReduceItem(curPlayer, itemPack, indexList, singleItemCnt, False, "AddFruitUseLimit")
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_AttrFruitAddItemCnt % itemID, addItemUseCnt+singleItemCnt)
    Sync_AttrFruitEatCnt(curPlayer, [itemID])
    return