| | |
| | | % (lotteryRec.lotteryNum, crossServerTime, GameWorld.ChangeTimeNumToStr(crossServerTime),
|
| | | lotteryRec.lotteryTime, GameWorld.ChangeTimeNumToStr(lotteryRec.lotteryTime), passTime, MaxTime))
|
| | |
|
| | | if not GameWorld.IsCrossServer():
|
| | | return
|
| | | |
| | | maxBuyCount = IpyGameDataPY.GetFuncCfg("LuckyCloudBuySet", 2)
|
| | | doLotteryBuyCountPer = IpyGameDataPY.GetFuncCfg("LuckyCloudBuySet", 3)
|
| | | doLotteryBuyCount = int(math.ceil(maxBuyCount * doLotteryBuyCountPer / 100.0))
|
| | | |
| | | zoneLotteryInfo = {}
|
| | | for zoneID, lotteryRecList in PyGameData.g_luckyCloudBuyLotteryDict.items():
|
| | | if not lotteryRecList:
|
| | | continue
|
| | | lastLotteryRec = lotteryRecList[-1] # 取最后一个为最新一期
|
| | | cfgID = lastLotteryRec.cfgID
|
| | | if lastLotteryRec.lotteryNum:
|
| | | GameWorld.Log("OnDay已开奖进入新一天第一轮! cfgID=%s,zoneID=%s" % (cfgID, zoneID))
|
| | | DoStartNewRoundLuckyCloudBuy(cfgID, 1)
|
| | | continue
|
| | | buyRecList = PyGameData.g_luckyCloudBuyNumDict.get(zoneID, [])
|
| | | buyCount = len(buyRecList)
|
| | | if len(buyRecList) >= doLotteryBuyCount:
|
| | | GameWorld.Log("OnDay未开奖但购买份数超过开奖保底份数! cfgID=%s,zoneID=%s,buyCount=%s >= %s" % (cfgID, zoneID, buyCount, doLotteryBuyCount))
|
| | | DoLuckyCloudBuyLottery(lastLotteryRec, True, "OnDay")
|
| | | continue
|
| | | |
| | | GameWorld.Log("已购买份数不足开奖保底份数,重置为新一天的第一轮! cfgID=%s,zoneID=%s,buyCount=%s < %s" % (cfgID, zoneID, buyCount, doLotteryBuyCount))
|
| | | lastLotteryRec.roundNum = 1
|
| | | dataDict = {"Type":"ResetRound"}
|
| | | dataDict.update(lastLotteryRec.GetString())
|
| | | DataRecordPack.SendEventPack("LuckyCloudBuyLottery", dataDict)
|
| | | zoneLotteryInfo[zoneID] = [lastLotteryRec.GetString()]
|
| | | |
| | | # 广播子服轮次信息变更
|
| | | if zoneLotteryInfo:
|
| | | dataMsg = {"syncType":"Update", "zoneLotteryInfo":zoneLotteryInfo}
|
| | | CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_LuckyCloudBuyLottery, dataMsg)
|
| | | return
|
| | |
|
| | | def DoLuckyCloudBuyLottery(lotteryRec, resetRound=False, sign=""):
|
| | |
| | | zoneLotteryInfo = {zoneID:[lotteryRec.GetString()]}
|
| | | dataMsg = {"syncType":"Update", "zoneLotteryInfo":zoneLotteryInfo}
|
| | | CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_LuckyCloudBuyLottery, dataMsg)
|
| | | |
| | | actInfoDict = CrossActionControl.GetCrossActInfoByCfgID(ShareDefine.CrossActName_LuckyCloudBuy, cfgID)
|
| | | if not actInfoDict or not actInfoDict[ShareDefine.ActKey_State]:
|
| | | GameWorld.Log(" 不在活动中了,不开下一轮! cfgID=%s" % cfgID)
|
| | | return
|
| | | |
| | | if roundNum >= IpyGameDataPY.GetFuncCfg("LuckyCloudBuySet", 1):
|
| | | GameWorld.Log(" 当日已达每日云购轮数上限,不开下一轮! roundNum=%s" % roundNum)
|
| | | return
|
| | |
|
| | | nextRoundNum = 1 if resetRound else (roundNum + 1)
|
| | | GameWorld.Log("幸运云购开启下一轮! cfgID=%s,zoneID=%s,roundNum=%s,resetRound=%s,nextRoundNum=%s" |
| | | % (cfgID, zoneID, roundNum, resetRound, nextRoundNum))
|
| | | # 开始下一轮
|
| | | return DoStartNewRoundLuckyCloudBuy(cfgID, nextRoundNum)
|
| | | return DoStartNewRoundLuckyCloudBuy(cfgID, resetRound, roundNum)
|
| | |
|
| | | def GetMailBuyNums(buyNumList):
|
| | | buyNumList.sort()
|
| | |
| | |
|
| | | return buyNums
|
| | |
|
| | | def OnLuckyCloudBuyReset(ipyData, state):
|
| | | ## 云购重置
|
| | | def OnLuckyCloudBuyStateChange(ipyData, actIDChange, state):
|
| | | ## 云购状态变更
|
| | | |
| | | cfgID = ipyData.GetCfgID()
|
| | | zoneID = ipyData.GetZoneID()
|
| | |
|
| | | startNewLottery = False
|
| | | lotteryRecList = PyGameData.g_luckyCloudBuyLotteryDict.get(zoneID, [])
|
| | | lastLotteryRec = None if not lotteryRecList else lotteryRecList[-1]
|
| | | # 最后一场未开奖
|
| | | if lastLotteryRec and not lastLotteryRec.lotteryNum:
|
| | | buyRecList = PyGameData.g_luckyCloudBuyNumDict.get(zoneID, [])
|
| | | if buyRecList:
|
| | |
| | | if popLotteryRec:
|
| | | GameWorld.Log("移除无效轮次信息 %s" % popLotteryRec.GetString())
|
| | |
|
| | | # 变更为活动中且未开启新轮次
|
| | | if state and not startNewLottery:
|
| | | GameWorld.Log("幸运云购重置,当前没有未开奖的轮次,直接开启新一轮! cfgID=%s,zoneID=%s" % (cfgID, zoneID))
|
| | | DoStartNewRoundLuckyCloudBuy(cfgID, 1)
|
| | | GameWorld.Log("幸运云购重置,当前没有未开奖的轮次,直接开启新一轮! cfgID=%s,zoneID=%s,state=%s" % (cfgID, zoneID, state))
|
| | | DoStartNewRoundLuckyCloudBuy(cfgID, True)
|
| | |
|
| | | return
|
| | |
|
| | | def DoStartNewRoundLuckyCloudBuy(cfgID, roundNum):
|
| | | def DoStartNewRoundLuckyCloudBuy(cfgID, resetRound, roundNum=0):
|
| | | # 开启新一轮云购
|
| | | |
| | | |
| | | actInfoDict = CrossActionControl.GetCrossActInfoByCfgID(ShareDefine.CrossActName_LuckyCloudBuy, cfgID)
|
| | | if not actInfoDict or not actInfoDict[ShareDefine.ActKey_State]:
|
| | | GameWorld.ErrLog("幸运云购非活动中,无法开启! cfgID=%s, roundNum=%s" % (cfgID, roundNum))
|
| | | GameWorld.ErrLog("幸运云购非活动中,无法开启新轮次! cfgID=%s, roundNum=%s" % (cfgID, roundNum))
|
| | | return
|
| | | state = actInfoDict[ShareDefine.ActKey_State]
|
| | |
|
| | | actIpyData = IpyGameDataPY.GetIpyGameData("CrossActLuckyCloudBuy", cfgID)
|
| | | if not actIpyData:
|
| | | return
|
| | | zoneID = actIpyData.GetZoneID()
|
| | | serverIDRangeList = actIpyData.GetServerIDRangeList()
|
| | | roundMaxList = actIpyData.GetRoundMaxList()
|
| | | templateIDList = actIpyData.GetTemplateIDList()
|
| | | if not templateIDList:
|
| | | if not roundMaxList or not templateIDList:
|
| | | return
|
| | |
|
| | | dayIndex = actInfoDict.get(ShareDefine.ActKey_DayIndex, 0)
|
| | | templateID = templateIDList[dayIndex] if len(templateIDList) > dayIndex else templateIDList[-1]
|
| | | sIndex = state - 1
|
| | | roundMax = roundMaxList[sIndex] if len(roundMaxList) > sIndex else roundMaxList[-1]
|
| | | if not resetRound and roundMax and roundNum >= roundMax:
|
| | | GameWorld.Log(" 已达云购轮数上限,不开下一轮! cfgID=%s,state=%s,roundNum=%s" % (cfgID, state, roundNum))
|
| | | return
|
| | | |
| | | templateID = templateIDList[sIndex] if len(templateIDList) > sIndex else templateIDList[-1]
|
| | | templateIpyData = IpyGameDataPY.GetIpyGameData("CrossActLuckyCloudBuyTemplate", templateID)
|
| | | if not templateIpyData:
|
| | | return
|
| | |
|
| | | if resetRound:
|
| | | nextRoundNum = 1
|
| | | else:
|
| | | nextRoundNum = roundNum + 1
|
| | | |
| | | superItemWeightInfo = templateIpyData.GetSuperItemWeightInfo()
|
| | | superItemInfo = GameWorld.GetResultByWeightList(superItemWeightInfo)
|
| | | if not superItemInfo or len(superItemInfo) < 3:
|
| | | GameWorld.ErrLog("幸运云购生成大奖失败! zoneID=%s,roundNum=%s,superItemInfo=%s" % (zoneID, roundNum, superItemInfo))
|
| | | GameWorld.ErrLog("幸运云购生成大奖失败! cfgID=%s,zoneID=%s,nextRoundNum=%s,superItemInfo=%s" % (cfgID, zoneID, nextRoundNum, superItemInfo))
|
| | | return
|
| | |
|
| | | lotteryRec = LuckyCloudBuyLottery()
|
| | | lotteryRec.idTime = int(time.time())
|
| | | lotteryRec.cfgID = cfgID
|
| | | lotteryRec.zoneID = zoneID
|
| | | lotteryRec.roundNum = roundNum
|
| | | lotteryRec.roundNum = nextRoundNum
|
| | |
|
| | | lotteryRec.serverIDRangeList = serverIDRangeList
|
| | | lotteryRec.superItemInfo = superItemInfo
|
| | |
| | | lotteryRecList = PyGameData.g_luckyCloudBuyLotteryDict[zoneID]
|
| | | lotteryRecList.append(lotteryRec)
|
| | |
|
| | | PyGameData.g_luckyCloudBuyNumDict[zoneID] = [] # 新一轮情况购买记录
|
| | | PyGameData.g_luckyCloudBuyNumDict[zoneID] = [] # 新一轮清空购买记录
|
| | |
|
| | | dataDict = {"Type":"NewRound"}
|
| | | dataDict.update(lotteryRec.GetString())
|
| | | DataRecordPack.SendEventPack("LuckyCloudBuyLottery", dataDict)
|
| | | GameWorld.Log("幸运云购开启新轮次! cfgID=%s,zoneID=%s,state=%s,nextRoundNum=%s,superItemInfo=%s" % (cfgID, zoneID, state, nextRoundNum, superItemInfo))
|
| | |
|
| | | # 广播子服开奖信息
|
| | | zoneLotteryInfo = {zoneID:[lotteryRec.GetString()]}
|
| | |
| | | actInfo = CrossActionControl.GetCrossActInfoByServerGroupID(ShareDefine.CrossActName_LuckyCloudBuy, serverGroupID)
|
| | | if not actInfo:
|
| | | return
|
| | | state = actInfo.get(ShareDefine.ActKey_State)
|
| | | #state = actInfo.get(ShareDefine.ActKey_State)
|
| | | ipyDataInfo = actInfo.get(ShareDefine.ActKey_IpyDataInfo)
|
| | | if not state or not ipyDataInfo:
|
| | | if not ipyDataInfo:
|
| | | return
|
| | | zoneID = ipyDataInfo.get("ZoneID")
|
| | | if not zoneID:
|
| | |
| | | if not lotteryRec:
|
| | | return
|
| | |
|
| | | roundTimeList = []
|
| | | StartTimeList = ipyDataInfo.get("StartTimeList")
|
| | | EndTimeList = ipyDataInfo.get("EndTimeList")
|
| | | RoundMaxList = ipyDataInfo.get("RoundMaxList")
|
| | | for i, startTime in enumerate(StartTimeList):
|
| | | roundTime = ChPyNetSendPack.tagGCLuckyCloudBuyRoundTime()
|
| | | roundTime.StartTime = startTime
|
| | | roundTime.EndtTime = EndTimeList[i] if len(EndTimeList) > i else ""
|
| | | roundTime.RoundMax = RoundMaxList[i] if len(RoundMaxList) > i else 0
|
| | | roundTimeList.append(roundTime)
|
| | | |
| | | superItemInfo = lotteryRec.superItemInfo + [0, 0, 0, 0, 0]
|
| | | superItemID, superItemCount, _, moneyType, moneyValue = superItemInfo[:5]
|
| | | clientPack = ChPyNetSendPack.tagGCLuckyCloudBuyRoundInfo()
|
| | |
| | | clientPack.StartDate = ipyDataInfo.get("StartDate", "")
|
| | | clientPack.EndtDate = ipyDataInfo.get("EndDate", "")
|
| | | clientPack.LVLimit = ipyDataInfo.get("LVLimit", 0)
|
| | | clientPack.RoundTimeList = roundTimeList
|
| | | clientPack.RoundTimeCount = len(clientPack.RoundTimeList)
|
| | | clientPack.RoundID = lotteryRec.idTime
|
| | | clientPack.RoundNum = lotteryRec.roundNum
|
| | | clientPack.SuperItemID = superItemID
|