| | |
| | |
|
| | | import GameWorld
|
| | | import PlayerRune
|
| | | import IPY_GameWorld
|
| | | import IpyGameDataPY
|
| | | import FormulaControl
|
| | | import ChPyNetSendPack
|
| | |
| | | import ItemCommon
|
| | | import PlayerHero
|
| | | import PyGameData
|
| | | import PlayerTask
|
| | | import ChConfig
|
| | |
|
| | | import random
|
| | |
| | | # 每日心愿重置
|
| | | wishLibSelect = ipyData.GetWishLibSelect()
|
| | | wishReset = ipyData.GetWishReset()
|
| | | if wishReset == 1:
|
| | | for libIDStr, wishCnt in wishLibSelect.items():
|
| | | for wishIndex in range(wishCnt):
|
| | | wishID, outCnt = GetWishInfo(curPlayer, treasureType, libIDStr, wishIndex)
|
| | | SetWishInfo(curPlayer, treasureType, libIDStr, wishIndex, wishID, 0)
|
| | | GameWorld.DebugLog("寻宝每日心愿重置: treasureType=%s,libID=%s,wishIndex=%s,wishID=%s,昨日心愿产出次数=%s" |
| | | % (treasureType, libIDStr, wishIndex, wishID, outCnt))
|
| | | |
| | | if wishReset == 1 and wishLibSelect:
|
| | | for libIDStr in wishLibSelect.keys():
|
| | | libID = int(libIDStr)
|
| | | libItemList = IpyGameDataPY.GetIpyGameDataList("TreasureItemLib", libID)
|
| | | if not libItemList:
|
| | | continue
|
| | | for libItem in libItemList:
|
| | | wishID = libItem.GetID()
|
| | | outCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreasureWishOut % (treasureType, wishID))
|
| | | if not outCnt:
|
| | | continue
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TreasureWishOut % (treasureType, wishID), 0)
|
| | | GameWorld.DebugLog("寻宝每日心愿重置: treasureType=%s,libID=%s,wishID=%s,昨日心愿产出次数=%s" % (treasureType, libID, wishID, outCnt))
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TreasureWishLibOut % (treasureType, libID), 0)
|
| | | |
| | | if syncTypeList:
|
| | | Sync_TreasureInfo(curPlayer, syncTypeList)
|
| | | return
|
| | |
| | | return True
|
| | | return False
|
| | |
|
| | | def GetWishInfo(curPlayer, treasureType, libID, wishIndex):
|
| | | ## 心愿信息
|
| | | # @return: 心愿ID, 已产出次数
|
| | | info = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreasureWish % (treasureType, libID, wishIndex))
|
| | | wishID, outCnt = info / 100, info % 100
|
| | | return wishID, outCnt
|
| | | def SetWishInfo(curPlayer, treasureType, libID, wishIndex, wishID, outCnt):
|
| | | info = wishID * 100 + min(outCnt, 99)
|
| | | info = PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TreasureWish % (treasureType, libID, wishIndex), info)
|
| | | return info
|
| | |
|
| | | #// A5 69 寻宝心愿物品选择 #tagCSTreasureWishSelect
|
| | | #
|
| | | #struct tagCSTreasureWishSelect
|
| | |
| | | # tagHead Head;
|
| | | # BYTE TreasureType; //寻宝类型
|
| | | # BYTE WishCnt;
|
| | | # WORD WishIDList[WishCnt]; // 选择的寻宝物品库中的数据ID,注意不是库ID
|
| | | # DWORD WishIDList[WishCnt]; // 选择的寻宝物品库中的数据ID,注意不是库ID
|
| | | # BYTE WishCardUseCnt;
|
| | | # WORD WishCardUseLibIDList[WishCardUseCnt]; // 使用心愿卡的库ID列表
|
| | | #};
|
| | | def OnTreasureWishSelect(index, clientData, tick):
|
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | | treasureType = clientData.TreasureType
|
| | | reqSelectWishIDList = clientData.WishIDList
|
| | | wishCardUseLibIDList = clientData.WishCardUseLibIDList
|
| | |
|
| | | setIpyData = IpyGameDataPY.GetIpyGameData("TreasureSet", treasureType)
|
| | | if not setIpyData:
|
| | | return
|
| | | wishLibSelect = setIpyData.GetWishLibSelect() |
| | | wishLibSelect = setIpyData.GetWishLibSelect()
|
| | | if not wishLibSelect:
|
| | | GameWorld.DebugLog("该寻宝类型没有心愿物品功能! treasureType=%s" % (treasureType))
|
| | | return
|
| | |
| | |
|
| | | selectLibItemDict = {} # 重新选择的心愿物品汇总 {libID:[wishID, ...], ...}
|
| | | for wishID in reqSelectWishIDList:
|
| | | if not wishID:
|
| | | continue
|
| | | libItemIpyData = IpyGameDataPY.GetIpyGameDataByCondition("TreasureItemLib", {"ID":wishID}, False)
|
| | | if not libItemIpyData:
|
| | | return
|
| | |
|
| | | itemID = libItemIpyData.GetItemID()
|
| | | if not libItemIpyData.GetWishOutCnt():
|
| | | if not libItemIpyData.GetIsWishItem():
|
| | | GameWorld.DebugLog("非心愿物品,不可选择! wishID=%s" % (wishID))
|
| | | return
|
| | |
|
| | |
| | | GameWorld.DebugLog("需要激活本体的武将未激活不可选择!itemID=%s" % itemID)
|
| | | return
|
| | |
|
| | | hisOutDict = {} # 历史选择已产出过的心愿物品记录 {wishID:outCnt, ...}
|
| | | # 公共次数模式,不限制切换
|
| | | if setIpyData.GetWishLibPubFreeCnt():
|
| | | # 无限制,直接保存
|
| | | pass
|
| | | |
| | | # 独立次数模式,有产出后的心愿物品无法切换
|
| | | else: |
| | | GameWorld.DebugLog("重选心愿库对应ID汇总: %s" % selectLibItemDict)
|
| | | for libIDStr, wishCnt in wishLibSelect.items():
|
| | | libID = int(libIDStr)
|
| | | selectLibWishIDList = selectLibItemDict.get(libID, [])
|
| | | if selectLibWishIDList and len(selectLibWishIDList) != wishCnt:
|
| | | GameWorld.DebugLog("选择心愿库的物品数量与设定的心愿物品数量不一致!libID=%s,wishCnt=%s,selectCnt=%s,%s" |
| | | % (libID, wishCnt, len(selectLibWishIDList), selectLibWishIDList))
|
| | | return
|
| | | |
| | | libItemList = IpyGameDataPY.GetIpyGameDataList("TreasureItemLib", libID)
|
| | | if not libItemList:
|
| | | return
|
| | | for libItem in libItemList:
|
| | | wishID = libItem.GetID()
|
| | | outCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreasureWishOut % (treasureType, wishID))
|
| | | if not outCnt:
|
| | | continue
|
| | | if wishID not in selectLibWishIDList:
|
| | | GameWorld.DebugLogEx("已经产出过的心愿物品不可从选择中去除! outCnt=%s,wishID=%s not in %s", outCnt, wishID, selectLibWishIDList)
|
| | | return
|
| | | |
| | | # 验证通过,保存
|
| | | for libIDStr, wishCnt in wishLibSelect.items():
|
| | | libID = int(libIDStr)
|
| | | selectLibWishIDList = selectLibItemDict.get(libID, [])
|
| | | if len(selectLibWishIDList) != wishCnt:
|
| | | GameWorld.DebugLog("选择心愿库的物品数量与设定的心愿物品数量不一致!libID=%s,wishCnt=%s,selectCnt=%s,%s" |
| | | % (libID, wishCnt, len(selectLibWishIDList), selectLibWishIDList))
|
| | | return
|
| | | |
| | | wishIDList = selectLibItemDict.get(libID, [])
|
| | | for wishIndex in range(wishCnt):
|
| | | wishID, outCnt = GetWishInfo(curPlayer, treasureType, libID, wishIndex)
|
| | | if not outCnt:
|
| | | continue
|
| | | if wishID not in selectLibWishIDList:
|
| | | GameWorld.DebugLogEx("已经产出过的心愿物品不可从选择中去除! outCnt=%s,wishID=%s not in %s", outCnt, wishID, selectLibWishIDList)
|
| | | return
|
| | | hisOutDict[wishID] = outCnt
|
| | | wishID = wishIDList[wishIndex] if len(wishIDList) > wishIndex else 0
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TreasureWishSelect % (treasureType, libIDStr, wishIndex), wishID)
|
| | | GameWorld.DebugLog("保存心愿选择: libID=%s,wishIndex=%s,wishID=%s" % (libID, wishIndex, wishID))
|
| | |
|
| | | # 验证通过,保存
|
| | | for libID, wishIDList in selectLibItemDict.items():
|
| | | for wishIndex, wishID in enumerate(wishIDList):
|
| | | 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))
|
| | | |
| | | isUse = 1 if libID in wishCardUseLibIDList else 0
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TreasureWishUseItem % (treasureType, libID), isUse)
|
| | | GameWorld.DebugLog("保存心愿卡是否使用: libID=%s,isUse=%s" % (libID, isUse))
|
| | | |
| | | Sync_TreasureInfo(curPlayer, [treasureType])
|
| | | return
|
| | |
|
| | |
| | | gridItemInfoDict = ipyData.GetGridItemInfo() # 格子对应物品信息 {"格子编号":[物品ID, 数量], ...}
|
| | | gridLibInfoDict = ipyData.GetGridLibInfo() # 格子编号对应库ID {"编号":物品库ID, ...}
|
| | |
|
| | | # 心愿
|
| | | wishSelectState = False # 心愿物品是否已选择
|
| | | canOutWishDict = {} # 还可产出的心愿物品 {libID:{wishID:[wishIndex, canOut], ...}, ...}
|
| | | wishOutputRule = setIpyData.GetWishOutput() # 心愿产出规则:心愿产出完毕后: 0 - 可继续产出该库物品; 1 - 不可再产出该库物品
|
| | | wishLibSelect = setIpyData.GetWishLibSelect()
|
| | | # 心愿设定
|
| | | wishLibSelect = setIpyData.GetWishLibSelect() # {"心愿库":可选择物品数, ...}
|
| | | wishPubFreeCntDict = setIpyData.GetWishLibPubFreeCnt() # 心愿库公共免费次数 {"心愿库":免费次数, ...}
|
| | | wishPubCardDict = setIpyData.GetWishLibCard() # 心愿库公共次数心愿卡 {"心愿库":心愿卡ID, ...}
|
| | | |
| | | # 心愿优先产出相关
|
| | | preOutWishDict = {} # 心愿物品预计产出数{libID:预计优先产出数, ...}
|
| | | retOutWishDict = {} # 心愿物品实际产出数{libID:{wishID:实际优先产出数, ...}, ...}
|
| | | selectWishIDDict = {} # 库当前对应选择的心愿物品 {libID:[wishID, ...], ...}
|
| | | |
| | | # 公共心愿
|
| | | canFreeOutWishLibDict = {} # 心愿物品库公共还可免费产出数 {libID:还可免费产出数, ...}
|
| | | wishCardItemLibDict = {} # 公共心愿次数心愿卡背包物品 {libID:wishCardItem, ...}
|
| | | |
| | | # 独立心愿
|
| | | canFreeOutWishIDict = {} # 心愿物品独立还可免费产出数 {wishID:还可免费产出数, ...}
|
| | | |
| | | for libIDStr, selectCnt in wishLibSelect.items():
|
| | | libID = int(libIDStr)
|
| | | if libID not in canOutWishDict:
|
| | | canOutWishDict[libID] = {}
|
| | | |
| | | if wishPubFreeCntDict:
|
| | | outTotal = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreasureWishLibOut % (treasureType, libID))
|
| | | freeCnt = wishPubFreeCntDict.get(libIDStr, 0)
|
| | | canFreeOutPub = freeCnt - outTotal
|
| | | if canFreeOutPub > 0:
|
| | | canFreeOutWishLibDict[libID] = canFreeOutPub
|
| | | |
| | | for wishIndex in range(selectCnt):
|
| | | wishID, outCnt = GetWishInfo(curPlayer, treasureType, libID, wishIndex)
|
| | | wishID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreasureWishSelect % (treasureType, libIDStr, wishIndex))
|
| | | if not wishID:
|
| | | continue
|
| | | wishSelectState = True
|
| | | libItemIpyData = IpyGameDataPY.GetIpyGameDataByCondition("TreasureItemLib", {"ID":wishID}, False)
|
| | | if not libItemIpyData:
|
| | | continue
|
| | | outCntLimit = libItemIpyData.GetWishOutCnt()
|
| | | if not outCntLimit:
|
| | | if not libItemIpyData.GetIsWishItem():
|
| | | # 非心愿物品
|
| | | continue
|
| | | if outCnt >= outCntLimit:
|
| | | # 该心愿物品产出次数已用完
|
| | | continue
|
| | | libWishCanOutDict = canOutWishDict[libID]
|
| | | canOut = outCntLimit - outCnt
|
| | | libWishCanOutDict[wishID] = [wishIndex, canOut]
|
| | | if canOutWishDict:
|
| | | if not wishSelectState:
|
| | | GameWorld.DebugLog("心愿物品还未选择!", playerID)
|
| | | else:
|
| | | GameWorld.DebugLog("还可产出的心愿库对应WishID还可产出次数: %s" % canOutWishDict, playerID)
|
| | |
|
| | | if libID not in selectWishIDDict:
|
| | | selectWishIDDict[libID] = []
|
| | | selectWishIDList = selectWishIDDict[libID]
|
| | | selectWishIDList.append(wishID)
|
| | | |
| | | # 公共次数
|
| | | if wishPubFreeCntDict:
|
| | | pass
|
| | | |
| | | # 独立次数
|
| | | else:
|
| | | outCntLimit = libItemIpyData.GetWishOutCnt()
|
| | | outCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreasureWishOut % (treasureType, wishID))
|
| | | canFreeOut = outCntLimit - outCnt
|
| | | if canFreeOut <= 0:
|
| | | continue
|
| | | canFreeOutWishIDict[wishID] = canFreeOut
|
| | | |
| | | if wishLibSelect:
|
| | | GameWorld.DebugLog("当前心愿库选择的心愿ID列表: %s" % selectWishIDDict, playerID)
|
| | | GameWorld.DebugLog("还可优先产出的心愿免费次数:%s" % canFreeOutWishLibDict, playerID)
|
| | | |
| | | # 单抽产出优先级: 幸运物品 > 必出 > 保底 > 普通
|
| | | # 连抽没有优先级限制,只要满足条件即可产出
|
| | | getGridResult = []
|
| | |
| | |
|
| | | gridNum = GameWorld.GetResultByRandomList(curRateList)
|
| | | if gridNum in luckyGridNumList and gridNum in getGridResult:
|
| | | GameWorld.DebugLog(" 幸运物品已经出过,不再重复产出! gridNum=%s in %s" % (gridNum, getGridResult))
|
| | | GameWorld.DebugLog(" 幸运物品已经出过,不再重复产出重新随机! gridNum=%s in %s" % (gridNum, getGridResult), playerID)
|
| | | continue
|
| | |
|
| | | # 心愿产出限制
|
| | | # 心愿库物品,检查心愿预产出
|
| | | gridNumStr = str(gridNum)
|
| | | wishLibID = 0
|
| | | if wishLibSelect and gridNumStr in gridLibInfoDict and gridLibInfoDict[gridNumStr] in canOutWishDict:
|
| | | if wishLibSelect and gridNumStr in gridLibInfoDict and str(gridLibInfoDict[gridNumStr]) in wishLibSelect:
|
| | | wishLibID = gridLibInfoDict[gridNumStr]
|
| | | if wishOutputRule == 1: # 心愿物品产出完毕后,不可再产出该库物品,该模式下,未选择心愿的,也视为无可产出的心愿物品
|
| | | if not canOutWishDict[wishLibID]:
|
| | | GameWorld.DebugLog(" 没有可产出的心愿物品,不产出! gridNum=%s,wishLibID=%s" % (gridNum, wishLibID), playerID)
|
| | | continue
|
| | | |
| | | if wishPubFreeCntDict:
|
| | | # 公共心愿默认均可正常产出,只是处理是否优先产出心愿
|
| | | __prePubWishOut(curPlayer, treasureType, gridNum, wishLibID, selectWishIDDict, |
| | | preOutWishDict, canFreeOutWishLibDict, wishPubCardDict, wishCardItemLibDict)
|
| | | #else:
|
| | | # # 非公共的暂不支持,后续有需要再处理
|
| | | # return
|
| | | |
| | | if not gridNum:
|
| | | continue
|
| | |
|
| | | getGridResult.append(gridNum)
|
| | | GameWorld.DebugLog(" 本次产出: gridNum=%s, %s, doCount=%s" % (gridNum, getGridResult, doCount), playerID)
|
| | | if gridNum in luckyGridNumList and addLuck:
|
| | | if gridNum == setLuckyGridNum or updLuck >= maxLuck:
|
| | | updLuck = 0
|
| | | if gridNum in luckyGridNumList or updLuck >= maxLuck:
|
| | | if addLuck:
|
| | | if gridNum == setLuckyGridNum or updLuck >= maxLuck:
|
| | | updLuck = 0
|
| | | else:
|
| | | updLuck = stageLuck # 直接切换到下一阶段幸运
|
| | | else:
|
| | | updLuck = stageLuck # 直接切换到下一阶段幸运
|
| | | updLuck = 0
|
| | | 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)
|
| | |
| | | treasureResult = []
|
| | | randItemIDDict = IpyGameDataPY.GetFuncEvalCfg("TreasureSet", 2)
|
| | |
|
| | | wishAddOutDict = {} # 本次心愿物品预计增加产出 {wishID:addOut, ...}
|
| | | for gridNum in getGridResult:
|
| | | gridNum = str(gridNum)
|
| | | if gridNum in gridItemInfoDict:
|
| | |
| | | if not libItemList:
|
| | | return
|
| | |
|
| | | libWishCanOutDict = canOutWishDict.get(libID, {})
|
| | | wishWeightList = [] # 心愿物品权重
|
| | | itemWeightList = []
|
| | | for libItem in libItemList:
|
| | |
| | | if not __checkItemCanTreasure(curPlayer, treasureType, itemID):
|
| | | continue
|
| | | itemWeightList.append([itemWeight, [itemID, itemCount]])
|
| | | if curID in libWishCanOutDict:
|
| | | _, canOut = libWishCanOutDict[curID]
|
| | | if canOut - wishAddOutDict.get(curID, 0) > 0:
|
| | | wishWeightList.append([itemWeight, [itemID, itemCount, curID]])
|
| | | |
| | | |
| | | # 公共次数
|
| | | if wishPubFreeCntDict:
|
| | | selectWishIDList = selectWishIDDict.get(libID, [])
|
| | | if curID not in selectWishIDList:
|
| | | continue
|
| | | preOutWishCnt = preOutWishDict.get(libID, 0)
|
| | | if preOutWishCnt <= 0:
|
| | | continue
|
| | | preOutWishDict[libID] = preOutWishCnt - 1
|
| | | wishWeightList.append([itemWeight, [itemID, itemCount, curID]])
|
| | | |
| | | if not itemWeightList:
|
| | | GameWorld.ErrLog("寻宝随机格子没有可随机的物品!treasureType=%s,treasureIndex=%s,gridNum=%s,libID=%s"
|
| | | % (treasureType, treasureIndex, gridNum, libID), playerID)
|
| | |
| | | # 优先产出选择的心愿物品
|
| | | if wishWeightList:
|
| | | itemID, itemCount, curID = GameWorld.GetResultByWeightList(wishWeightList)
|
| | | wishAddOutDict[curID] = wishAddOutDict.get(curID, 0) + 1
|
| | | GameWorld.DebugLog("优先产出心愿物品: gridNum=%s,libID=%s,wishID=%s,itemID=%s" % (gridNum, libID, curID, itemID), playerID)
|
| | | if libID not in retOutWishDict:
|
| | | retOutWishDict[libID] = {}
|
| | | retOutWishIDDict = retOutWishDict[libID]
|
| | | retOutWishIDDict[curID] = retOutWishIDDict.get(curID, 0) + 1 # 累加实际优先产出
|
| | | |
| | | else:
|
| | | itemID, itemCount = GameWorld.GetResultByWeightList(itemWeightList)
|
| | | else:
|
| | |
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TreasureCountEx % (treasureType), treasureCountEx)
|
| | | GameWorld.DebugLog("更新第x次x抽次数: treasureIndex=%s,curIndexCount=%s,maxIndexCount=%s,treasureCountEx=%s" % (treasureIndex, curIndexCount, maxIndexCount, treasureCountEx), playerID)
|
| | | # 心愿产出次数
|
| | | for curID, addOut in wishAddOutDict.items():
|
| | | for libID, libWishCanOutDict in canOutWishDict.items():
|
| | | if curID not in libWishCanOutDict:
|
| | | continue
|
| | | wishIndex, canOut = libWishCanOutDict[curID]
|
| | | wishID, outCnt = GetWishInfo(curPlayer, treasureType, libID, wishIndex)
|
| | | updOut = outCnt + addOut
|
| | | SetWishInfo(curPlayer, treasureType, libID, wishIndex, wishID, updOut)
|
| | | GameWorld.DebugLog("更新心愿物品已产出次数: libID=%s,wishIndex=%s,wishID=%s,updOut=%s" % (libID, wishIndex, wishID, updOut), playerID)
|
| | | for libID, retOutWishIDDict in retOutWishDict.items():
|
| | | retOutTotal = 0
|
| | | for wishID, retOutCnt in retOutWishIDDict.items():
|
| | | retOutTotal += retOutCnt
|
| | | outCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreasureWishOut % (treasureType, wishID))
|
| | | updOutCnt = outCnt + retOutCnt
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TreasureWishOut % (treasureType, wishID), updOutCnt)
|
| | | GameWorld.DebugLog("更新心愿物品优先产出次数: libID=%s,wishID=%s,retOutCnt=%s,updOutCnt=%s" % (libID, wishID, retOutCnt, updOutCnt), playerID)
|
| | |
|
| | | outTotal = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreasureWishLibOut % (treasureType, libID))
|
| | | updOutTotal = outTotal + retOutTotal
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TreasureWishLibOut % (treasureType, libID), updOutTotal)
|
| | | GameWorld.DebugLog("更新心愿库物品累计优先产出次数: libID=%s,retOutTotal=%s,updOutTotal=%s" % (libID, retOutTotal, updOutTotal), playerID)
|
| | | |
| | | canFreeCnt = canFreeOutWishLibDict.get(libID, 0)
|
| | | costWishCardCnt = retOutTotal - canFreeCnt
|
| | | if costWishCardCnt > 0 and libID in wishCardItemLibDict:
|
| | | wishCardItem = wishCardItemLibDict[libID]
|
| | | cardItemID = wishCardItem.GetItemTypeID() if wishCardItem else 0
|
| | | costWishCardCnt = min(costWishCardCnt, ItemControler.GetItemCount(wishCardItem))
|
| | | GameWorld.DebugLog("扣除心愿卡个数: cardItemID=%s,costWishCardCnt=%s" % (cardItemID, costWishCardCnt), playerID)
|
| | | if wishCardItem:
|
| | | ItemCommon.DelItem(curPlayer, wishCardItem, costWishCardCnt)
|
| | | |
| | | addScoreType = setIpyData.GetAwardMoneyType() # 额外奖励货币类型
|
| | | addScore = setIpyData.GetAwardMoneyValue() # 单次奖励货币数
|
| | | if addScoreType and addScore:
|
| | | 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:
|
| | |
| | | NetPackCommon.SendFakePack(curPlayer, sendPack)
|
| | |
|
| | | Sync_TreasureInfo(curPlayer, [treasureType])
|
| | | return
|
| | |
|
| | | def __prePubWishOut(curPlayer, treasureType, gridNum, wishLibID, selectWishIDDict, preOutWishDict, |
| | | canFreeOutWishLibDict, wishPubCardDict, wishCardItemLibDict):
|
| | | ## 公共心愿产出预处理
|
| | | |
| | | playerID = curPlayer.GetPlayerID()
|
| | | selectWishIDList = selectWishIDDict.get(wishLibID, [])
|
| | | if not selectWishIDList:
|
| | | GameWorld.DebugLog(" 公共心愿未选择心愿物品,走默认随机规则", playerID)
|
| | | return
|
| | | |
| | | preOutTotal = preOutWishDict.get(wishLibID, 0)
|
| | | canFreeCnt = canFreeOutWishLibDict.get(wishLibID, 0)
|
| | | GameWorld.DebugLog(" 公共免费心愿次数! gridNum=%s,wishLibID=%s,preOutTotal=%s,canFreeCnt=%s" |
| | | % (gridNum, wishLibID, preOutTotal, canFreeCnt), playerID)
|
| | | |
| | | if preOutTotal >= canFreeCnt:
|
| | | if not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreasureWishUseItem % (treasureType, wishLibID)):
|
| | | GameWorld.DebugLog(" 玩家心愿卡未启用,走默认随机规则! gridNum=%s,wishLibID=%s" % (gridNum, wishLibID), playerID)
|
| | | return
|
| | | |
| | | wishCardID = wishPubCardDict.get(str(wishLibID), 0)
|
| | | if not wishCardID:
|
| | | GameWorld.DebugLog(" 该库没有心愿卡配置,走默认随机规则! gridNum=%s,wishLibID=%s" % (gridNum, wishLibID), playerID)
|
| | | return
|
| | | |
| | | if wishLibID not in wishCardItemLibDict:
|
| | | wishCardItem = ItemCommon.FindItemInPackByItemID(curPlayer, wishCardID, IPY_GameWorld.rptItem)
|
| | | if not wishCardItem:
|
| | | GameWorld.DebugLog(" 玩家没有对应心愿卡物品,走默认随机规则! gridNum=%s,wishLibID=%s,wishCardID=%s" |
| | | % (gridNum, wishLibID, wishCardID), playerID)
|
| | | return
|
| | | wishCardItemLibDict[wishLibID] = wishCardItem
|
| | | wishCardItem = wishCardItemLibDict[wishLibID]
|
| | | cardItemCount = ItemControler.GetItemCount(wishCardItem)
|
| | | canOutTotal = canFreeCnt + cardItemCount
|
| | | if preOutTotal >= canOutTotal:
|
| | | GameWorld.DebugLog(" 心愿卡个数预产出已消耗完,走默认随机规则! gridNum=%s,wishLibID=%s,wishCardID=%s" |
| | | % (gridNum, wishLibID, wishCardID), playerID)
|
| | | return
|
| | | GameWorld.DebugLog(" 心愿卡个数还可产出! gridNum=%s,wishLibID=%s,wishCardID=%s,cardItemCount=%s" |
| | | % (gridNum, wishLibID, wishCardID, cardItemCount), playerID)
|
| | | else:
|
| | | GameWorld.DebugLog(" 公共心愿还有免费次数强制消耗次数", playerID)
|
| | | |
| | | preOutWishDict[wishLibID] = preOutTotal + 1 |
| | | return
|
| | |
|
| | | def GetHeroCallCnt(curPlayer):
|
| | |
| | | tTypeInfo.GridLimitCntList.append(gridLimit)
|
| | | tTypeInfo.GridLimitCnt = len(tTypeInfo.GridLimitCntList)
|
| | |
|
| | | tTypeInfo.WishLibList = []
|
| | | wishLibSelect = setIpyData.GetWishLibSelect()
|
| | | for libIDStr, wishCnt in wishLibSelect.items():
|
| | | libID = int(libIDStr)
|
| | | wishLib = ChPyNetSendPack.tagMCTreasureWishLib()
|
| | | wishLib.LibID = libID
|
| | | wishLib.OutCntTotal = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreasureWishLibOut % (tType, libID))
|
| | | wishLib.IsUseWishCard = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreasureWishUseItem % (tType, libID))
|
| | | wishLib.WishList = []
|
| | | for wishIndex in range(wishCnt):
|
| | | wishID, outCnt = GetWishInfo(curPlayer, tType, libID, wishIndex)
|
| | | wishID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreasureWishSelect % (tType, libID, wishIndex))
|
| | | wish = ChPyNetSendPack.tagMCTreasureWish()
|
| | | wish.WishID = wishID
|
| | | wish.OutCnt = outCnt
|
| | | tTypeInfo.WishList.append(wish)
|
| | | tTypeInfo.WishCnt = len(tTypeInfo.WishList)
|
| | | wish.OutCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreasureWishOut % (tType, wishID))
|
| | | wishLib.WishList.append(wish)
|
| | | wishLib.WishCnt = len(wishLib.WishList)
|
| | | |
| | | tTypeInfo.WishLibList.append(wishLib)
|
| | | tTypeInfo.WishLibCnt = len(tTypeInfo.WishLibList)
|
| | |
|
| | | treasureInfoPack.TreasuerInfoList.append(tTypeInfo)
|
| | | treasureInfoPack.InfoCount = len(treasureInfoPack.TreasuerInfoList)
|