| | |
| | | import EventShell
|
| | | import ChConfig
|
| | | import ChEquip
|
| | |
|
| | | import math
|
| | | #-------------------------------------------------------------------------------------------
|
| | |
|
| | |
|
| | |
| | | costEquipPlaceList = ipyData.GetCostEquipPlace()
|
| | | costEquipColorList = ipyData.GetCostEquipColor()
|
| | | isJobLimit = ipyData.GetIsJobLimit()
|
| | | suitTotalRate = ipyData.GetSuitTotalRate()
|
| | | itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
|
| | | delEquipIndexList = []
|
| | | totalEquipStars = ChEquip.GetTotalEquipStars(curPlayer)
|
| | |
|
| | | if not costEquipCnt:
|
| | | curRate = suitTotalRate / 2
|
| | | curRate = 100
|
| | | else:
|
| | | singleSuitRate = float(suitTotalRate) / costEquipCnt
|
| | | curRate = 0 #成功概率
|
| | | diffClassChangeRatePerInfo = IpyGameDataPY.GetFuncEvalCfg("EquipStarRate", 1)
|
| | | unSuitRateRange = IpyGameDataPY.GetFuncEvalCfg("EquipStarRate", 2)
|
| | | suitRateRange = IpyGameDataPY.GetFuncEvalCfg("EquipStarRate", 3)
|
| | | if len(diffClassChangeRatePerInfo) != 2 or len(unSuitRateRange) != 2 or len(suitRateRange) != 2:
|
| | | GameWorld.ErrLog('升星不同阶概率配置错误!')
|
| | | return result
|
| | |
|
| | | for i, index in enumerate(clientData.CostEquipIndex):
|
| | | costEquip = itemPack.GetAt(index)
|
| | |
| | | if equipID != clientData.CostEquipID[i]:
|
| | | GameWorld.ErrLog(' 装备升星 客户端发的物品索引与实际物品ID不对应 index=%s,eatItemID=%s,wantEatItemID=%s' % (index, equipID, clientData.CostEquipID[i]))
|
| | | return result
|
| | | if costEquip.GetItemColor() not in costEquipColorList:
|
| | | itemColor = costEquip.GetItemColor()
|
| | | equipPlace = costEquip.GetEquipPlace()
|
| | | if itemColor not in costEquipColorList:
|
| | | return result
|
| | | if costEquip.GetEquipPlace() not in costEquipPlaceList:
|
| | | if equipPlace not in costEquipPlaceList:
|
| | | return result
|
| | | if isJobLimit and not ItemCommon.CheckJob(curPlayer, costEquip):
|
| | | return result
|
| | | delEquipIndexList.append(index)
|
| | | isSuite = costEquip.GetSuiteID()
|
| | | addRate = singleSuitRate if isSuite else singleSuitRate / 2
|
| | | |
| | | if costEquip.GetSuiteID():
|
| | | baseRate = ipyData.GetSuitRate()
|
| | | minRate, maxRate = suitRateRange
|
| | | else:
|
| | | baseRate = ipyData.GetUnSuitRate()
|
| | | minRate, maxRate = unSuitRateRange
|
| | | |
| | | GameWorld.DebugLog("equipID=%s,baseRate=%s,minRate=%s,maxRate=%s" % (equipID, baseRate, minRate, maxRate))
|
| | | addRate = baseRate
|
| | | costClassLV = ItemCommon.GetItemClassLV(costEquip)
|
| | | |
| | | #吞高阶
|
| | | if costClassLV > classLV:
|
| | | diffClassChangeRatePer = diffClassChangeRatePerInfo[0] * (costClassLV - classLV)
|
| | | addRate = int(math.ceil(round(baseRate * (100 + diffClassChangeRatePer) /100.0, 2)))
|
| | | GameWorld.DebugLog(" 吞高阶 costClassLV=%s,classLV=%s,diffClassChangeRatePer=%s,addRate=%s" % (costClassLV, classLV, diffClassChangeRatePer, addRate))
|
| | | #吞低阶
|
| | | elif costClassLV < classLV:
|
| | | diffClassChangeRatePer = diffClassChangeRatePerInfo[1] * (classLV - costClassLV)
|
| | | addRate = int(math.ceil(round(baseRate * (100 - diffClassChangeRatePer) /100.0, 2)))
|
| | | GameWorld.DebugLog(" 吞低阶 costClassLV=%s,classLV=%s,diffClassChangeRatePer=%s,addRate=%s" % (costClassLV, classLV, diffClassChangeRatePer, addRate))
|
| | | addRate = max(minRate, min(addRate, maxRate))
|
| | | curRate += addRate
|
| | | GameWorld.DebugLog(" 本件装备增加概率=%s,当前总概率=%s" % (addRate, curRate))
|
| | | delEquipIndexList.append(index)
|
| | | if totalEquipStars < IpyGameDataPY.GetFuncCfg('EquipStarCustomized'):
|
| | | curRate = 100
|
| | | if curRate <= 0:
|
| | | GameWorld.Log('装备升星异常 概率为0!!equipPackIndex=%s'%equipPackIndex)
|
| | | return result
|
| | | #判断普通物品材料
|
| | | isOK = GameWorld.CanHappen(curRate, 100)
|
| | | GameWorld.DebugLog("装备升星最终总概率: %s, isOK=%s" % (curRate, isOK))
|
| | | #判断普通物品材料 成功才扣
|
| | | costItemDict = ipyData.GetCostItemDict()
|
| | | if costItemDict:
|
| | | if isOK and costItemDict:
|
| | | delItemDict = {}
|
| | | for itemID, itemCnt in costItemDict.items():
|
| | | hasEnough, indexList, findItemIsBind, lackCnt = ItemCommon.GetItem_FromPack_ByID_ExEx(itemID, itemPack, itemCnt)
|
| | |
| | | ItemCommon.ReduceItem(curPlayer, itemPack, itemIndexList, delCnt, True, ChConfig.ItemDel_EquipStarUp)
|
| | | #扣装备
|
| | | ItemCommon.ReduceItem(curPlayer, itemPack, delEquipIndexList, len(delEquipIndexList), True, ChConfig.ItemDel_EquipStarUp)
|
| | | isOK = GameWorld.CanHappen(curRate, 100)
|
| | | |
| | | if isOK:
|
| | | ChEquip.SetEquipPartStar(curPlayer, equipPackIndex, nextStar)
|
| | | ChEquip.NotifyEquipPartStar(curPlayer, equipPackIndex)
|