def onUserLuckyDraw(cls, userId, roomId): ''' 热身系统:抽奖处理 ''' ftlog.debug('WarmUpSystem.onUserLuckyDraw', 'userId=', userId, 'roomId=', roomId) global warmupLotteryPool if not warmupLotteryPool: warmupLotteryPool = WarmUpSystemLotteryPool() ftlog.debug('WarmUpSystem.onUserLuckyDraw', 'userId=', userId, 'warmupLotteryPool.prizeList=', warmupLotteryPool.lotteryPool.prizeList) ## 处理抽奖花费不足 if not WarmUpSystemHelper.checkAssetsEnough(userId): return {'success':False, 'mychip': UserInfo.getChip(userId)} ## 处理抽奖CD if not CountingTimer.checkCooldownFinish(userId): return {'success':False, 'mychip': UserInfo.getChip(userId)} ## 消耗抽奖花费 if not WarmUpSystemHelper.consumeLuckyDrawExpenses(userId): return {'success':False, 'mychip': UserInfo.getChip(userId)} chooseItemConfigure = warmupLotteryPool.randomGetPoolItem() ftlog.debug('WarmUpSystem.onUserLuckyDraw', 'userId=', userId, 'chooseItemConfigure=', chooseItemConfigure) ## 重置CD时间 CountingTimer.resetCounting(userId) ## 抽奖未抽中 chooseitemId = chooseItemConfigure.get('itemId') if not chooseitemId or len(chooseitemId) <= 0: return WarmUpSystemHelper.buildSuccessMessagePack(userId, chooseItemConfigure) ## 发送抽奖奖励 prizeMail = WarmUpSystemHelper.buildLuckyDrawMailMessage(chooseItemConfigure, roomId) UserBag.sendAssetsToUser(6, userId, chooseItemConfigure, BIEVENT_ID, prizeMail) ## 添加消息到抽奖记录中 LuckyDrawRecorder.pushRecord(LuckyDrawRecorder.buildRecord(userId, chooseItemConfigure)) return WarmUpSystemHelper.buildSuccessMessagePack(userId, chooseItemConfigure)
def buildSuccessMessagePack(cls, userId, itemconf): ''' 构建抽奖成功的result结果 @param: itemconf - 抽到的奖励项 ''' return {'success':True, 'message': cls.buildLuckyDrawMessage(itemconf), 'name': UserInfo.getNickname(userId), 'mychip': UserInfo.getChip(userId)}
def onGetRecordMessage(cls, userId, number): ''' 获得抽奖记录处理 ''' messageList = LuckyDrawRecorder.getRecordWithNumber(number) ftlog.debug('WarmUpSystem.onGetRecordMessage', 'userId=', userId, 'number=', number, 'messageList=', messageList) return { 'messages':messageList or [], 'cd': CountingTimer.getConfigureRequireCooldownSeconds(), 'chip': WarmUpSystemHelper.getLuckyDrawExpenses().get('count'), # 只会消耗金币 'mychip': UserInfo.getChip(userId) }