| | |
| | | import ItemCommon
|
| | | import ShareDefine
|
| | | import IPY_GameWorld
|
| | | import FormulaControl
|
| | | import PlayerControl
|
| | | import ItemControler
|
| | | import IpyGameDataPY
|
| | | import ChConfig
|
| | | import PlayerSuccess
|
| | | import DataRecordPack
|
| | | import PlayerWing
|
| | | import PlayerDogz
|
| | |
|
| | | import random
|
| | | import math
|
| | |
| | | compoundCnt = max(1, clientData.CompoundCnt) # 至少合成一个
|
| | | unfixedItemIndexList = clientData.UnfixedItemIndex
|
| | | fixedItemIndexList = clientData.FixedItemIndex
|
| | | addonsItemIndexList = clientData.AddonsItemIndex
|
| | | addonsItemCountList = clientData.AddonsItemCount
|
| | | #addonsItemIndexList = clientData.AddonsItemIndex
|
| | | #addonsItemCountList = clientData.AddonsItemCount
|
| | | incRateItemIndexList = clientData.RateIncreaseItemIndex
|
| | | GameWorld.DebugLog("物品合成: ID=%s,compoundCnt=%s,unfixedItemIndexList=%s,fixedItemIndexList=%s,addonsItemIndexList=%s,addonsItemCountList=%s,incRateItemIndexList=%s" |
| | | % (compoundID, compoundCnt, unfixedItemIndexList, fixedItemIndexList, addonsItemIndexList, addonsItemCountList, incRateItemIndexList), playerID)
|
| | | GameWorld.DebugLog("物品合成: ID=%s,compoundCnt=%s,unfixedItemIndexList=%s,fixedItemIndexList=%s,incRateItemIndexList=%s" |
| | | % (compoundID, compoundCnt, unfixedItemIndexList, fixedItemIndexList, incRateItemIndexList), playerID)
|
| | |
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("ItemCompound", compoundID)
|
| | | if not ipyData:
|
| | | GameWorld.ErrLog("找不到该合成表数据配置! ID=%s" % compoundID)
|
| | | return
|
| | |
|
| | | composeGroup = ipyData.GetComposeGroup()
|
| | | makeIDList = ipyData.GetMakeID()
|
| | | unfixedItemIDList = ipyData.GetUnfixedItemID()
|
| | | fixedItemIDList = ipyData.GetFixedItemID()
|
| | | fixedItemCountList = ipyData.GetFixedItemCount()
|
| | |
|
| | | isFirstSuccMakeJobItem = False
|
| | | if ipyData.GetIsFirstSuccMakeJobItem() and not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstSuccMakeJobItem % compoundID):
|
| | | isFirstSuccMakeJobItem = True
|
| | | makeItemID = 0
|
| | | for jobItemID in makeIDList:
|
| | | itemData = GameWorld.GetGameData().GetItemByTypeID(jobItemID)
|
| | | if itemData and ItemCommon.CheckJob(curPlayer, itemData):
|
| | | makeItemID = jobItemID
|
| | | break
|
| | | else:
|
| | | makeItemID = random.choice(makeIDList) # 从可合成物品列表里随机一个
|
| | | makeItemID = random.choice(makeIDList) # 从可合成物品列表里随机一个
|
| | | makeItemData = GameWorld.GetGameData().GetItemByTypeID(makeItemID)
|
| | | if not makeItemData:
|
| | | GameWorld.ErrLog("不存在该合成物品! makeItemID=%s" % makeItemID)
|
| | |
| | | successRate = ipyData.GetSuccessRate()
|
| | | successRateMax = ipyData.GetSuccessRateMax()
|
| | | successRateIncrease = ipyData.GetSuccessRateIncrease()
|
| | | addonsCountMax = ipyData.GetAddonsCountMax() # 可叠加的算叠加数量
|
| | | # 可使用非固定道具 或 附加道具的 单次合成数默认为1
|
| | | if unfixedItemIDList or addonsCountMax > 0 or incRateItemIndexList:
|
| | | if unfixedItemIDList or incRateItemIndexList:
|
| | | compoundCnt = 1
|
| | | |
| | | |
| | | totalNeedMoney = needMoney * compoundCnt
|
| | | if not PlayerControl.HaveMoney(curPlayer, IPY_GameWorld.TYPE_Price_Silver_Money, totalNeedMoney):
|
| | | if totalNeedMoney and not PlayerControl.HaveMoney(curPlayer, IPY_GameWorld.TYPE_Price_Silver_Money, totalNeedMoney):
|
| | | GameWorld.DebugLog("货币不足合成! totalNeedMoney=%s" % totalNeedMoney, playerID)
|
| | | return
|
| | |
|
| | | # 目标物品可否拆解判断
|
| | | canDecompoundItemTypeList = IpyGameDataPY.GetFuncEvalCfg("ItemDecompound", 1)
|
| | | decompoundMinColor = IpyGameDataPY.GetFuncCfg("ItemDecompound", 2)
|
| | | canDecompound = makeItemData.GetType() in canDecompoundItemTypeList and makeItemData.GetItemColor() >= decompoundMinColor
|
| | | decompoundItemInfo = [] # 拆解返还物品列表 [装备ID,材料1ID,个数,是否绑定,材料2ID,个数,是否绑定,...]
|
| | | |
| | | itemPack = curPlayer.GetItemManager().GetPack(packType)
|
| | | itemExpireTime = 0
|
| | | wingItemExpInfo = None #材料翅膀精炼信息
|
| | | dogzEquipPlusExp = 0 #神兽装备强化熟练度
|
| | | liantaiInfo = None #莲台相关信息
|
| | | # 检查不固定消耗道具
|
| | | if unfixedItemIDList:
|
| | | unfixedItem = GameWorld.GetGameData().GetItemByTypeID(unfixedItemIDList[0])
|
| | |
| | | unfixedItemIDList, needUnfixedItemCount)
|
| | | if not unfixedItemCostInfo:
|
| | | return
|
| | | unfixedItemCostList, wingItemExpInfo, dogzEquipPlusExp, expireTime, liantaiInfo = unfixedItemCostInfo
|
| | | unfixedItemCostList, expireTime = unfixedItemCostInfo
|
| | | if expireTime:
|
| | | itemExpireTime = expireTime if not itemExpireTime else min(itemExpireTime, expireTime)
|
| | |
|
| | |
| | | if not fixedItemInfo:
|
| | | return
|
| | | fixedItemIndexDict, fixedItemNeedCntDict, compoundBindCnt, expireTime = fixedItemInfo
|
| | | if expireTime:
|
| | | itemExpireTime = expireTime if not itemExpireTime else min(itemExpireTime, expireTime)
|
| | | |
| | | # 检查附加道具增加成功率消耗
|
| | | addSuccRate, addSuccRateItemInfo = 0, []
|
| | | if addonsCountMax > 0:
|
| | | addSuccRateInfo = __CheckAddonsItem(playerID, compoundID, itemPack, addonsItemIndexList, addonsItemCountList, addonsCountMax)
|
| | | if addSuccRateInfo == None:
|
| | | return
|
| | | addSuccRate, addSuccRateItemInfo, expireTime = addSuccRateInfo
|
| | | if expireTime:
|
| | | itemExpireTime = expireTime if not itemExpireTime else min(itemExpireTime, expireTime)
|
| | |
|
| | |
| | | itemExpireTime = expireTime if not itemExpireTime else min(itemExpireTime, expireTime)
|
| | |
|
| | | # 扣铜钱
|
| | | PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Silver_Money, totalNeedMoney, ChConfig.Def_Cost_ItemProduce, |
| | | {ChConfig.Def_Cost_Reason_SonKey:makeItemID, "CompoundCount":compoundCnt})
|
| | | if totalNeedMoney:
|
| | | PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Silver_Money, totalNeedMoney, ChConfig.Def_Cost_ItemProduce, |
| | | {ChConfig.Def_Cost_Reason_SonKey:makeItemID, "CompoundCount":compoundCnt})
|
| | |
|
| | | drDict = {"CompoundID":compoundID, "MakeItemID":makeItemID, "CompoundCount":compoundCnt, "itemExpireTime":itemExpireTime, "PackType":packType}
|
| | | if liantaiInfo:
|
| | | drDict["LiantaiInfo"] = liantaiInfo
|
| | |
|
| | | makeItemBind = False
|
| | |
|
| | |
| | | False, ChConfig.ItemDel_ItemCompound, drDict)
|
| | | makeItemBind = True if hasBind else makeItemBind
|
| | |
|
| | | if canDecompound:
|
| | | decompoundUnfixedItemID = 0 if not unfixedItemIDList else random.choice(unfixedItemIDList) # 拆解时随机返还一件不固定消耗道具
|
| | | decompoundItemInfo.append(decompoundUnfixedItemID)
|
| | | |
| | | # 扣固定消耗物品
|
| | | if fixedItemIDList:
|
| | | for fixedItemID, countInfo in fixedItemNeedCntDict.items():
|
| | |
| | | if delBindCnt:
|
| | | makeItemBind = True
|
| | | ItemCommon.ReduceItem(curPlayer, itemPack, bindFixedIndexList, delBindCnt, False, ChConfig.ItemDel_ItemCompound, drDict)
|
| | | if canDecompound:
|
| | | decompoundItemInfo.append(fixedItemID)
|
| | | decompoundItemInfo.append(delBindCnt)
|
| | | decompoundItemInfo.append(1) # 绑定
|
| | | if delUnBindCnt:
|
| | | ItemCommon.ReduceItem(curPlayer, itemPack, unbindFixedIndexList, delUnBindCnt, False, ChConfig.ItemDel_ItemCompound, drDict)
|
| | | if canDecompound:
|
| | | decompoundItemInfo.append(fixedItemID)
|
| | | decompoundItemInfo.append(delUnBindCnt)
|
| | | decompoundItemInfo.append(0) # 不绑定
|
| | | |
| | | # 扣附加道具
|
| | | if addonsCountMax > 0:
|
| | | for i, addonsItemIndex in enumerate(addonsItemIndexList):
|
| | | hasBind = ItemCommon.ReduceItem(curPlayer, itemPack, [addonsItemIndex], addonsItemCountList[i], |
| | | False, ChConfig.ItemDel_ItemCompound, drDict)
|
| | | #makeItemBind = True if hasBind else makeItemBind #策划说附加材料不决定合成物品是否绑定
|
| | |
|
| | | # 扣提升概率道具
|
| | | if incRateItemCostList:
|
| | |
| | | compoundBindCnt = 1
|
| | |
|
| | | # 给合成物品
|
| | | totalSuccRate = successRate + addSuccRate + incRate
|
| | | totalSuccRate = successRate + incRate
|
| | | if successRateMax:
|
| | | totalSuccRate = min(successRateMax, totalSuccRate)
|
| | | GameWorld.DebugLog("合成成功率: successRate=%s,addSuccRate=%s,incRate=%s,successRateMax=%s,totalSuccRate=%s" |
| | | % (successRate, addSuccRate, incRate, successRateMax, totalSuccRate), playerID)
|
| | | # 前X次合成成功率百分百
|
| | | composeMustSuccessDict = IpyGameDataPY.GetFuncEvalCfg("ComposeMustSuccess", 1, {})
|
| | | if composeGroup in composeMustSuccessDict:
|
| | | mustSuccessCountTotal = composeMustSuccessDict[composeGroup]
|
| | | hisComposeCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ComposeMustSuccess % composeGroup)
|
| | | if hisComposeCount < mustSuccessCountTotal:
|
| | | totalSuccRate = ShareDefine.Def_MaxRateValue
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ComposeMustSuccess % composeGroup, hisComposeCount + 1)
|
| | | GameWorld.DebugLog("前X次合成必定成功!composeGroup=%s,hisComposeCount=%s,mustSuccessCountTotal=%s,totalSuccRate=%s" |
| | | % (composeGroup, hisComposeCount, mustSuccessCountTotal, totalSuccRate), playerID)
|
| | | |
| | | GameWorld.DebugLog("合成成功率: successRate=%s,incRate=%s,successRateMax=%s,totalSuccRate=%s" |
| | | % (successRate, incRate, successRateMax, totalSuccRate), playerID)
|
| | | |
| | | # 合成成功
|
| | | maxRateValue = ShareDefine.Def_MaxRateValue
|
| | | randValue = random.randint(1, maxRateValue)
|
| | | canHappen = randValue <= totalSuccRate
|
| | | GameWorld.DebugLog("canHappen=%s,randValue=%s,totalSuccRate=%s,maxRateValue=%s"
|
| | | % (canHappen, randValue, totalSuccRate, maxRateValue), playerID)
|
| | | if drDict:
|
| | | DataRecordPack.SendEventPack("ItemCompound_Liantai", drDict, curPlayer)
|
| | | #if drDict:
|
| | | # DataRecordPack.SendEventPack("ItemCompound_Liantai", drDict, curPlayer)
|
| | | # 不是百分百成功的记录合成流向
|
| | | if successRate != maxRateValue:
|
| | | drDict = {"PlayerID":curPlayer.GetPlayerID(), "AccID":curPlayer.GetAccID(), "ID":compoundID, "MakeItemID":makeItemID, "IsSuccess":canHappen,
|
| | | "RateInfo":{"totalSuccRate":"%s(%s+%s+%s)" % (totalSuccRate, successRate, addSuccRate, incRate), "randValue":randValue, "maxRateValue":maxRateValue},
|
| | | "AddSuccRateItemInfo":addSuccRateItemInfo, "PackType":packType,
|
| | | "RateInfo":{"totalSuccRate":"%s(%s+%s)" % (totalSuccRate, successRate, incRate), "randValue":randValue, "maxRateValue":maxRateValue},
|
| | | "PackType":packType,
|
| | | }
|
| | | DataRecordPack.SendEventPack("ItemCompound", drDict, curPlayer)
|
| | |
|
| | | if canHappen:
|
| | | GameWorld.DebugLog("合成成功: makeItemID=%s,compoundCnt=%s,compoundBindCnt=%s,itemExpireTime=%s" % (makeItemID, compoundCnt, compoundBindCnt, itemExpireTime), playerID)
|
| | | userData = GiveNewCompoundItem(curPlayer, packType, makeItemID, compoundCnt, compoundBindCnt, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo, itemExpireTime, liantaiInfo)
|
| | | userData = GiveNewCompoundItem(curPlayer, packType, makeItemID, compoundCnt, compoundBindCnt, itemExpireTime)
|
| | |
|
| | | msgMark = ipyData.GetSysMark()
|
| | | paramType = ipyData.GetSysMarkParamType()
|
| | |
| | | PlayerControl.WorldNotify(0, msgMark, [curPlayer.GetName(), fixedItemCountList[0], fixedItemIDList[0], makeItemID, userData])
|
| | | else:
|
| | | PlayerControl.WorldNotify(0, msgMark, [curPlayer.GetName(), makeItemID, userData])
|
| | | |
| | | if isFirstSuccMakeJobItem:
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FirstSuccMakeJobItem % compoundID, 1)
|
| | | GameWorld.DebugLog("标记首次合成成功给本职业物品!", playerID)
|
| | |
|
| | | # 通知合成成功
|
| | | ItemCommon.SyncMakeItemAnswer(curPlayer, ShareDefine.Def_mitItemCompound, ChConfig.Def_ComposeState_Sucess, makeItemID)
|
| | |
| | | # 合成失败
|
| | | else:
|
| | | GameWorld.DebugLog("合成失败!")
|
| | | __SendDogzEquipRemainExpMail(playerID, dogzEquipPlusExp, False)
|
| | | ItemCommon.SyncMakeItemAnswer(curPlayer, ShareDefine.Def_mitItemCompound, ChConfig.Def_ComposeState_Fail, 0)
|
| | | #curPlayer.Sync_MakeItemAnswer(ShareDefine.Def_mitItemCompound, ChConfig.Def_ComposeState_Fail)
|
| | |
|
| | |
| | | def __CheckUnfixedItem(curPlayer, compoundID, makeItemData, itemPack, unfixedItemIndexList, unfixedItemIDList, needUnfixedItemCount):
|
| | | ## 检查不固定消耗道具, 只要客户端提交的数据有不符合要求的,则直接返回 None
|
| | | expireTime = 0
|
| | | wingItemExpInfo = None
|
| | | dogzEquipPlusExp = 0
|
| | | unfixedItemTotalCount = 0
|
| | | unfixedItemCostList = [[], []] # [[绑定索引], [非绑定索引]]
|
| | | maxPackCount = itemPack.GetCount()
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | makeItemID = makeItemData.GetItemTypeID()
|
| | | liantaiDecomposeIDCount, liantaiComposeMakeID, liantaiComposeAllItemIDList, liantaiLegendAttrList, liantaiComposeSkillIDList = 0, 0, [], [], []
|
| | | liantaiDecomposeID = IpyGameDataPY.GetFuncCfg("ComposeLiantai", 1) # 合成莲台碎片ID
|
| | | liantaiComposePreIDList = IpyGameDataPY.GetFuncEvalCfg("ComposeLiantai", 2) # 合并莲台预览ID
|
| | | #makeItemID = makeItemData.GetItemTypeID()
|
| | | for index in unfixedItemIndexList:
|
| | | if index >= maxPackCount:
|
| | | GameWorld.Log("该物品格子索引不存在!无法合成!index=%s,maxPackCount=%s" % (index, maxPackCount), playerID)
|
| | |
| | | itemCount = curItem.GetCount()
|
| | | unfixedItemTotalCount += itemCount
|
| | | unfixedItemCostList[0].append(index) if isBind else unfixedItemCostList[1].append(index)
|
| | | |
| | | #记录翅膀精炼值
|
| | | if curItem.GetType() == ChConfig.Def_ItemType_retWing:
|
| | | wingItemExpInfo = PlayerWing.GetWingItemChangeExp(curItem, ItemCommon.GetItemClassLV(makeItemData))
|
| | | elif ItemCommon.GetIsDogzEquip(curItem):
|
| | | equipExpEff = ItemCommon.GetItemEffectByEffectID(curItem, ChConfig.Def_Effect_DogzEquipPlusExp)
|
| | | baseExp = 0 if not equipExpEff else equipExpEff.GetEffectValue(0)
|
| | | plusExp = curItem.GetUserAttrByIndex(ShareDefine.Def_IudetDogzEquipPlus, 1)
|
| | | dogzEquipPlusExp += (baseExp + plusExp)
|
| | | GameWorld.DebugLog(" 神兽合成材料: index=%s,itemID=%s,baseExp=%s,plusExp=%s" % (index, itemID, baseExp, plusExp))
|
| | | |
| | | #合成莲台碎片
|
| | | if makeItemID == liantaiDecomposeID:
|
| | | liantaiDecomposeIDCount += __GetLiantaiDecomposeIDCount(curItem)
|
| | | #合并莲台
|
| | | elif makeItemID in liantaiComposePreIDList:
|
| | | itemSkillIDList = ItemCommon.GetItemSkillIDList(curItem)
|
| | | for skillID in itemSkillIDList:
|
| | | if skillID in liantaiComposeSkillIDList:
|
| | | GameWorld.Log("合成莲台技能ID重复,无法合成! skillID=%s" % (skillID), playerID)
|
| | | PlayerControl.NotifyCode(curPlayer, "CompoundLiantaiSkillRep", [skillID])
|
| | | return
|
| | | liantaiComposeSkillIDList.append(skillID)
|
| | | |
| | | liantaiComposeMakeID, liantaiLegendAttrList = __GetLiantaiComposeInfo(liantaiComposeMakeID, liantaiComposeAllItemIDList, curItem)
|
| | |
|
| | | if unfixedItemTotalCount < needUnfixedItemCount:
|
| | | GameWorld.Log("不固定消耗道具不足,无法合成!ID=%s,unfixedItemIDList=%s,needUnfixedItemCount=%s > unfixedItemTotalCount=%s"
|
| | | % (compoundID, unfixedItemIDList, needUnfixedItemCount, unfixedItemTotalCount), playerID)
|
| | | return
|
| | |
|
| | | liantaiInfo = [liantaiDecomposeIDCount, liantaiComposeMakeID, liantaiComposeAllItemIDList, liantaiLegendAttrList, liantaiComposeSkillIDList]
|
| | | return unfixedItemCostList, wingItemExpInfo, dogzEquipPlusExp, expireTime, liantaiInfo
|
| | |
|
| | | def __GetLiantaiDecomposeIDCount(curItem):
|
| | | ## 获取合成莲台碎片个数
|
| | | decCountTotal = 0
|
| | | decItemIDList = [curItem.GetItemTypeID()]
|
| | | for i in xrange(curItem.GetUserAttrCount(ShareDefine.Def_IudetLiantaiItemID)):
|
| | | itemID = curItem.GetUserAttrByIndex(ShareDefine.Def_IudetLiantaiItemID, i)
|
| | | if itemID not in decItemIDList:
|
| | | decItemIDList.append(itemID)
|
| | | liantaiDecomposeIDCountDict = IpyGameDataPY.GetFuncEvalCfg("ComposeLiantai", 3, {})
|
| | | for itemID in decItemIDList:
|
| | | for itemIDTuple, decCount in liantaiDecomposeIDCountDict.items():
|
| | | if itemID in itemIDTuple:
|
| | | decCountTotal += decCount
|
| | | return decCountTotal
|
| | |
|
| | | def __GetLiantaiComposeInfo(liantaiComposeMakeID, liantaiComposeAllItemIDList, curItem):
|
| | | ## 获取合成莲台的目标物品ID
|
| | | curItemID = curItem.GetItemTypeID()
|
| | | gameData = GameWorld.GetGameData()
|
| | | |
| | | # 所有合成的莲台ID
|
| | | if curItemID not in liantaiComposeAllItemIDList:
|
| | | liantaiComposeAllItemIDList.append(curItemID)
|
| | | for i in xrange(curItem.GetUserAttrCount(ShareDefine.Def_IudetLiantaiItemID)):
|
| | | itemID = curItem.GetUserAttrByIndex(ShareDefine.Def_IudetLiantaiItemID, i)
|
| | | if itemID not in liantaiComposeAllItemIDList:
|
| | | liantaiComposeAllItemIDList.append(itemID)
|
| | | |
| | | # 获取合成目标莲台ID
|
| | | if not liantaiComposeMakeID:
|
| | | liantaiComposeMakeID = curItemID
|
| | | else:
|
| | | makeLiantaiItemData = gameData.GetItemByTypeID(liantaiComposeMakeID)
|
| | | if makeLiantaiItemData:
|
| | | makeName = makeLiantaiItemData.GetName()
|
| | | curName = curItem.GetName()
|
| | | makeNameIndex, curNameIndex = 0, 0
|
| | | namePriorityList = IpyGameDataPY.GetFuncEvalCfg("ComposeLiantai", 4)
|
| | | for i, nameP in enumerate(namePriorityList):
|
| | | if nameP in makeName:
|
| | | makeNameIndex = i
|
| | | if nameP in curName:
|
| | | curNameIndex = i
|
| | | if curNameIndex > makeNameIndex:
|
| | | liantaiComposeMakeID = curItemID
|
| | | |
| | | # 额外莲台传奇属性
|
| | | liantaiLegendAttrList = []
|
| | | for itemID in liantaiComposeAllItemIDList:
|
| | | if itemID == liantaiComposeMakeID:
|
| | | # 目标莲台不加入额外传奇属性
|
| | | continue
|
| | | itemData = gameData.GetItemByTypeID(itemID)
|
| | | if not itemData:
|
| | | continue
|
| | | |
| | | for effIndex in xrange(itemData.GetEffectCount()):
|
| | | curEff = itemData.GetEffectByIndex(effIndex)
|
| | | effID = curEff.GetEffectID()
|
| | | if effID == 0:
|
| | | break
|
| | | liantaiLegendAttrList.append([effID, curEff.GetEffectValue(0)])
|
| | | # 支持多属性,按属性ID、数值排序
|
| | | if liantaiLegendAttrList:
|
| | | liantaiLegendAttrList.sort(reverse=True)
|
| | | return liantaiComposeMakeID, liantaiLegendAttrList
|
| | | return unfixedItemCostList, expireTime
|
| | |
|
| | | def __CheckFixedItem(playerID, compoundID, itemPack, fixedItemIndexList, fixedItemIDList, fixedItemCountList, compoundCnt):
|
| | | ## 检查固定消耗道具, 只要客户端提交的数据有不符合要求的,则直接返回 None
|
| | |
| | | GameWorld.DebugLog("最终消耗材料个数: %s" % (fixedItemNeedCntDict))
|
| | | return fixedItemIndexDict, fixedItemNeedCntDict, compoundBindCnt, expireTime
|
| | |
|
| | |
|
| | | def __CheckAddonsItem(playerID, compoundID, itemPack, addonsItemIndexList, addonsItemCountList, addonsCountMax):
|
| | | ## 检查附加材料
|
| | | |
| | | # ComposeAddonsType 1|2|3|4|5 0 0 0 0 可附加物品类型
|
| | | # ComposeAddonsQuality 4|2 0 0 0 0 阶数和颜色
|
| | | # ComposeAddonsFormula level*10 0 0 0 0 计算合成时附加材料增加的几率公式
|
| | |
|
| | | addSuccRateItemInfo = []
|
| | | composeAddonsTypeList = IpyGameDataPY.GetFuncEvalCfg("ComposeAddonsType")
|
| | | classLV, color = IpyGameDataPY.GetFuncEvalCfg("ComposeAddonsQuality", 1)
|
| | | ComposeAddonsFormula = IpyGameDataPY.GetFuncCfg("ComposeAddonsFormula")
|
| | | |
| | | maxPackCount = itemPack.GetCount()
|
| | | if len(addonsItemIndexList) != len(addonsItemCountList):
|
| | | GameWorld.Log("附加消耗材料数据错误!无法合成!addonsItemIndexList=%s,addonsItemCountList=%s" |
| | | % (addonsItemIndexList, addonsItemCountList), playerID)
|
| | | return
|
| | | |
| | | expireTime = 0
|
| | | useCount = 0
|
| | | addTotalSuccRate = 0
|
| | | for i, index in enumerate(addonsItemIndexList):
|
| | | if index >= maxPackCount:
|
| | | GameWorld.Log("该物品格子索引不存在!无法合成!index=%s,maxPackCount=%s" % (index, maxPackCount), playerID)
|
| | | return
|
| | | curItem = itemPack.GetAt(index)
|
| | | if not __CheckItemCanUseCompound(playerID, index, curItem):
|
| | | GameWorld.Log("该物品不可使用!无法合成! ID=%s,index=%s" % (compoundID, index), playerID)
|
| | | return
|
| | | |
| | | itemID = curItem.GetItemTypeID()
|
| | | itemType = curItem.GetType()
|
| | | if itemType not in composeAddonsTypeList:
|
| | | GameWorld.Log("该物品类型不可作为附加材料!无法合成! index=%s,itemID=%s,itemType=%s,composeAddonsTypeList=%s" |
| | | % (index, itemID, itemType, composeAddonsTypeList), playerID)
|
| | | return
|
| | | |
| | | itemColor = curItem.GetItemColor()
|
| | | if itemColor < color:
|
| | | GameWorld.Log("该物品颜色不可作为附加材料!无法合成! index=%s,itemID=%s,itemColor=%s < %s" |
| | | % (index, itemID, itemColor, color), playerID)
|
| | | return
|
| | | |
| | | itemColor = curItem.GetItemColor()
|
| | | itemClassLV = ItemCommon.GetItemClassLV(curItem)
|
| | | if itemClassLV < classLV:
|
| | | GameWorld.Log("该物品阶级不可作为附加材料!无法合成! index=%s,itemID=%s,itemClassLV=%s < %s" |
| | | % (index, itemID, itemClassLV, classLV), playerID)
|
| | | return
|
| | | costCount = addonsItemCountList[i]
|
| | | if costCount <= 0 or costCount > curItem.GetCount():
|
| | | GameWorld.Log("该附加物品个数不足,无法合成! index=%s,itemID=%s,costCount=%s" % (index, itemID, costCount), playerID)
|
| | | return
|
| | | useCount += costCount
|
| | | if useCount > addonsCountMax:
|
| | | GameWorld.Log("附加物品总个数超出限制,无法合成! useCount=%s > addonsCountMax=%s" % (useCount, addonsCountMax), playerID)
|
| | | return
|
| | | |
| | | isExpireItem, remainingTime = ItemCommon.GetItemRemainingTime(curItem)
|
| | | if isExpireItem:
|
| | | if not remainingTime:
|
| | | GameWorld.Log("附加材料时效物品已失效,无法合成! index=%s,itemID=%s" % (index, itemID), playerID)
|
| | | return
|
| | | expireTime = remainingTime if not expireTime else min(expireTime, remainingTime)
|
| | | |
| | | addSuccRate = eval(FormulaControl.GetCompileFormula("ComposeAddonsFormula", ComposeAddonsFormula))
|
| | | addTotalSuccRate += (addSuccRate*costCount)
|
| | | addSuccRateItemInfo.append({"ItemID":itemID, "ItemColor":itemColor, "ItemClassLV":itemClassLV, "addSuccRate":addSuccRate, "costCount":costCount})
|
| | | |
| | | return int(addTotalSuccRate), addSuccRateItemInfo, expireTime
|
| | |
|
| | | def __CheckIncRateItem(playerID, compoundID, itemPack, incRateItemIndexList, incRateItemID, needIncRateItemCount):
|
| | | ## 检查提升概率道具, 只要客户端提交的数据有不符合要求的,则直接返回 None
|
| | | expireTime = 0
|
| | |
| | | # @param newItem: 新物品
|
| | | # @param itemCount: 合成数量
|
| | | # @return None
|
| | | def GiveNewCompoundItem(curPlayer, packType, newItemID, itemCount, compoundBindCnt, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo, itemExpireTime, liantaiInfo):
|
| | | def GiveNewCompoundItem(curPlayer, packType, newItemID, itemCount, compoundBindCnt, itemExpireTime):
|
| | | compoundUnBindCnt = itemCount - compoundBindCnt
|
| | |
|
| | | if compoundBindCnt > 0:
|
| | | userData = __GivePlayerCompoundItem(curPlayer, packType, newItemID, compoundBindCnt, True, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo, itemExpireTime, liantaiInfo)
|
| | | userData = __GivePlayerCompoundItem(curPlayer, packType, newItemID, compoundBindCnt, True, itemExpireTime)
|
| | | if compoundUnBindCnt > 0:
|
| | | userData = __GivePlayerCompoundItem(curPlayer, packType, newItemID, compoundUnBindCnt, False, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo, itemExpireTime, liantaiInfo)
|
| | | userData = __GivePlayerCompoundItem(curPlayer, packType, newItemID, compoundUnBindCnt, False, itemExpireTime)
|
| | |
|
| | | if not userData:
|
| | | return ""
|
| | | return userData
|
| | |
|
| | | def __GivePlayerCompoundItem(curPlayer, packType, newItemID, itemCount, isBind, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo, expireTime, liantaiInfo):
|
| | | def __GivePlayerCompoundItem(curPlayer, packType, newItemID, itemCount, isBind, expireTime):
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | if liantaiInfo:
|
| | | liantaiDecomposeIDCount, liantaiComposeMakeID, liantaiComposeAllItemIDList, liantaiLegendAttrList, liantaiComposeSkillIDList = liantaiInfo
|
| | | if liantaiDecomposeIDCount:
|
| | | itemCount = liantaiDecomposeIDCount
|
| | | GameWorld.DebugLog("分解莲台碎片总个数: %s" % liantaiDecomposeIDCount, playerID)
|
| | | if liantaiComposeMakeID:
|
| | | newItemID = liantaiComposeMakeID
|
| | | GameWorld.DebugLog("莲台合成目标莲台物品ID: %s, 所有莲台ID: %s, 额外传奇属性: %s, 所有技能ID: %s" \
|
| | | % (liantaiComposeMakeID, liantaiComposeAllItemIDList, liantaiLegendAttrList, liantaiComposeSkillIDList), playerID)
|
| | | |
| | | curSingleItem = ItemControler.GetOutPutItemObj(newItemID, itemCount, False, expireTime, curPlayer=curPlayer)
|
| | | if not curSingleItem:
|
| | | GameWorld.ErrLog("创造物品失败, give item itemid:%s,count:%s" % (newItemID, itemCount), playerID)
|
| | | return
|
| | |
|
| | | changeTagWingExp, materialItemDict = 0, {}
|
| | | if wingItemExpInfo:
|
| | | changeTagWingExp, materialItemDict = wingItemExpInfo
|
| | | wingFinalExp = changeTagWingExp
|
| | | |
| | | wingProgressExIDList = IpyGameDataPY.GetFuncEvalCfg("WingInitialWashValue", 2)
|
| | | if newItemID in wingProgressExIDList:
|
| | | wingProgressExPerList = IpyGameDataPY.GetFuncEvalCfg("WingInitialWashValue", 1)
|
| | | addPer = GameWorld.GetResultByRandomList(wingProgressExPerList, 0)
|
| | | addValue = PlayerWing.GetWingProgressPerValueByID(newItemID, addPer)
|
| | | wingFinalExp += addValue
|
| | | GameWorld.Log("合成翅膀随机赠送精炼值: newItemID=%s,addPer=%s,addValue=%s,changeTagWingExp=%s,wingFinalExp=%s,materialItemDict=%s" |
| | | % (newItemID, addPer, addValue, changeTagWingExp, wingFinalExp, materialItemDict), playerID)
|
| | | |
| | | if wingFinalExp:#继承翅膀精炼值
|
| | | PlayerWing.WingProgressUP(curSingleItem, wingFinalExp, materialItemDict)
|
| | | if dogzEquipPlusExp:#继承神兽装备熟练度
|
| | | dogzEquipLV, dogzEquipExp = PlayerDogz.GetDogzEquipPlusLVExpInfo(curSingleItem.GetItemColor(), curSingleItem.GetEquipPlace(), dogzEquipPlusExp)
|
| | | curSingleItem.AddUserAttr(ShareDefine.Def_IudetDogzEquipPlus, dogzEquipLV)
|
| | | curSingleItem.AddUserAttr(ShareDefine.Def_IudetDogzEquipPlus, dogzEquipExp)
|
| | | remainExp = max(0, dogzEquipPlusExp - dogzEquipExp)
|
| | | GameWorld.DebugLog("合成神兽装备成功, dogzEquipLV=%s,dogzEquipExp=%s,remainExp=%s,总EXP=%s" |
| | | % (dogzEquipLV, dogzEquipExp, remainExp, dogzEquipPlusExp), playerID)
|
| | | __SendDogzEquipRemainExpMail(playerID, remainExp, True)
|
| | | |
| | | # 保留合成材料消耗,拆解时用
|
| | | if decompoundItemInfo:
|
| | | curSingleItem.ClearUserAttr(ShareDefine.Def_IudetItemDecompound)
|
| | | for decompoundValue in decompoundItemInfo:
|
| | | curSingleItem.AddUserAttr(ShareDefine.Def_IudetItemDecompound, decompoundValue)
|
| | | GameWorld.Log("保存可拆解装备拆解物品信息: %s" % decompoundItemInfo, playerID)
|
| | | |
| | | # 莲台属性
|
| | | if liantaiInfo:
|
| | | if liantaiComposeAllItemIDList:
|
| | | curSingleItem.ClearUserAttr(ShareDefine.Def_IudetLiantaiItemID)
|
| | | for liantaiItemID in liantaiComposeAllItemIDList:
|
| | | curSingleItem.AddUserAttr(ShareDefine.Def_IudetLiantaiItemID, liantaiItemID)
|
| | | |
| | | if liantaiComposeSkillIDList:
|
| | | curSingleItem.ClearUserAttr(ShareDefine.Def_IudetAddSkillID)
|
| | | for skillID in liantaiComposeSkillIDList:
|
| | | curSingleItem.AddUserAttr(ShareDefine.Def_IudetAddSkillID, skillID)
|
| | | |
| | | if liantaiLegendAttrList:
|
| | | curSingleItem.ClearUserAttr(ShareDefine.Def_IudetLegendAttrID)
|
| | | curSingleItem.ClearUserAttr(ShareDefine.Def_IudetLegendAttrValue)
|
| | | for liantaiLegAttrID, liantaiLegAttrValue in liantaiLegendAttrList:
|
| | | curSingleItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrID, liantaiLegAttrID)
|
| | | curSingleItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrValue, liantaiLegAttrValue)
|
| | | |
| | | ItemCommon.MakeEquipGS(curSingleItem)
|
| | | |
| | | userData = curSingleItem.GetUserData()
|
| | | if not ItemControler.PlayerItemControler(curPlayer).PutInItem(packType, curSingleItem, event=[ChConfig.ItemGive_ItemCompound, False, {}]):
|
| | | GameWorld.ErrLog("给合成物品失败, give item itemid:%s,count:%s" % (newItemID, itemCount), playerID)
|
| | | curSingleItem.Clear()
|
| | | return
|
| | |
|
| | | if liantaiInfo and liantaiDecomposeIDCount:
|
| | | PlayerControl.NotifyCode(curPlayer, "DecompoundLiantai", [liantaiDecomposeIDCount, newItemID])
|
| | | |
| | | return userData
|
| | |
|
| | | def __SendDogzEquipRemainExpMail(playerID, remainExp, isSucc):
|
| | | if not remainExp:
|
| | | return
|
| | | |
| | | expItemID = IpyGameDataPY.GetFuncCfg("DogzAssist", 5)
|
| | | itemData = GameWorld.GetGameData().GetItemByTypeID(expItemID)
|
| | | if not itemData:
|
| | | return
|
| | | |
| | | effect = ItemCommon.GetItemEffectByEffectID(itemData, ChConfig.Def_Effect_DogzEquipPlusExp)
|
| | | if not effect:
|
| | | GameWorld.ErrLog("神兽装备合成返回熟练度物品ID错误! expItemID=%s,remainExp=%s" % (expItemID, remainExp), playerID)
|
| | | return
|
| | | baseExp = effect.GetEffectValue(0)
|
| | | if not baseExp:
|
| | | GameWorld.ErrLog("神兽装备合成返回熟练度物品ID错误! expItemID=%s,baseExp=%s,remainExp=%s" |
| | | % (expItemID, baseExp, remainExp), playerID)
|
| | | return
|
| | | |
| | | giveItemCount = int(remainExp/baseExp)
|
| | | if giveItemCount <= 0:
|
| | | return
|
| | | |
| | | mailTypeKey = "DogzComposeSuc" if isSucc else "DogzComposeLose"
|
| | | GameWorld.DebugLog("合成神兽装备, 返还强化熟练度=%s,baseExp=%s,expItemID=%s,giveItemCount=%s" |
| | | % (remainExp, baseExp, expItemID, giveItemCount), playerID)
|
| | | |
| | | isBind = 1
|
| | | PlayerControl.SendMailByKey(mailTypeKey, [playerID], [[expItemID, giveItemCount, isBind]])
|
| | | return
|
| | |
|
| | | #// A3 13 物品拆解 #tagCMItemDecompound
|
| | | #
|