| | |
| | | import ItemCommon
|
| | | import PlayerHero
|
| | | import PyGameData
|
| | | import PlayerTask
|
| | | import ChConfig
|
| | |
|
| | | import random
|
| | |
| | |
|
| | | selectLibItemDict = {} # 重新选择的心愿物品汇总 {libID:[wishID, ...], ...}
|
| | | for wishID in reqSelectWishIDList:
|
| | | if not wishID:
|
| | | continue
|
| | | libItemIpyData = IpyGameDataPY.GetIpyGameDataByCondition("TreasureItemLib", {"ID":wishID}, False)
|
| | | if not libItemIpyData:
|
| | | return
|
| | |
| | | GameWorld.DebugLog("需要激活本体的武将未激活不可选择!itemID=%s" % itemID)
|
| | | return
|
| | |
|
| | | GameWorld.DebugLog("重选心愿库对应ID汇总: %s" % selectLibItemDict)
|
| | | hisOutDict = {} # 历史选择已产出过的心愿物品记录 {wishID:outCnt, ...}
|
| | | for libIDStr, wishCnt in wishLibSelect.items():
|
| | | libID = int(libIDStr)
|
| | | selectLibWishIDList = selectLibItemDict.get(libID, [])
|
| | | if len(selectLibWishIDList) != wishCnt:
|
| | | if selectLibWishIDList and len(selectLibWishIDList) != wishCnt:
|
| | | GameWorld.DebugLog("选择心愿库的物品数量与设定的心愿物品数量不一致!libID=%s,wishCnt=%s,selectCnt=%s,%s"
|
| | | % (libID, wishCnt, len(selectLibWishIDList), selectLibWishIDList))
|
| | | return
|
| | |
| | | GameWorld.DebugLogEx("已经产出过的心愿物品不可从选择中去除! outCnt=%s,wishID=%s not in %s", outCnt, wishID, selectLibWishIDList)
|
| | | return
|
| | | hisOutDict[wishID] = outCnt
|
| | | GameWorld.DebugLog("历史已产出心愿ID次数: %s" % hisOutDict)
|
| | |
|
| | | # 验证通过,保存
|
| | | for libID, wishIDList in selectLibItemDict.items():
|
| | | for wishIndex, wishID in enumerate(wishIDList):
|
| | | for libIDStr, wishCnt in wishLibSelect.items():
|
| | | libID = int(libIDStr)
|
| | | wishIDList = selectLibItemDict.get(libID, [])
|
| | | for wishIndex in range(wishCnt):
|
| | | wishID = wishIDList[wishIndex] if len(wishIDList) > wishIndex else 0
|
| | | outCnt = hisOutDict.get(wishID, 0)
|
| | | SetWishInfo(curPlayer, treasureType, libID, wishIndex, wishID, outCnt)
|
| | | GameWorld.DebugLog("保存心愿选择: libID=%s,wishIndex=%s,wishID=%s,outCnt=%s" % (libID, wishIndex, wishID, outCnt))
|
| | |
| | | maxLuck = max(luckyValueList) if luckyValueList else 0 # 满幸运值
|
| | | updLuck = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreasureLuck % (treasureType)) # 当前幸运值
|
| | | GameWorld.DebugLog("updLuck=%s,maxLuck=%s,setLuckyGridNum=%s,luckyItemRateDict=%s" % (updLuck, maxLuck, setLuckyGridNum, luckyItemRateDict), playerID)
|
| | | |
| | | if treasureType in TreasureType_HeroCallList and not PlayerGoldInvest.GetInvestState(curPlayer, ChConfig.InvestType_Life):
|
| | | addLuck = 0
|
| | | GameWorld.DebugLog("终身卡未开通,武将招募不增加幸运", playerID)
|
| | | |
| | | curTreasureCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreasureCount % (treasureType)) # 当前已寻宝次数
|
| | | updTreasureCount = curTreasureCount
|
| | |
|
| | |
| | | GameWorld.DebugLog("beSureCountDict=%s" % beSureCountDict, playerID)
|
| | | GameWorld.DebugLog("ensureCount=%s, %s" % (ensureCount, ensureRateList), playerID)
|
| | | notifyGridNumList = setIpyData.GetNotifyGridNumList() # 额外需要广播的格子,幸运必出、次数必出可不配置
|
| | | notifyKey = setIpyData.GetNotifyKey()
|
| | | notifyKeyDict = setIpyData.GetNotifyKeyDict()
|
| | | gridNumMaxLimitInfo = setIpyData.GetGridNumMaxLimitInfo() # {"格子":最大可产出次数, ...}
|
| | | gridNumCountInfo = {} # 有限制产出次数的格子已经产出数
|
| | | for gridNumStr in gridNumMaxLimitInfo.keys():
|
| | |
| | | gridLibInfoDict = ipyData.GetGridLibInfo() # 格子编号对应库ID {"编号":物品库ID, ...}
|
| | |
|
| | | # 心愿
|
| | | wishSelectState = False # 心愿物品是否已选择
|
| | | canOutWishDict = {} # 还可产出的心愿物品 {libID:{wishID:[wishIndex, canOut], ...}, ...}
|
| | | wishOutputRule = setIpyData.GetWishOutput() # 心愿产出规则:心愿产出完毕后: 0 - 可继续产出该库物品; 1 - 不可再产出该库物品
|
| | | wishLibSelect = setIpyData.GetWishLibSelect()
|
| | | for libIDStr, selectCnt in wishLibSelect.items():
|
| | | libID = int(libIDStr)
|
| | | if libID not in canOutWishDict:
|
| | | canOutWishDict[libID] = {}
|
| | | for wishIndex in range(selectCnt):
|
| | | wishID, outCnt = GetWishInfo(curPlayer, treasureType, libID, wishIndex)
|
| | | if not wishID:
|
| | | continue
|
| | | wishSelectState = True
|
| | | libItemIpyData = IpyGameDataPY.GetIpyGameDataByCondition("TreasureItemLib", {"ID":wishID}, False)
|
| | | if not libItemIpyData:
|
| | | continue
|
| | |
| | | if not outCntLimit:
|
| | | # 非心愿物品
|
| | | continue
|
| | | if libID not in canOutWishDict:
|
| | | canOutWishDict[libID] = {}
|
| | | if outCnt >= outCntLimit:
|
| | | # 该心愿物品产出次数已用完
|
| | | continue
|
| | | libWishCanOutDict = canOutWishDict[libID]
|
| | | canOut = outCntLimit - outCnt
|
| | | libWishCanOutDict[wishID] = [wishIndex, canOut]
|
| | | if canOutWishDict:
|
| | | if not wishSelectState:
|
| | | if wishLibSelect:
|
| | | if not canOutWishDict:
|
| | | GameWorld.DebugLog("心愿物品还未选择!", playerID)
|
| | | else:
|
| | | GameWorld.DebugLog("还可产出的心愿库对应WishID还可产出次数: %s" % canOutWishDict, playerID)
|
| | | GameWorld.DebugLog("已选的还可产出的心愿库对应WishID还可产出次数: %s" % canOutWishDict, playerID)
|
| | |
|
| | | # 单抽产出优先级: 幸运物品 > 必出 > 保底 > 普通
|
| | | # 连抽没有优先级限制,只要满足条件即可产出
|
| | | luckyOut = False # 幸运物品理论产出状态,不一定是真实产出,可能受终身卡限制
|
| | | getGridResult = []
|
| | | for tIndex in range(treasureCount):
|
| | | updLuck = min(updLuck + addLuck, maxLuck)
|
| | |
| | |
|
| | | # 满幸运必出
|
| | | if not curRateList and stageLuck and updLuck >= stageLuck and luckItemRateList:
|
| | | luckyOut = True
|
| | | if treasureType in TreasureType_HeroCallList and not PlayerGoldInvest.GetInvestState(curPlayer, ChConfig.InvestType_Life):
|
| | | GameWorld.DebugLog(" 【满幸运必出饼图】: 终身卡未开通,武将招募幸运不产出", playerID)
|
| | | else:
|
| | | curRateList = GetRemoveLimitGridRateList(luckItemRateList, gridNumCountInfo, gridNumMaxLimitInfo)
|
| | | GameWorld.DebugLog(" 【满幸运必出饼图】: %s" % curRateList, playerID)
|
| | | |
| | | curRateList = GetRemoveLimitGridRateList(luckItemRateList, gridNumCountInfo, gridNumMaxLimitInfo)
|
| | | GameWorld.DebugLog(" 【满幸运必出饼图】: %s" % curRateList, playerID)
|
| | | |
| | | # 次数必出
|
| | | if not curRateList and updTreasureCount in beSureCountDict:
|
| | | besureGridRateList = beSureCountDict[updTreasureCount]
|
| | |
| | |
|
| | | getGridResult.append(gridNum)
|
| | | GameWorld.DebugLog(" 本次产出: gridNum=%s, %s, doCount=%s" % (gridNum, getGridResult, doCount), playerID)
|
| | | if gridNum in luckyGridNumList or luckyOut:
|
| | | luckyOut = False
|
| | | if gridNum == setLuckyGridNum or updLuck >= maxLuck:
|
| | | if gridNum in luckyGridNumList or updLuck >= maxLuck:
|
| | | if addLuck:
|
| | | if gridNum == setLuckyGridNum or updLuck >= maxLuck:
|
| | | updLuck = 0
|
| | | else:
|
| | | updLuck = stageLuck # 直接切换到下一阶段幸运
|
| | | else:
|
| | | updLuck = 0
|
| | | else:
|
| | | updLuck = stageLuck # 直接切换到下一阶段幸运
|
| | | if gridNum in luckyGridNumList:
|
| | | GameWorld.DebugLog(" 【产出幸运格子】: gridNum=%s,updLuck=%s" % (gridNum, updLuck), playerID)
|
| | | else:
|
| | | GameWorld.DebugLog(" 【理论产出幸运格子,实际没有产出】: gridNum=%s,updLuck=%s,luckyGridNumList=%s" % (gridNum, updLuck, luckyGridNumList), playerID)
|
| | | GameWorld.DebugLog(" 不加幸运时强制重置幸运值: gridNum=%s,updLuck=%s" % (gridNum, updLuck), playerID)
|
| | | GameWorld.DebugLog(" 【产出幸运格子】: gridNum=%s,updLuck=%s" % (gridNum, updLuck), playerID)
|
| | | if wishLibID:
|
| | | GameWorld.DebugLog(" 【产出的是心愿库物品】: gridNum=%s,wishLibID=%s" % (gridNum, wishLibID), playerID)
|
| | |
|
| | |
| | | PlayerControl.GiveMoney(curPlayer, addScoreType, addScore * treasureCount)
|
| | |
|
| | | if treasureType in TreasureType_HeroCallList:
|
| | | PlayerTask.AddTaskValue(curPlayer, ChConfig.TaskType_HeroCall, treasureCount)
|
| | | PlayerActivity.AddDailyTaskValue(curPlayer, ChConfig.DailyTask_HeroCall, treasureCount)
|
| | | heroCallCnt = GetHeroCallCnt(curPlayer)
|
| | | if OpenServerActivity.GetOSAState(curPlayer, ShareDefine.Def_BT_OSA_HeroCall) == 1:
|
| | |
| | | itemObj = ItemControler.GetOutPutItemObj(itemID, itemCount, isBind, curPlayer=curPlayer)
|
| | | mailItemDict = ItemCommon.GetMailItemDict(itemObj)
|
| | |
|
| | | if int(gridNum) in notifyGridNumList and notifyKey:
|
| | | if int(gridNum) in notifyGridNumList and notifyKeyDict:
|
| | | notifyKey = notifyKeyDict.get(int(gridNum), notifyKeyDict.get(0, ""))
|
| | | if treasureType in TreasureType_HeroCallList:
|
| | | if PlayerHero.GetHeroActivite(curPlayer, itemID):
|
| | | notifyKey = ""
|
| | | GameWorld.DebugLog("招募武将非首次获得的不广播了! itemID=%s" % itemID, playerID)
|
| | | else:
|
| | | elif notifyKey:
|
| | | heroIpyData = IpyGameDataPY.GetIpyGameData("Hero", itemID)
|
| | | if heroIpyData:
|
| | | heroQuality = heroIpyData.GetQuality()
|
| | | PlayerControl.WorldNotify(0, notifyKey, [curPlayer.GetPlayerName(), heroQuality, itemID])
|
| | | else:
|
| | | elif notifyKey:
|
| | | PlayerControl.WorldNotify(0, notifyKey, [curPlayer.GetPlayerName(), itemID, itemObj.GetUserData(), itemCount])
|
| | |
|
| | | if mailItemList or not itemControl.PutInItem(packType, itemObj, event=[ChConfig.ItemGive_Treasure, False, {}]):
|