def getLoopTaskInfoProcess(userId, gameId, bigRoomId): ''' 获取周期任务信息格式如下:赢1/6局:20金币 ''' tbWinTimes, tbPlayCount = getTreasureBoxState(userId, gameId, bigRoomId) tbConfig = majiang_conf.getTreasureBoxRoomInfo(gameId, bigRoomId, ROOM_PATH) if tbConfig: prize = tbConfig.get('prize', '') return "赢%d/%d局:%s" % (int(tbWinTimes), int(tbPlayCount), str(prize)) return None
def getTreasureTableTip(gameId, bigRoomId): ''' 获取循环任务奖励描述 ''' tbconfigers = majiang_conf.getTreasureBoxRoomInfo(gameId, bigRoomId, ROOM_PATH) if tbconfigers : desc = majiang_conf.getTreasureBoxDescInfo(gameId, ROOM_PATH) rRound = tbconfigers.get(ROUND_COUNT, 0) prize = tbconfigers.get('prize', '') if rRound > 0: newDesc = ftstr.replaceParams(desc, {"round": rRound, "prize": prize}) return newDesc return ''
def getTreasureRewardItem(gameId, bigRoomId): ''' 获取用户的循环任务奖励信息 ''' tbconfigers = majiang_conf.getTreasureBoxRoomInfo(gameId, bigRoomId, ROOM_PATH) itemId = '' itemCount = 0 if tbconfigers : items = tbconfigers.get('reward', {}).get('items', []) for item in items: if item['count'] > 0: itemId = item['itemId'] itemCount = item['count'] ftlog.debug('LoopWinTask.getTreasureRewardItem->bigRoomId=', bigRoomId , 'itemId=', itemId , 'itemCount=', itemCount) return itemId, itemCount
def updateTreasureBoxState(userId, gameId, bigRoomId, winState): ''' 更新循环任务奖励 ''' tbconfigers = majiang_conf.getTreasureBoxRoomInfo(gameId, bigRoomId, ROOM_PATH) ftlog.debug('LoopWinTask.updateTreasureBoxState tbconfigers:', tbconfigers) if not tbconfigers: return tbplaycount = tbconfigers[ROUND_COUNT] tbcontinuesecodes = tbconfigers[REMAIN_MAX_TIME] tbWinTimes, tbLastTime, datas = getUserTbInfo(userId, gameId, bigRoomId) ctime = int(time.time()) ftlog.debug('LoopWinTask.updateTreasureBoxState roundCount:', tbplaycount , ' continueSeconds:', tbcontinuesecodes , ' tbWinTimes:', tbWinTimes , ' lastTime:', tbLastTime , ' datas:', datas , ' delta-T:', abs(ctime - tbLastTime)) if abs(ctime - tbLastTime) > tbcontinuesecodes: tbWinTimes = 0 tbroomid = bigRoomId tbLastTime = ctime if winState: tbWinTimes += 1 datas[ROOMID] = tbroomid datas[LASTTIME] = tbLastTime ftlog.debug('LoopWinTask.updateTreasureBoxState->userIds=', userId, 'bigRoomId=', bigRoomId, 'datas=', datas) # 先发奖 if tbWinTimes == tbplaycount: datas[WINTIMES] = tbWinTimes doTreasureBox(userId, gameId, bigRoomId, datas, tbconfigers) else: datas[WINTIMES] = tbWinTimes % tbplaycount notifyMsg(userId, gameId, bigRoomId, datas, tbconfigers, _getDoubleInfos(gameId)) # 数据保存 在赢了以后再保存 if winState: _setTbData(userId, gameId, bigRoomId, datas)
def getTreasureBoxState(userId, gameId, bigRoomId): ''' 获取用户的循环任务奖励状态 ''' tbWinTimes, tbLastTime, _ = getUserTbInfo(userId, gameId, bigRoomId) tbconfigers = majiang_conf.getTreasureBoxRoomInfo(gameId, bigRoomId, ROOM_PATH) if tbconfigers : ctime = int(time.time()) tbplaycount = tbconfigers[ROUND_COUNT] tbcontinuesecodes = tbconfigers[REMAIN_MAX_TIME] if tbplaycount < 2 or abs(ctime - tbLastTime) > tbcontinuesecodes: if tbplaycount < 2: tbplaycount = 1 tbWinTimes = 0 else: tbplaycount = 1 tbWinTimes = 0 if tbWinTimes > tbplaycount: tbWinTimes = tbplaycount ftlog.debug('LoopWinTask.getTreasureBoxState->userIds=', userId , 'bigRoomId=', bigRoomId , tbWinTimes, '/', tbplaycount) return tbWinTimes, tbplaycount