| | |
| | | if useAwakeLV:
|
| | | GameWorld.DebugLog("材料卡觉醒等级不为0暂时无法升星!useAwakeLV=%s" % (useAwakeLV), playerID)
|
| | | return
|
| | | useHeroLV = useItem.GetUserAttr(ShareDefine.Def_IudetHeroLV)
|
| | | useBreakLV = useItem.GetUserAttr(ShareDefine.Def_IudetHeroBreakLV)
|
| | | if useHeroLV > 1 or useBreakLV:
|
| | | GameWorld.DebugLog("材料卡已升级或突破暂时无法升星!useHeroLV=%s,useBreakLV=%s" % (useHeroLV, useBreakLV), playerID)
|
| | | return
|
| | |
|
| | | heroIpyData = IpyGameDataPY.GetIpyGameData("Hero", heroID)
|
| | | if not heroIpyData:
|
| | |
| | | useStar = useItem.GetUserAttr(ShareDefine.Def_IudetHeroStar)
|
| | | addStar = useStar + 1
|
| | | updStar = star + addStar
|
| | | useHeroLV = useItem.GetUserAttr(ShareDefine.Def_IudetHeroLV)
|
| | | useBreakLV = useItem.GetUserAttr(ShareDefine.Def_IudetHeroBreakLV)
|
| | | GameWorld.DebugLog("武将升星: itemIndex=%s,heroID=%s,star=%s,useStar=%s,addStar=%s,updStar=%s,useHeroLV=%s,useBreakLV=%s" |
| | | % (itemIndex, heroID, star, useStar, addStar, updStar, useHeroLV, useBreakLV), playerID)
|
| | | GameWorld.DebugLog("武将升星: itemIndex=%s,heroID=%s,star=%s,useStar=%s,addStar=%s,updStar=%s" |
| | | % (itemIndex, heroID, star, useStar, addStar, updStar), playerID)
|
| | | ItemCommon.DelItem(curPlayer, useItem, useItem.GetCount(), False, "HeroStarUP")
|
| | | DoHeroUpdStar(curPlayer, heroItem, updStar)
|
| | | |
| | | returnItemDict = {}
|
| | | if useHeroLV > 1:
|
| | | __calcHeroLVReturnitem(quality, useHeroLV, returnItemDict)
|
| | | if useBreakLV:
|
| | | __calcHeroBreakReturnitem(quality, useBreakLV, returnItemDict)
|
| | | if returnItemDict:
|
| | | returnItemList = [[k, v] for k, v in returnItemDict.items()]
|
| | | ItemControler.GivePlayerItemOrMail(curPlayer, returnItemList, event=["HeroStarUP", False, {}])
|
| | | |
| | | return
|
| | |
|
| | | def GetHeroStarMax(heroItem):
|
| | |
| | | return 0
|
| | | InitStarUpper = qualityIpyData.GetInitStarUpper()
|
| | |
|
| | | awakeLV = heroItem.GetUserAttr(ShareDefine.Def_IudetHeroAwakeLV)
|
| | | if not awakeLV:
|
| | | return InitStarUpper
|
| | | |
| | | addStarUpper = 0
|
| | | heroAwakeIpyDataList = IpyGameDataPY.GetIpyGameDataList("HeroAwake", heroID)
|
| | | heroAwakeIpyDataList = IpyGameDataPY.GetIpyGameDataListNotLog("HeroAwake", heroID)
|
| | | if heroAwakeIpyDataList:
|
| | | awakeLV = heroItem.GetUserAttr(ShareDefine.Def_IudetHeroAwakeLV)
|
| | | for ipyData in heroAwakeIpyDataList:
|
| | | if ipyData.GetAwakeLV() > awakeLV:
|
| | | break
|
| | |
| | | def __DoHeroStarTalentUp(singleItem, addLV):
|
| | | ## 执行武将星级天赋等级提升
|
| | |
|
| | | heroID = singleItem.GetItemTypeID()
|
| | | commTalentSlot = IpyGameDataPY.GetFuncCfg("HeroStarTalent", 1) # 常规天赋槽个数
|
| | | talentMaxLV = IpyGameDataPY.GetFuncCfg("HeroStarTalent", 2) # 每个天赋最大等级
|
| | | |
| | | maxUnlockSlot = commTalentSlot # 最大有效的已解锁槽位
|
| | | awakeIpyDataList = IpyGameDataPY.GetIpyGameDataListNotLog("HeroAwake", heroID)
|
| | | if awakeIpyDataList:
|
| | | awakeLV = singleItem.GetUserAttr(ShareDefine.Def_IudetHeroAwakeLV)
|
| | | for ipyData in awakeIpyDataList[:awakeLV][::-1]: # 倒序遍历,第一个命中的就是最大的
|
| | | unlockTalentSlot = ipyData.GetUnlockTalentSlot()
|
| | | if unlockTalentSlot and unlockTalentSlot :
|
| | | maxUnlockSlot = unlockTalentSlot
|
| | | break
|
| | | |
| | | idCount = singleItem.GetUserAttrCount(ShareDefine.Def_IudetHeroTalentID)
|
| | | lvCount = singleItem.GetUserAttrCount(ShareDefine.Def_IudetHeroTalentIDLV)
|
| | | idList, lvList = [], [] # 记录在物品上的值,有顺序
|
| | | unfullLVIDList = [] # 未满级的天赋ID
|
| | | unfullLVIDListUnlock = [] # 未满级的天赋ID,仅已解锁槽位,重生可能导致觉醒已解锁槽位暂时被锁住
|
| | | haveUp = False
|
| | | for index in range(min(idCount, lvCount)):
|
| | | talentID = singleItem.GetUserAttrByIndex(ShareDefine.Def_IudetHeroTalentID, index)
|
| | |
| | | lvList.append(talentLV)
|
| | | if talentLV < talentMaxLV:
|
| | | unfullLVIDList.append(talentID)
|
| | | |
| | | if index < maxUnlockSlot:
|
| | | unfullLVIDListUnlock.append(talentID)
|
| | | |
| | | if len(idList) < commTalentSlot:
|
| | | idList += [0] * (commTalentSlot - len(idList))
|
| | | lvList += [0] * (commTalentSlot - len(lvList))
|
| | |
|
| | | GameWorld.DebugLog("执行武将星级天赋等级提升: addLV=%s" % addLV)
|
| | | GameWorld.DebugLog("当前星级天赋: idList=%s,lvList=%s" % (idList, lvList))
|
| | | GameWorld.DebugLog("未满级星级天赋ID: %s" % unfullLVIDList)
|
| | | GameWorld.DebugLog("当前星级天赋: idList=%s,lvList=%s,maxUnlockSlot=%s" % (idList, lvList, maxUnlockSlot))
|
| | | GameWorld.DebugLog("未满级星级天赋ID: %s,unfullLVIDListUnlock=%s" % (unfullLVIDList, unfullLVIDListUnlock))
|
| | |
|
| | | # 有空余槽位,优先给空余槽位天赋,额外解锁的槽位是需要先选择的,所以一定不为空,故这里只判断常规槽位即可
|
| | | if 0 in idList:
|
| | |
| | | idList[zeroIndex] = randTalentID
|
| | | lvList[zeroIndex] = 1
|
| | | unfullLVIDList.append(randTalentID)
|
| | | unfullLVIDListUnlock.append(randTalentID)
|
| | | GameWorld.DebugLog("新增星级天赋ID: %s" % (randTalentID))
|
| | | addLV -= 1
|
| | | haveUp = True
|
| | |
| | | for _ in range(addLV):
|
| | | if not unfullLVIDList:
|
| | | break
|
| | | randID = random.choice(unfullLVIDList)
|
| | | # 优先随机已解锁的
|
| | | randID = random.choice(unfullLVIDListUnlock) if unfullLVIDListUnlock else random.choice(unfullLVIDList)
|
| | | if randID not in idList:
|
| | | unfullLVIDList.remove(randID)
|
| | | continue
|
| | | randIndex = idList.index(randID)
|
| | | idLV = lvList[randIndex]
|
| | |
| | | GameWorld.DebugLog("升级星级天赋ID: %s,idLV=%s,index=%s" % (randID, idLV, randIndex))
|
| | |
|
| | | if idLV >= talentMaxLV:
|
| | | unfullLVIDList.remove(randID)
|
| | | GameWorld.DebugLog(" 移除未满级ID: %s,unfullLVIDList=%s" % (randID, unfullLVIDList))
|
| | | if randID in unfullLVIDList:
|
| | | unfullLVIDList.remove(randID)
|
| | | if randID in unfullLVIDListUnlock:
|
| | | unfullLVIDListUnlock.remove(randID)
|
| | | GameWorld.DebugLog(" 移除满级ID: %s,unfullLVIDList=%s,unfullLVIDListUnlock=%s" % (randID, unfullLVIDList, unfullLVIDListUnlock))
|
| | |
|
| | | haveUp = True
|
| | |
|
| | |
| | | ## 觉醒解锁天赋槽
|
| | | heroID = singleItem.GetItemTypeID()
|
| | | awakeLV = singleItem.GetUserAttr(ShareDefine.Def_IudetHeroAwakeLV)
|
| | | awakeIpyDataList = IpyGameDataPY.GetIpyGameDataList("HeroAwake", heroID)
|
| | | awakeIpyDataList = IpyGameDataPY.GetIpyGameDataListNotLog("HeroAwake", heroID)
|
| | | if not awakeIpyDataList:
|
| | | return
|
| | | maxUnlockSlot = 0
|
| | |
| | | if awardMoneyInfo and len(awardMoneyInfo) == 2:
|
| | | moneyType, moneyValue = awardMoneyInfo
|
| | | if moneyType and moneyValue:
|
| | | PlayerControl.GiveMoney(curPlayer, moneyType, moneyValue, "HeroBookAct")
|
| | | PlayerControl.GiveMoney(curPlayer, moneyType, moneyValue, "HeroBookAct", notifyAward=True)
|
| | |
|
| | | Sync_HeroInfo(curPlayer, [heroID])
|
| | |
|
| | |
| | | if not heroIpyData:
|
| | | return
|
| | | quality = heroIpyData.GetQuality()
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("HeroQualityAwake", quality, awakeLV)
|
| | | if not ipyData:
|
| | | return
|
| | | costMoney = ipyData.GetRebirthCostMoney()
|
| | | qualityAwakeIpyData = IpyGameDataPY.GetIpyGameDataNotLog("HeroQualityAwake", quality, awakeLV)
|
| | | awakeCostMoney = qualityAwakeIpyData.GetRebirthCostMoney() if qualityAwakeIpyData else 0
|
| | | moneyType = IpyGameDataPY.GetFuncCfg("HeroRebirth", 1)
|
| | | if moneyType and costMoney and not PlayerControl.HaveMoney(curPlayer, moneyType, costMoney):
|
| | | lvCostMoney = int(eval(IpyGameDataPY.GetFuncCompileCfg("HeroRebirth", 3)))
|
| | | costMoneyTotal = lvCostMoney + awakeCostMoney
|
| | | GameWorld.DebugLog("武将重生: itemIndex=%s,heroID=%s,quality=%s,heroLV=%s,breakLV=%s,awakeLV=%s,costMoneyTotal=%s(%s+%s)" |
| | | % (itemIndex, heroID, quality, heroLV, breakLV, awakeLV, costMoneyTotal, lvCostMoney, awakeCostMoney))
|
| | | if moneyType and costMoneyTotal and not PlayerControl.HaveMoney(curPlayer, moneyType, costMoneyTotal):
|
| | | return
|
| | |
|
| | | # 验证通过,可以重生
|
| | | GameWorld.DebugLog("武将重生: itemIndex=%s,heroID=%s,quality=%s,heroLV=%s,breakLV=%s,awakeLV=%s" |
| | | % (itemIndex, heroID, quality, heroLV, breakLV, awakeLV))
|
| | | |
| | | ratio = IpyGameDataPY.GetFuncCfg("HeroRebirth", 4)
|
| | | returnItemDict = {}
|
| | | __calcHeroLVReturnitem(quality, heroLV, returnItemDict)
|
| | | __calcHeroBreakReturnitem(quality, breakLV, returnItemDict)
|
| | | __calcHeroAwakeReturnitem(quality, awakeLV, returnItemDict)
|
| | | __calcHeroLVReturnitem(quality, heroLV, returnItemDict, ratio)
|
| | | __calcHeroBreakReturnitem(quality, breakLV, returnItemDict, ratio)
|
| | | __calcHeroAwakeReturnitem(quality, awakeLV, returnItemDict, ratio)
|
| | |
|
| | | if moneyType and costMoney and not PlayerControl.PayMoney(curPlayer, moneyType, costMoney, "HeroRebirth"):
|
| | | if moneyType and costMoneyTotal and not PlayerControl.PayMoney(curPlayer, moneyType, costMoneyTotal, "HeroRebirth"):
|
| | | return
|
| | |
|
| | | # 执行重生
|
| | |
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_HeroAwakeRebirthCnt, rebirthCnt + 1)
|
| | | Sync_PlayerHeroInfo(curPlayer)
|
| | |
|
| | | PlayerOnline.GetOnlinePlayer(curPlayer).OnHeroItemUpate([itemIndex])
|
| | | return
|
| | |
|
| | | def __calcHeroLVReturnitem(quality, heroLV, returnItemDict):
|
| | | def __calcHeroLVReturnitem(quality, heroLV, returnItemDict, ratio):
|
| | | ## 计算武将等级返还
|
| | | returnDict = {}
|
| | | for retLV in range(1, heroLV):
|
| | |
| | | if not costItemInfo:
|
| | | continue
|
| | | costItemID, costItemCount = costItemInfo
|
| | | costItemCount = max(1, int(costItemCount * ratio / 100.0))
|
| | | returnItemDict[costItemID] = returnItemDict.get(costItemID, 0) + costItemCount
|
| | | returnDict[costItemID] = returnDict.get(costItemID, 0) + costItemCount
|
| | | GameWorld.DebugLog(" 等级返还: quality=%s,heroLV=%s,%s,总%s" % (quality, heroLV, returnDict, returnItemDict))
|
| | | GameWorld.DebugLog(" 等级返还: quality=%s,heroLV=%s,ratio=%s,%s,总%s" % (quality, heroLV, ratio, returnDict, returnItemDict))
|
| | | return
|
| | |
|
| | | def __calcHeroBreakReturnitem(quality, breakLV, returnItemDict):
|
| | | def __calcHeroBreakReturnitem(quality, breakLV, returnItemDict, ratio):
|
| | | # 计算武将突破返还
|
| | | returnDict = {}
|
| | | for retBreakLV in range(0, breakLV):
|
| | |
| | | if not costItemInfo:
|
| | | continue
|
| | | costItemID, costItemCount = costItemInfo
|
| | | costItemCount = max(1, int(costItemCount * ratio / 100.0))
|
| | | returnItemDict[costItemID] = returnItemDict.get(costItemID, 0) + costItemCount
|
| | | returnDict[costItemID] = returnDict.get(costItemID, 0) + costItemCount
|
| | | GameWorld.DebugLog(" 突破返还: quality=%s,breakLV=%s,%s,总%s" % (quality, breakLV, returnDict, returnItemDict))
|
| | | GameWorld.DebugLog(" 突破返还: quality=%s,breakLV=%s,ratio=%s,%s,总%s" % (quality, breakLV, ratio, returnDict, returnItemDict))
|
| | | return
|
| | |
|
| | | def __calcHeroAwakeReturnitem(quality, awakeLV, returnItemDict):
|
| | | def __calcHeroAwakeReturnitem(quality, awakeLV, returnItemDict, ratio):
|
| | | # 计算武将觉醒返还
|
| | | returnDict = {}
|
| | | for retAwakeLV in range(0, awakeLV):
|
| | |
| | | if not costItemInfo:
|
| | | continue
|
| | | costItemID, costItemCount = costItemInfo
|
| | | costItemCount = max(1, int(costItemCount * ratio / 100.0))
|
| | | returnItemDict[costItemID] = returnItemDict.get(costItemID, 0) + costItemCount
|
| | | returnDict[costItemID] = returnDict.get(costItemID, 0) + costItemCount
|
| | | GameWorld.DebugLog(" 觉醒返还: quality=%s,awakeLV=%s,%s,总%s" % (quality, awakeLV, returnDict, returnItemDict))
|
| | | GameWorld.DebugLog(" 觉醒返还: quality=%s,awakeLV=%s,ratio=%s,%s,总%s" % (quality, awakeLV, ratio, returnDict, returnItemDict))
|
| | | return
|
| | |
|
| | | #// B2 40 武将遣散 #tagCSHeroDismiss
|
| | |
| | | itemIndexList = clientData.ItemIndexList
|
| | | GameWorld.DebugLog("武将遣散: itemIndexList=%s" % itemIndexList)
|
| | |
|
| | | ratio = IpyGameDataPY.GetFuncCfg("HeroRebirth", 5)
|
| | | dismissItemList = []
|
| | | returnItemDict = {}
|
| | | curPack = curPlayer.GetItemManager().GetPack(ShareDefine.rptHero)
|
| | |
| | | GameWorld.DebugLog("Dzɢ: itemIndex=%s,heroID=%s,quality=%s,heroLV=%s,breakLV=%s,heroStar=%s" % (itemIndex, heroID, quality, heroLV, breakLV, heroStar))
|
| | | dismissReturnItems = qualityIpyData.GetDismissReturnItems()
|
| | | for itemID, itemCount in dismissReturnItems:
|
| | | starRetCnt = (heroStar + 1) * itemCount
|
| | | starRetCnt = max(1, int((heroStar + 1) * itemCount * ratio / 100.0))
|
| | | returnItemDict[itemID] = returnItemDict.get(itemID, 0) + starRetCnt
|
| | | GameWorld.DebugLog(" 星级返还: quality=%s,heroStar=%s,%s,总%s" % (quality, heroStar, dismissReturnItems, returnItemDict))
|
| | | __calcHeroLVReturnitem(quality, heroLV, returnItemDict)
|
| | | __calcHeroBreakReturnitem(quality, breakLV, returnItemDict)
|
| | | GameWorld.DebugLog(" 星级返还: quality=%s,heroStar=%s,ratio=%s,%s,总%s" % (quality, heroStar, ratio, dismissReturnItems, returnItemDict))
|
| | | __calcHeroLVReturnitem(quality, heroLV, returnItemDict, ratio)
|
| | | __calcHeroBreakReturnitem(quality, breakLV, returnItemDict, ratio)
|
| | | dismissItemList.append([itemIndex, heroItem])
|
| | |
|
| | | if not dismissItemList:
|