From ab2158916e07846e4be746673231dac6dfa27fc9 Mon Sep 17 00:00:00 2001
From: xdh <xiefantasy@qq.com>
Date: 星期四, 18 四月 2019 14:21:24 +0800
Subject: [PATCH] 6528 【后端】【2.0】增加丹药属性

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerAttrFruit.py |   90 +++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 83 insertions(+), 7 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerAttrFruit.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerAttrFruit.py
index 21f344f..5f9e96a 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerAttrFruit.py
+++ b/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:
@@ -121,6 +121,7 @@
     if totalMoney:
         addDataDict = {"recycleItemList":recycleItemList}
         PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_Danjing, totalMoney, ChConfig.Def_GiveMoney_UseItem, addDataDict)
+        curPlayer.Sync_MakeItemAnswer(ShareDefine.Def_mitRecycleAttrFruit, 1)
     return
 
 
@@ -215,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)
@@ -262,7 +263,9 @@
     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
 
@@ -294,7 +297,16 @@
     
     
     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()
@@ -366,8 +378,9 @@
         #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
     
 
 ## 统计百分比属性对功能内层的属性增加
@@ -433,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)
@@ -465,3 +478,66 @@
         
     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

--
Gitblit v1.8.0