| | |
| | | import PlayerActYunshi
|
| | | import PlayerActivity
|
| | | import PlayerSuccess
|
| | | import PlayerGoldInvest
|
| | | import OpenServerActivity
|
| | | import PlayerBillboard
|
| | | import ShareDefine
|
| | |
| | | syncTypeList.append(treasureType)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TreasureCountToday % (treasureType), 0)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TreasureFreeCount % (treasureType), 0)
|
| | | |
| | | # 每日心愿重置
|
| | | 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 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
|
| | | #};
|
| | | def OnTreasureWishSelect(index, clientData, tick):
|
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | | treasureType = clientData.TreasureType
|
| | | reqSelectWishIDList = clientData.WishIDList
|
| | | |
| | | setIpyData = IpyGameDataPY.GetIpyGameData("TreasureSet", treasureType)
|
| | | if not setIpyData:
|
| | | return
|
| | | wishLibSelect = setIpyData.GetWishLibSelect() |
| | | if not wishLibSelect:
|
| | | GameWorld.DebugLog("该寻宝类型没有心愿物品功能! treasureType=%s" % (treasureType))
|
| | | return
|
| | | |
| | | GameWorld.DebugLog("寻宝选择心愿物品: treasureType=%s,reqSelectWishIDList=%s" % (treasureType, reqSelectWishIDList))
|
| | | |
| | | selectLibItemDict = {} # 重新选择的心愿物品汇总 {libID:[wishID, ...], ...}
|
| | | for wishID in reqSelectWishIDList:
|
| | | libItemIpyData = IpyGameDataPY.GetIpyGameDataByCondition("TreasureItemLib", {"ID":wishID}, False)
|
| | | if not libItemIpyData:
|
| | | return
|
| | | |
| | | itemID = libItemIpyData.GetItemID()
|
| | | if not libItemIpyData.GetWishOutCnt():
|
| | | GameWorld.DebugLog("非心愿物品,不可选择! wishID=%s" % (wishID))
|
| | | return
|
| | | |
| | | # 按所属库归类汇总
|
| | | libID = libItemIpyData.GetLibID()
|
| | | if libID not in selectLibItemDict:
|
| | | selectLibItemDict[libID] = []
|
| | | selectLibWishIDList = selectLibItemDict[libID]
|
| | | if wishID not in selectLibWishIDList:
|
| | | selectLibWishIDList.append(wishID)
|
| | | |
| | | # 武将招募,额外限制
|
| | | if treasureType in TreasureType_HeroCallList:
|
| | | heroIpyData = IpyGameDataPY.GetIpyGameData("Hero", itemID)
|
| | | if not heroIpyData:
|
| | | return
|
| | | if heroIpyData.GetRecruitBySelf() and not PlayerHero.GetHeroActivite(curPlayer, itemID):
|
| | | GameWorld.DebugLog("需要激活本体的武将未激活不可选择!itemID=%s" % itemID)
|
| | | return
|
| | | |
| | | hisOutDict = {} # 历史选择已产出过的心愿物品记录 {wishID:outCnt, ...}
|
| | | 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
|
| | | |
| | | 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
|
| | | |
| | | # 验证通过,保存
|
| | | 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))
|
| | | |
| | | Sync_TreasureInfo(curPlayer, [treasureType])
|
| | | return
|
| | |
|
| | | |
| | | #// A5 68 请求寻宝 #tagCMRequestTreasure
|
| | | #
|
| | | #struct tagCMRequestTreasure
|
| | |
| | | if curIndexCount <= maxIndexCount and curIndexCount in beSureCountByIndexDict:
|
| | | beSureCountByIndexCfg = beSureCountByIndexDict[curIndexCount]
|
| | |
|
| | | gridItemInfoDict = ipyData.GetGridItemInfo() # 格子对应物品信息 {"格子编号":[物品ID, 数量], ...}
|
| | | 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
|
| | | outCntLimit = libItemIpyData.GetWishOutCnt()
|
| | | if not outCntLimit:
|
| | | # 非心愿物品
|
| | | 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)
|
| | | |
| | | # 单抽产出优先级: 幸运物品 > 必出 > 保底 > 普通
|
| | | # 连抽没有优先级限制,只要满足条件即可产出
|
| | | luckyOut = False # 幸运物品理论产出状态,不一定是真实产出,可能受终身卡限制
|
| | | getGridResult = []
|
| | | for tIndex in range(treasureCount):
|
| | | updLuck = min(updLuck + addLuck, maxLuck)
|
| | |
| | |
|
| | | # 满幸运必出
|
| | | if not curRateList and stageLuck and updLuck >= stageLuck and luckItemRateList:
|
| | | curRateList = GetRemoveLimitGridRateList(luckItemRateList, gridNumCountInfo, gridNumMaxLimitInfo)
|
| | | GameWorld.DebugLog(" 【满幸运必出饼图】: %s" % curRateList, playerID)
|
| | | |
| | | 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)
|
| | | |
| | | # 次数必出
|
| | | if not curRateList and updTreasureCount in beSureCountDict:
|
| | | besureGridRateList = beSureCountDict[updTreasureCount]
|
| | |
| | | GameWorld.DebugLog(" 幸运物品已经出过,不再重复产出! gridNum=%s in %s" % (gridNum, getGridResult))
|
| | | continue
|
| | |
|
| | | # 其他产出限制...
|
| | | |
| | | # 心愿产出限制
|
| | | gridNumStr = str(gridNum)
|
| | | wishLibID = 0
|
| | | if wishLibSelect and gridNumStr in gridLibInfoDict and gridLibInfoDict[gridNumStr] in canOutWishDict:
|
| | | wishLibID = gridLibInfoDict[gridNumStr]
|
| | | if wishOutputRule == 1: # 心愿物品产出完毕后,不可再产出该库物品,该模式下,未选择心愿的,也视为无可产出的心愿物品
|
| | | if not canOutWishDict[wishLibID]:
|
| | | GameWorld.DebugLog(" 没有可产出的心愿物品,不产出! gridNum=%s,wishLibID=%s" % (gridNum, wishLibID), playerID)
|
| | | continue
|
| | | |
| | | if not gridNum:
|
| | | continue
|
| | |
|
| | | getGridResult.append(gridNum)
|
| | | GameWorld.DebugLog(" 本次产出: gridNum=%s, %s" % (gridNum, getGridResult), playerID)
|
| | | if gridNum in luckyGridNumList:
|
| | | 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:
|
| | | updLuck = 0
|
| | | else:
|
| | | updLuck = stageLuck # 直接切换到下一阶段幸运
|
| | | GameWorld.DebugLog(" 【产出幸运格子】: gridNum=%s,updLuck=%s" % (gridNum, updLuck), playerID)
|
| | | 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)
|
| | | if wishLibID:
|
| | | GameWorld.DebugLog(" 【产出的是心愿库物品】: gridNum=%s,wishLibID=%s" % (gridNum, wishLibID), playerID)
|
| | | |
| | | if gridNum in gridNumCountInfo:
|
| | | gridNumCountInfo[gridNum] = gridNumCountInfo[gridNum] + 1
|
| | | GameWorld.DebugLog(" 【更新产出次数】: gridNum=%s, %s" % (gridNum, gridNumCountInfo), playerID)
|
| | |
| | |
|
| | | isBind = 0 # 暂时默认不绑定
|
| | | job = curPlayer.GetJob()
|
| | | gridItemInfoDict = ipyData.GetGridItemInfo() # 格子对应物品信息 {"格子编号":[物品ID, 数量], ...}
|
| | | gridLibInfoDict = ipyData.GetGridLibInfo() # 格子编号对应库ID {"编号":物品库ID, ...}
|
| | | jobItemList = ipyData.GetJobItemList()
|
| | | treasureResult = []
|
| | | randItemIDDict = IpyGameDataPY.GetFuncEvalCfg("TreasureSet", 2)
|
| | |
|
| | | wishAddOutDict = {} # 本次心愿物品预计增加产出 {wishID:addOut, ...}
|
| | | for gridNum in getGridResult:
|
| | | gridNum = str(gridNum)
|
| | | if gridNum in gridItemInfoDict:
|
| | |
| | | libItemList = IpyGameDataPY.GetIpyGameDataList("TreasureItemLib", libID)
|
| | | if not libItemList:
|
| | | return
|
| | | |
| | | libWishCanOutDict = canOutWishDict.get(libID, {})
|
| | | wishWeightList = [] # 心愿物品权重
|
| | | itemWeightList = []
|
| | | for libItem in libItemList:
|
| | | curID = libItem.GetID()
|
| | | itemWeight, itemID, itemCount = libItem.GetItemWeight(), libItem.GetItemID(), libItem.GetItemCount()
|
| | | if not itemWeight:
|
| | | continue
|
| | | 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 not itemWeightList:
|
| | | GameWorld.ErrLog("寻宝随机格子没有可随机的物品!treasureType=%s,treasureIndex=%s,gridNum=%s,libID=%s"
|
| | | % (treasureType, treasureIndex, gridNum, libID), playerID)
|
| | | return
|
| | | itemID, itemCount = GameWorld.GetResultByWeightList(itemWeightList)
|
| | | # 优先产出选择的心愿物品
|
| | | 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)
|
| | | else:
|
| | | itemID, itemCount = GameWorld.GetResultByWeightList(itemWeightList)
|
| | | else:
|
| | | GameWorld.ErrLog("寻宝格子不存在!treasureType=%s,gridNum=%s" % (treasureType, gridNum), playerID)
|
| | | return
|
| | |
| | | if curIndexCount <= maxIndexCount:
|
| | | treasureCountEx = GameWorld.ChangeDataByDigitPlace(treasureCountEx, treasureIndex, curIndexCount)
|
| | | 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))
|
| | | |
| | | 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)
|
| | | |
| | | addScoreType = setIpyData.GetAwardMoneyType() # 额外奖励货币类型
|
| | | addScore = setIpyData.GetAwardMoneyValue() # 单次奖励货币数
|
| | | if addScoreType and addScore:
|
| | |
| | | mailItemDict = ItemCommon.GetMailItemDict(itemObj)
|
| | |
|
| | | if int(gridNum) in notifyGridNumList and notifyKey:
|
| | | PlayerControl.WorldNotify(0, notifyKey, [curPlayer.GetPlayerName(), itemID, itemObj.GetUserData(), itemCount])
|
| | | if treasureType in TreasureType_HeroCallList:
|
| | | if PlayerHero.GetHeroActivite(curPlayer, itemID):
|
| | | notifyKey = ""
|
| | | GameWorld.DebugLog("招募武将非首次获得的不广播了! itemID=%s" % itemID, playerID)
|
| | | else:
|
| | | heroIpyData = IpyGameDataPY.GetIpyGameData("Hero", itemID)
|
| | | if heroIpyData:
|
| | | heroQuality = heroIpyData.GetQuality()
|
| | | PlayerControl.WorldNotify(0, notifyKey, [curPlayer.GetPlayerName(), heroQuality, itemID])
|
| | | else:
|
| | | PlayerControl.WorldNotify(0, notifyKey, [curPlayer.GetPlayerName(), itemID, itemObj.GetUserData(), itemCount])
|
| | |
|
| | | if mailItemList or not itemControl.PutInItem(packType, itemObj, event=[ChConfig.ItemGive_Treasure, False, {}]):
|
| | | mailItemList.append(mailItemDict)
|
| | |
| | | if not heroIpyData:
|
| | | return
|
| | | if heroIpyData.GetRecruitBySelf() and not PlayerHero.GetHeroActivite(curPlayer, itemID):
|
| | | GameWorld.DebugLog("武将未激活不产出!itemID=%s" % itemID, playerID)
|
| | | GameWorld.DebugLog("武将未激活不产出! itemID=%s" % itemID, playerID)
|
| | | return
|
| | |
|
| | | elif itemData.GetType() == ChConfig.Def_ItemType_Rune:
|
| | | if not PlayerRune.GetIsOpenByRuneID(curPlayer, itemID):
|
| | | GameWorld.DebugLog("未解锁的符印不产出!itemID=%s" % itemID, playerID)
|
| | | GameWorld.DebugLog("未解锁的符印不产出! itemID=%s" % itemID, playerID)
|
| | | return
|
| | |
|
| | | return True
|
| | |
| | | gridLimit.GridCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreasureGridCnt % (tType, gridNum))
|
| | | tTypeInfo.GridLimitCntList.append(gridLimit)
|
| | | tTypeInfo.GridLimitCnt = len(tTypeInfo.GridLimitCntList)
|
| | | |
| | | wishLibSelect = setIpyData.GetWishLibSelect()
|
| | | for libIDStr, wishCnt in wishLibSelect.items():
|
| | | libID = int(libIDStr)
|
| | | for wishIndex in range(wishCnt):
|
| | | wishID, outCnt = GetWishInfo(curPlayer, tType, libID, wishIndex)
|
| | | wish = ChPyNetSendPack.tagMCTreasureWish()
|
| | | wish.WishID = wishID
|
| | | wish.OutCnt = outCnt
|
| | | tTypeInfo.WishList.append(wish)
|
| | | tTypeInfo.WishCnt = len(tTypeInfo.WishList)
|
| | | |
| | | treasureInfoPack.TreasuerInfoList.append(tTypeInfo)
|
| | | treasureInfoPack.InfoCount = len(treasureInfoPack.TreasuerInfoList)
|
| | | NetPackCommon.SendFakePack(curPlayer, treasureInfoPack)
|