|  |  |  | 
|---|
|  |  |  | 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: | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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) | 
|---|
|  |  |  | 
|---|
|  |  |  | if hasUseCnt <= 0: | 
|---|
|  |  |  | return DefaultReturn | 
|---|
|  |  |  | PlayerControl.NomalDictSetProperty(curPlayer, eatCntKey, eatCnt) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if funcIndex == ShareDefine.Def_AttrFruitFunc_Stove: | 
|---|
|  |  |  | PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_UseStoveBylv, hasUseCnt, [item.GetLV()]) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ItemCommon.DelItem(curPlayer, item, hasUseCnt, True, ChConfig.ItemDel_AttrFruit) | 
|---|
|  |  |  | return addValue, hasUseCnt | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | limitType = Def_LimitType_Cnt #默认按个数 | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | # 增加附加战力,仅按个数时有效 | 
|---|
|  |  |  | fightPowerExfigKey = ChConfig.Def_PlayerKey_FruitFightPowerEx % (funcIndex) | 
|---|
|  |  |  | fightPowerEx = curPlayer.GetDictByKey(fightPowerExfigKey) | 
|---|
|  |  |  | fruitIpyData = GetAttrFruitIpyData(fruitItemID) | 
|---|
|  |  |  | addFightPowerEx = 0 if not fruitIpyData else fruitIpyData.GetFightPowerEx() | 
|---|
|  |  |  | fightPowerEx = fightPowerEx + addFightPowerEx * addValue | 
|---|
|  |  |  | curPlayer.SetDict(fightPowerExfigKey, fightPowerEx) | 
|---|
|  |  |  | GameWorld.DebugLog("    Add funcIndex=%s,addFightPowerEx=%s,addValue=%s,fightPowerEx=%s" % (funcIndex, addFightPowerEx, addValue, fightPowerEx)) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for i in range(itemData.GetEffectCount()): | 
|---|
|  |  |  | curEffect = itemData.GetEffectByIndex(i) | 
|---|
|  |  |  | effectID = curEffect.GetEffectID() | 
|---|
|  |  |  | 
|---|
|  |  |  | #GameWorld.DebugLog("    effectID=%s,addValue=%s" % (effectID, addValue)) | 
|---|
|  |  |  | PlayerControl.CalcAttrDict_Type(effectID, addValue, allAttrList) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #GameWorld.DebugLog("    有果实属性 allAttrList=%s" % str(allAttrList)) | 
|---|
|  |  |  | return | 
|---|
|  |  |  | fightPowerEx = curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_FruitFightPowerEx % (funcIndex)) | 
|---|
|  |  |  | #GameWorld.DebugLog("    有果实属性funcIndex=%s,fightPowerEx=%s,allAttrList=%s" % (funcIndex, fightPowerEx, allAttrList)) | 
|---|
|  |  |  | return fightPowerEx | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ## 统计百分比属性对功能内层的属性增加 | 
|---|
|  |  |  | 
|---|
|  |  |  | 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) | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return eatCntDict | 
|---|
|  |  |  |  | 
|---|
|  |  |  | def IsFruitEatFull(curPlayer, itemID): | 
|---|
|  |  |  | #使用次数是否已满 | 
|---|
|  |  |  | maxEatCnt = GetMaxEatCnt(curPlayer, itemID) | 
|---|
|  |  |  | eatCntKey = ChConfig.Def_PDict_AttrFruitEatCnt % itemID | 
|---|
|  |  |  | limitType = Def_LimitType_Cnt | 
|---|
|  |  |  | if limitType == Def_LimitType_Attr: | 
|---|
|  |  |  | eatCntKey = ChConfig.Def_PDict_AttrFruitAddValue % itemID | 
|---|
|  |  |  | eatCnt = curPlayer.NomalDictGetProperty(eatCntKey) # 已吃次数/属性值 | 
|---|
|  |  |  | if eatCnt >= maxEatCnt: | 
|---|
|  |  |  | return True | 
|---|
|  |  |  | 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 | 
|---|