def loginGame(userId, gameId, clientId): """ 用户登录一个游戏, 检查用户的游戏数据是否存在(创建用户数据) """ # 确认用户的游戏数据是否存在 iscreate = ensureGameDataExists(userId, gameId, clientId) # 游戏登录次数加1,每次bind_user都会加1,包括断线重连 gamedata.incrGameAttr(userId, gameId, 'loginsum', 1) # 确认是否是今日第一次登录 isdayfirst = False datas = day1st.getDay1stDatas(userId, gameId) if 'daylogin' not in datas: isdayfirst = True datas['daylogin'] = 1 datas['iscreate'] = 1 else: datas['daylogin'] += 1 datas['iscreate'] = 0 day1st.setDay1stDatas(userId, gameId, datas) if isdayfirst: # 消息的数据结构新旧转换 message.convertOldData(gameId, userId) # 插件的登录补充处理 TYGame(gameId).loginGame(userId, gameId, clientId, iscreate, isdayfirst) evt = EventUserLogin(userId, gameId, isdayfirst, iscreate, clientId) TYGame(gameId).getEventBus().publishEvent(evt) userdata.updateUserGameDataAuthorTime(userId, gameId) return isdayfirst, iscreate
def gamePlay(userId, gameId, roomId, tableId, banker): ftlog.debug('table_events_remote trigger event UserTablePlayEvent...') from hengyangmj.game import TGhengyangmj TGhengyangmj.getEventBus().publishEvent(UserTablePlayEvent(gameId , userId , roomId , tableId , banker)) gamedata.incrGameAttr(userId, gameId, 'play_game_count', 1)
def refreshQuestTaskId(userId, taskId): """ 手动刷新每日任务 """ code = 1 newTaskId = 0 spareQuests = getSpareQuest(userId) cost = config.getDailyQuestRefreshConf().get("cost") if spareQuests and cost: todayQuest, _ = getTodayQuest(userId) quest = todayQuest.get(taskId, None) if ftlog.is_debug(): ftlog.debug("refreshQuestTaskId", "userId =", userId, "taskId =", taskId, "quest =", quest) if quest: questInfo = getUserQuestInfoData(userId) refreshTimes = gamedata.getGameAttrInt(userId, FISH_GAMEID, GameData.refreshDailyQuestTimes) process, state = questInfo.get(str(taskId), [0, QuestTaskState.Normal]) if ftlog.is_debug(): ftlog.debug("refreshQuestTaskId", "questInfo =", questInfo, "refreshTimes =", refreshTimes, process, state) if state == QuestTaskState.Normal and refreshTimes < config.getDailyQuestRefreshConf().get("maxTimes", 1): succ = True for item in cost: if util.balanceItem(userId, item["name"]) < item["count"]: succ = False if ftlog.is_debug(): ftlog.debug("refreshQuestTaskId ====>", "资源不足", userId, taskId, item["name"], item["count"]) break else: if not util.consumeItems(userId, cost, "ITEM_USE"): succ = False if succ: code = 0 gamedata.incrGameAttr(userId, FISH_GAMEID, GameData.refreshDailyQuestTimes, 1) import random new = random.choice(spareQuests) newTaskId = new["taskId"] if str(taskId) in questInfo: questInfo.pop(str(taskId)) if ftlog.is_debug(): ftlog.debug("refreshQuestTaskId, pop !", userId, taskId, questInfo) questInfo[str(newTaskId)] = [0, QuestTaskState.Normal] setUserQuestInfoData(userId, questInfo) else: code = 3 else: code = 2 mo = MsgPack() mo.setCmd("task") mo.setResult("gameId", FISH_GAMEID) mo.setResult("userId", userId) mo.setResult("action", "refreshQuest") mo.setResult("taskId", taskId) mo.setResult("code", code) mo.setResult("newTaskId", newTaskId) dailyQuestData = getDailyQuestData(userId) mo.setResult("dailyTask", dailyQuestData) router.sendToUser(mo, userId)
def catchBudget(self, gainChip, gainCoupon, items, nowExp=0, wpId=0): super(FishNewbiePlayer, self).catchBudget(gainChip, gainCoupon, items, nowExp=0, wpId=0) # 捕获添加奖励 if gainCoupon > 0: gamedata.incrGameAttr(self.userId, FISH_GAMEID, GameData.catchCouponFishCount, 1)
def gamePlay(userId, gameId, roomId, tableId, banker): ftlog.debug('table_events_remote trigger event UserTablePlayEvent...') from queshou.game import TGQueshou TGQueshou.getEventBus().publishEvent(UserTablePlayEvent(gameId , userId , roomId , tableId , banker)) gamedata.incrGameAttr(userId, gameId, 'play_game_count', 1)
def loginGame(userId, gameId, clientId, iscreate, isdayfirst): ftlog.debug('hall.loginGame', userId, gameId, clientId, iscreate, isdayfirst) if isdayfirst: # 游戏登录天数加1 gamedata.incrGameAttr(userId, HALL_GAMEID, 'loginDays', 1) # 检测发送登录奖励 hall_login_reward.sendLoginReward(userId, HALL_GAMEID, clientId) hallitem._onUserLogin(gameId, userId, clientId, iscreate, isdayfirst) # 自动更新用户道具 hall_item_exchange.updateUserItems(userId, gameId, clientId) if not (iscreate or hallstartchip.needSendStartChip(userId, gameId)): hallbenefits.benefitsSystem.sendBenefits(gameId, userId, pktimestamp.getCurrentTimestamp())
def addUserSkillScore(self, userId, toAdd): score = gamedata.incrGameAttr(userId, self.gameId, 'skillscore', toAdd) # 大师分增量榜 hallranking.rankingSystem.setUserByInputType( self.gameId, TYRankingInputTypes.DASHIFEN_INCR, userId, toAdd, pktimestamp.getCurrentTimestamp()) oldScore = score - toAdd oldLevel = self.getLevel(oldScore) newLevel = self.getLevel(score) ret = buildUserSkillScoreInfo(UserSkillScore(userId, score, newLevel)) ret['userId'] = userId ret['addScore'] = toAdd if oldLevel != newLevel: changeName = False needLevel = commconf.getChangeNickNameLevel(self.gameId) if needLevel == newLevel.level: setNameCount = hallrename.getRenameSum(self.gameId, userId) if setNameCount <= 0: ret['changename'] = 1 changeName = True rewards = self.sendLevelReward(userId, oldLevel, newLevel) if not changeName and rewards: ret['rewards'] = rewards ret['isLevelUp'] = True TYGame(self.gameId).getEventBus().publishEvent( SkillScoreIncrEvent(self.gameId, userId, oldScore, oldLevel.level, score, newLevel.level)) if ftlog.is_debug(): ftlog.debug('SkillScore.incrSkillScore', 'gameId=', self.gameId, 'userId=', userId, 'addScore=', toAdd, 'newScore=', score, 'oldLevel=', oldLevel.level, 'newLevel=', newLevel.level, 'ret=', ret) return ret
def loginGame(userId, gameId, clientId, iscreate, isdayfirst): ftlog.debug('hall.loginGame', userId, gameId, clientId, iscreate, isdayfirst) if isdayfirst: # 游戏登录天数加1 gamedata.incrGameAttr(userId, HALL_GAMEID, 'loginDays', 1) # 检测发送登录奖励 hall_login_reward.sendLoginReward(userId, HALL_GAMEID, clientId) hallitem._onUserLogin(gameId, userId, clientId, iscreate, isdayfirst) # 自动更新用户道具 hall_item_exchange.updateUserItems(userId, gameId, clientId) if not (iscreate or hallstartchip.needSendStartChip(userId, gameId)): hallbenefits.benefitsSystem.sendBenefits( gameId, userId, pktimestamp.getCurrentTimestamp())
def testFindProduct(self): remainDays, memberBonus = hallitem.getMemberInfo(self.userId, int(time.time())) todotask = hallpopwnd.makeTodoTaskNsloginReward(self.gameId, self.userId, self.clientId, remainDays, memberBonus) jstr = json.dumps(todotask.toDict(), indent=4, ensure_ascii=False) print jstr pkgamedata.incrGameAttr(self.userId, self.gameId, 'first_recharge', 1) pkgamedata.incrGameAttr(self.userId, self.gameId, 'first_recharge_reward', 1) #def addAsset(self, gameId, assetKindId, count, timestamp, eventId, intEventParam): hallitem.itemSystem.loadUserAssets(self.userId).addAsset(self.gameId, hallitem.ASSET_ITEM_MEMBER_KIND_ID, 1, 0, 0, 0) todotask = hallpopwnd.makeTodoTaskNsloginReward(self.gameId, self.userId, self.clientId, remainDays, memberBonus) jstr = json.dumps(todotask.toDict(), indent=4, ensure_ascii=False) print jstr todotask = hallpopwnd.makeTodoTaskLuckBuy(self.gameId, self.userId, self.clientId, 601) jstr = json.dumps(todotask.toDict(), indent=4, ensure_ascii=False) print jstr
def convertOldData(gameId, userId): """ 大厅v3.9存储改动,user数据库: 键message:g(gameid)u(userid),废弃 键msg:(gameId):(toUid),废弃 """ oldkey = 'message:g{}u{}'.format(gameId, userId) daobase.executeUserCmd(userId, 'DEL', oldkey) # from datetime import datetime # sendPrivate(9999, 10004, 0, 'oldmsg test now:{}'.format(datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f'))) hall37key = 'msg:{}:{}'.format(gameId, userId) rediskey = REDIS_KEY.format(MESSAGE_TYPE_PRIVATE, HALL_GAMEID, userId) new_msg_len = daobase.executeUserCmd(userId, 'HLEN', rediskey) # 限制50条 datas = daobase.executeUserCmd(userId, 'LRANGE', hall37key, 0, MAX_SIZE - new_msg_len - 1) if datas: for msgstr in datas: msg = strutil.loads(msgstr, ignoreException=True) if msg: new_msg = { 'gameid': gameId, 'time': msg['time'], 'text': msg['msg'] } if msg['from'] > 0: new_msg['from'] = msg['from'] maxid = gamedata.incrGameAttr(userId, HALL_GAMEID, 'msg.id.max', 1) daobase.executeUserCmd(userId, 'HSET', rediskey, maxid, strutil.dumps(new_msg)) daobase.executeUserCmd(userId, 'DEL', hall37key)
def sendPrivate(cls, gameId, toUid, fromUid, text): """ 游戏记录(使用大厅的游戏记录功能) """ ct = timestamp.formatTimeSecond() msg = {"gameid": gameId, "time": ct, "text": text} if fromUid: msg["from"] = fromUid rediskey = message.REDIS_KEY.format(message.MESSAGE_TYPE_PRIVATE, message.HALL_GAMEID, toUid) msglist = message._msg_load_and_expire(toUid, rediskey) if len(msglist) >= 100: # 超100条删除 lastmsgval = None for msgval in msglist: if lastmsgval: if message._msg_order(lastmsgval) > message._msg_order( msgval): continue lastmsgval = msgval if lastmsgval: daobase.executeUserCmd(toUid, "HDEL", rediskey, lastmsgval["id"]) maxid = gamedata.incrGameAttr(toUid, message.HALL_GAMEID, "msg.id.max", 1) daobase.executeUserCmd(toUid, "HSET", rediskey, maxid, strutil.dumps(msg))
def addShareInvitedUserId(shareUserId, invitedUserId, isNewUser=False): """ 添加分享邀请人信息 :param shareUserId: 分享卡片的分享者 :param invitedUserId: 点击卡片的被邀请者 :param isNewUser: 是否为新用户 """ inviteCount = weakdata.getDayFishData(shareUserId, "inviteCount", 0) if inviteCount < config.getCommonValueByKey("inviteLimitCount", 99999): if not isNewUser: inviteOldUserCount = weakdata.getDayFishData(shareUserId, "inviteOldUserCount", 0) if inviteOldUserCount > config.getCommonValueByKey("inviteLimitOldCount", 99999): return weakdata.incrDayFishData(shareUserId, "inviteOldUserCount", 1) inviteList = gamedata.getGameAttrJson(shareUserId, FISH_GAMEID, GameData.inviteList, []) inviteId = gamedata.incrGameAttr(shareUserId, FISH_GAMEID, GameData.inviteId, 1) inviteData = { "inviteId": inviteId, "userId": invitedUserId, "inviteTime": int(time.time()), "isNewUser": isNewUser, "isAppUser": 1 if util.isAppClient(invitedUserId) else 0 } inviteList.append(inviteData) gamedata.setGameAttr(shareUserId, FISH_GAMEID, GameData.inviteList, json.dumps(inviteList)) weakdata.incrDayFishData(shareUserId, "inviteCount", 1) module_tip.addModuleTipEvent(shareUserId, "invite", inviteId) getShareTaskInfo(shareUserId) from newfish.game import TGFish from newfish.entity.event import InvitedFinishEvent event = InvitedFinishEvent(shareUserId, FISH_GAMEID) TGFish.getEventBus().publishEvent(event)
def _sendMailBySender(senderUserId, receiverUserId, type, reward=None, desc=None, title=None): """ 添加邮件到发件人发件箱 :param senderUserId: 发件人 :param receiverUserId: 收件人 :param type: 邮件类型 :param reward: 附件奖励 :param desc: 邮件内容 :param title: 标题 """ curTime = int(time.time()) desc = desc or "" reward = reward or [] title = title or "" mailOutId = gamedata.incrGameAttr(senderUserId, FISH_GAMEID, GameData.outMailId, 1) mailOutInfos = gamedata.getGameAttrJson(senderUserId, FISH_GAMEID, GameData.outMailInfos, []) receiverUserName = util.getNickname(receiverUserId) mailOutInfos.insert(0, { "id": mailOutId, "userId": receiverUserId, "time": curTime, "name": receiverUserName, "reward": reward, "type": type, "desc": desc, "title": title }) mailOutInfos = _removeOutMailExpData(mailOutInfos, MAX_OUT_MAIL_COUNT) gamedata.setGameAttr(senderUserId, FISH_GAMEID, GameData.outMailInfos, json.dumps(mailOutInfos)) if type == MailRewardType.Present: lang = util.getLanguage(senderUserId) message = config.getMultiLangTextConf("ID_PRESENT_TO_OTHER_MSG", lang=lang) message = message.format(receiverUserName, receiverUserId, util.buildRewardsDesc(reward, lang)) GameMsg.sendPrivate(FISH_GAMEID, senderUserId, 0, message)
def doGetBindReward(self, gameId, userId, clientId): """ 获取绑定推荐人奖励 作为下线领取的奖励,只有一次 """ try: timestamp = pktimestamp.getCurrentTimestamp() status = hall_simple_invite.loadStatus(userId, timestamp) if (status.rewardState != Invitation.STATE_REWARDED) and \ status.getRewardState(userId, gameId, clientId) == Invitation.STATE_CAN_GET_REWARD: conf = hall_simple_invite.getSimpleInviteConf( userId, gameId, clientId) status.setRewardState(Invitation.STATE_REWARDED) hall_simple_invite.saveStatus(status) mo = MsgPack() mo.setCmd('invite_info') mo.setResult('action', 'get_bind_reward') mo.setResult('rewardState', status.rewardState) mo.setResult('gameId', gameId) count = self.getTotalReward(status) if conf.inviteRewardItem: if 0 == count: mo.setResult('totalReward', 0) else: total = gamedata.getGameAttrInt( userId, HALL_GAMEID, 'simpleInviteRewardCount') if 0 == total: total = count * conf.inviteRewardItem.count gamedata.incrGameAttr(userId, HALL_GAMEID, 'simpleInviteRewardCount', total) mo.setResult('totalReward', total) self.addUserItemByKindId(userId, gameId, clientId, conf.inviteRewardItem.assetKindId, conf.inviteRewardItem.count) gamedata.incrGameAttr(userId, HALL_GAMEID, 'simpleInviteRewardCount', conf.inviteRewardItem.count) router.sendToUser(mo, userId) else: TodoTaskHelper.sendTodoTask(gameId, userId, TodoTaskShowInfo('奖励已经领取', True)) except TYBizException, e: TodoTaskHelper.sendTodoTask(gameId, userId, TodoTaskShowInfo(e.message, True))
def incrVipExp(self, userId, count): ''' 给用户增加count个经验值,count可以为负数 @param userId: 哪个用户 @param count: 数量 @return: 变化后的值 ''' return pkgamedata.incrGameAttr(userId, 9999, 'vip.exp', count)
def on_praise_friend(cls, gameId, uid, clientId, mo): code = mo.getResult('code', 0) # vip = mo.getResult('vip') if code == 0: friend_uid = int(mo.getResult('friend_uid')) nick_name = mo.getResult('nick_name') friend_nick_name = mo.getResult('friend_nick_name') my_add_charm = mo.getResult('my_add_charm') friend_add_charm = mo.getResult('friend_add_charm') my_charm = mo.getResult('my_charm') friend_charm = mo.getResult('friend_charm') msg1 = '给"' + friend_nick_name + '"点赞获得' + str(my_add_charm) + '个魅力值' msg2 = '"' + nick_name + '"给您点赞获得' + str(friend_add_charm) + '个魅力值' from poker.entity.biz.message import message message.send(gameId, message.MESSAGE_TYPE_SYSTEM, int(uid), msg1) message.send(gameId, message.MESSAGE_TYPE_SYSTEM, int(friend_uid), msg2) ftlog.debug('on praise friend.... ' + msg1) ftlog.debug('on praise friend.... ' + msg2) datachangenotify.sendDataChangeNotify(gameId, uid, 'charm') from hall.entity.hallranking import rankingSystem, TYRankingInputTypes timestamp = pktimestamp.getCurrentTimestamp() rankingSystem.setUserByInputType(gameId, TYRankingInputTypes.CHARM, uid, my_charm, timestamp) rankingSystem.setUserByInputType(gameId, TYRankingInputTypes.CHARM, friend_uid, friend_charm, timestamp) # 历史获赞次数 history_praised_num = gamedata.incrGameAttr(friend_uid, gameId, 'history_praised_num', 1) mo.setResult('friend_history_praised_num', history_praised_num) if code != 2: return from hall.entity.todotask import TodoTaskPayOrder, TodoTaskShowInfo from hall.entity.todotask import TodoTaskHelper from hall.entity import hallvip, hallitem user_vip = hallvip.userVipSystem.getUserVip(uid) delta_exp = user_vip.deltaExpToNextLevel() product, _ = hallstore.findProductByContains(gameId, uid, clientId, ['coin'], None, hallitem.ASSET_CHIP_KIND_ID, delta_exp * 1000) pay_order = TodoTaskPayOrder(product) if user_vip == 0: msg = '点赞次数已达今日上限,开通VIP可提高点赞次数上限获得更多福利哦~' btnTxt = '开通VIP' else: msg = '点赞次数已达今日上限,升级VIP等级可提高点赞次数上限获得更多福利哦~' btnTxt = '升级VIP' dialog_task = TodoTaskShowInfo(msg, True) dialog_task.setSubCmd(pay_order) dialog_task.setSubText(btnTxt) TodoTaskHelper.sendTodoTask(gameId, uid, [dialog_task])
def _doTableWinloseUT(userId, roomId, tableId, roundNum, clientId, isWin, winStreak, winUserId, isDizhu, fee, cardNoteFee, winlose, systemPaid, winnerTax, baseScore, winDoubles, bomb, chuntian, winslam, playMode, topCardList, **kwargs): bigRoomId = strutil.getBigRoomIdFromInstanceRoomId(roomId) treasurebox.updateTreasureBoxWin(DIZHU_GAMEID, userId, kwargs.get('mixConfRoomId') or bigRoomId) exp, deltaExp, _winrate = comm_table_remote.checkSetMedal( DIZHU_GAMEID, userId, baseScore, False, winlose) deltaItems = buildSettlementDeltaItems( kwargs.get('mixConfRoomId') or roomId, fee, cardNoteFee, winlose, winnerTax) skillScoreInfo = _caleSkillScoreByUser( userId, isWin, winStreak, isDizhu, kwargs.get('mixConfRoomId') or bigRoomId, winDoubles) skillLevelUp = skillScoreInfo.get('isLevelUp', False) _reportRoomDelta(userId, roomId, bigRoomId, clientId, systemPaid) finalTableChip = _settlement(userId, kwargs.get('mixConfRoomId') or roomId, tableId, roundNum, clientId, deltaItems) # 纪录连胜 if isWin: gamedata.incrGameAttr(userId, DIZHU_GAMEID, 'winstreak', 1) else: gamedata.setGameAttr(userId, DIZHU_GAMEID, 'winstreak', 0) if ftlog.is_debug(): winstreaklog = gamedata.getGameAttr(userId, DIZHU_GAMEID, 'winstreak') ftlog.debug('_doTableWinloseUT winstreak=', winstreaklog, 'UserID=', userId, 'roomId=', roomId, 'tableId=', tableId, 'isWin=', isWin) # 广播用户结算事件 card = cardrules.CARD_RULE_DICT[playMode] topValidCard = card.validateCards(topCardList, None) finalUserChip = userchip.getChip(userId) _publishWinLoseEvent(roomId, tableId, userId, roundNum, isWin, isDizhu, winUserId, winlose, finalTableChip, winDoubles, bomb, chuntian, winslam, clientId, topValidCard, skillLevelUp, **kwargs) # 更新排名相关数据 _calRankInfoData(userId, winlose, winslam, winDoubles) return finalTableChip, finalUserChip, [exp, deltaExp], skillScoreInfo
def addWinCount(userId, gameId): ''' 增加获胜次数 :param userId: :param gameId: :param count: ''' if not isOpen(gameId): return 0 return gamedata.incrGameAttr(userId, gameId, "lotterytask_win", 1)
def handler(cls, userId): cls.cycleCheck(userId) playround = gamedata.incrGameAttr(userId, GAMEID, ':'.join([cls.name, cls.attr_round]), 1) clientId = sessiondata.getClientId(userId) ftlog.debug('sendShare playground handler userId=', userId, 'clientId=', clientId) return cls.findShare(clientId, playround), playround
def _caleWinStreakByUser(userId, winUserIds): winStreak = 0 if userId in winUserIds: winStreak = gamedata.incrGameAttr(userId, DIZHU_GAMEID, 'winstreak', 1) gamedata.setGameAttr(userId, DIZHU_GAMEID, 'stopwinstreak', 0) else: userWinStreak = gamedata.getGameAttr(userId, DIZHU_GAMEID, 'winstreak') gamedata.setGameAttr(userId, DIZHU_GAMEID, 'stopwinstreak', userWinStreak) gamedata.setGameAttr(userId, DIZHU_GAMEID, 'winstreak', 0) return winStreak
def _onChargeNotify(event): ftlog.info('hallstore._onChargeNotify gameId=', event.gameId, 'userId=', event.userId, 'diamonds=', event.diamonds, 'rmbs=', event.rmbs, 'firstRechargeThreshold=', storeSystem.firstRechargeThreshold) if event.diamonds >= storeSystem.firstRechargeThreshold: count = pkgamedata.incrGameAttr(event.userId, HALL_GAMEID, 'first_recharge', 1) if count == 1: TGHall.getEventBus().publishEvent(UserFirstRecharedEvent(HALL_GAMEID, event.userId)) datachangenotify.sendDataChangeNotify(HALL_GAMEID, event.userId, 'promotion_loc')
def addPool(userId, gameId, value): ''' 增加奖池 :param userId: :param gameId: :param count: ''' if not isOpen(gameId): return 0 bireport.reportGameEvent('HALL_LOTTERY_TASK_ADD', userId, gameId, 0, 0, 0, value, 0, 0, [], sessiondata.getClientId(userId)) return gamedata.incrGameAttr(userId, gameId, "lotterytask_pool", value)
def npw_todotask(userId, gameId, clientId, loginsum, isdayfirst, daylogin, npws_data): ftlog.debug("npw_todotask|enter", userId, gameId, clientId, loginsum, isdayfirst, daylogin, npws_data) npws = npws_data[0] data = npws_data[1] enable = data['enable'] condition = npws['condition'] if not enable or not checkConditionsTimes(userId, daylogin, npws): ftlog.debug("npw_todotask|timesNotMatch", enable, userId, daylogin) return if condition['typeId'] == "user.cond.and": if not checkConditionsAND(userId, gameId, clientId, condition): ftlog.debug("npw_todotask|user.cond.and", userId) return elif condition['typeId'] == "user.cond.or": if not checkConditionsOR(userId, gameId, clientId, condition): ftlog.debug("npw_todotask|user.cond.or", userId) return sendMsg2client(gameId, userId, "newpop_todotask", data) gamedata.incrGameAttr(userId, HALL_GAMEID, NPW_ + NPW_TODOTASK, 1)
def _onChargeNotify(event): ftlog.info('hallstore._onChargeNotify gameId=', event.gameId, 'userId=', event.userId, 'diamonds=', event.diamonds, 'rmbs=', event.rmbs, 'firstRechargeThreshold=', storeSystem.firstRechargeThreshold) if event.diamonds >= storeSystem.firstRechargeThreshold: count = pkgamedata.incrGameAttr(event.userId, HALL_GAMEID, 'first_recharge', 1) if count == 1: TGHall.getEventBus().publishEvent( UserFirstRecharedEvent(HALL_GAMEID, event.userId)) datachangenotify.sendDataChangeNotify(HALL_GAMEID, event.userId, 'promotion_loc')
def addfriend(cls, userId, friendId, gameId, prize, numlimit): ''' rpc ''' if not cls.friendNumLimit(userId, gameId, numlimit): return -1 friend = {'userId': friendId, 'state': 0} friendlist = gamedata.getGameAttr(userId, gameId, cls.attrname_invitedfriendlist) if not friendlist: friendlist = [] else: friendlist = json.loads(friendlist) existed = False for f in friendlist: if f['userId'] == friendId: existed = True break if existed: return -1 else: friendlist.append(friend) gamedata.setGameAttr(userId, gameId, cls.attrname_invitedfriendlist, json.dumps(friendlist)) gamedata.incrGameAttr(userId, gameId, cls.attrname_failchip, prize["CHIP"]) gamedata.incrGameAttr(userId, gameId, cls.attrname_invitedfriendnum, 1) friendnum = len(friendlist) if friendnum % 5 == 0: gamedata.incrGameAttr(userId, gameId, cls.attrname_failcoupon, prize["COUPON"]) return friendnum
def deliveryChestRewards(userId, chestId, rewards, eventId=None, fromType=None, param01=0, param02=0): """ 发放宝箱物品 """ if not rewards: ftlog.error("deliveryChestRewards->not rewards", userId, chestId) return 4 if not eventId: eventId = "BI_NFISH_OPEN_CHEST_REWARDS" code = util.addRewards(userId, rewards, eventId, int(chestId), param01=param01, param02=param02) if code != 0: ftlog.error("deliveryChestRewards->add gain error", userId, chestId, rewards) return code gamedata.incrGameAttr(userId, FISH_GAMEID, GameData.openChestCount, 1) bireport.reportGameEvent("BI_NFISH_GE_CHEST_OPEN", userId, FISH_GAMEID, 0, 0, int(chestId), 0, 0, 0, [], util.getClientId(userId)) if fromType: from newfish.game import TGFish from newfish.entity.event import GainChestEvent event = GainChestEvent(userId, FISH_GAMEID, chestId, fromType) TGFish.getEventBus().publishEvent(event) return 0
def testFindProduct(self): remainDays, memberBonus = hallitem.getMemberInfo( self.userId, int(time.time())) todotask = hallpopwnd.makeTodoTaskNsloginReward( self.gameId, self.userId, self.clientId, remainDays, memberBonus) jstr = json.dumps(todotask.toDict(), indent=4, ensure_ascii=False) print jstr pkgamedata.incrGameAttr(self.userId, self.gameId, 'first_recharge', 1) pkgamedata.incrGameAttr(self.userId, self.gameId, 'first_recharge_reward', 1) #def addAsset(self, gameId, assetKindId, count, timestamp, eventId, intEventParam): hallitem.itemSystem.loadUserAssets(self.userId).addAsset( self.gameId, hallitem.ASSET_ITEM_MEMBER_KIND_ID, 1, 0, 0, 0) todotask = hallpopwnd.makeTodoTaskNsloginReward( self.gameId, self.userId, self.clientId, remainDays, memberBonus) jstr = json.dumps(todotask.toDict(), indent=4, ensure_ascii=False) print jstr todotask = hallpopwnd.makeTodoTaskLuckBuy(self.gameId, self.userId, self.clientId, 601) jstr = json.dumps(todotask.toDict(), indent=4, ensure_ascii=False) print jstr
def doGetBindReward(self, gameId, userId, clientId): """ 获取绑定推荐人奖励 作为下线领取的奖励,只有一次 """ try: timestamp = pktimestamp.getCurrentTimestamp() status = hall_simple_invite.loadStatus(userId, timestamp) if (status.rewardState != Invitation.STATE_REWARDED) and \ status.getRewardState(userId, gameId, clientId) == Invitation.STATE_CAN_GET_REWARD: conf = hall_simple_invite.getSimpleInviteConf(userId, gameId, clientId) status.setRewardState(Invitation.STATE_REWARDED) hall_simple_invite.saveStatus(status) mo = MsgPack() mo.setCmd('invite_info') mo.setResult('action', 'get_bind_reward') mo.setResult('rewardState', status.rewardState) mo.setResult('gameId', gameId) count = self.getTotalReward(status) if conf.inviteRewardItem: if 0 == count: mo.setResult('totalReward', 0) else: total = gamedata.getGameAttrInt(userId, HALL_GAMEID, 'simpleInviteRewardCount') if 0 == total: total = count * conf.inviteRewardItem.count gamedata.incrGameAttr(userId, HALL_GAMEID, 'simpleInviteRewardCount', total) mo.setResult('totalReward', total) self.addUserItemByKindId(userId, gameId, clientId, conf.inviteRewardItem.assetKindId, conf.inviteRewardItem.count) gamedata.incrGameAttr(userId, HALL_GAMEID, 'simpleInviteRewardCount', conf.inviteRewardItem.count) router.sendToUser(mo, userId) else: TodoTaskHelper.sendTodoTask(gameId, userId, TodoTaskShowInfo('奖励已经领取', True)) except TYBizException, e: TodoTaskHelper.sendTodoTask(gameId, userId, TodoTaskShowInfo(e.message, True))
def npw_notice(userId, gameId, clientId, loginsum, isdayfirst, daylogin, npws_data): ftlog.debug("npw_notice|enter", userId, gameId, clientId, loginsum, isdayfirst, daylogin, npws_data) npws = npws_data[0] data = npws_data[1] enable = data['enable'] condition = npws['condition'] if not enable or not checkConditionsTimes(userId, daylogin, npws): ftlog.debug("npw_notice|timesNotMatch", enable, userId, daylogin) return if condition['typeId'] == "user.cond.and": if not checkConditionsAND(userId, gameId, clientId, condition): ftlog.debug("npw_notice|user.cond.and", userId) return elif condition['typeId'] == "user.cond.or": if not checkConditionsOR(userId, gameId, clientId, condition): ftlog.debug("npw_notice|user.cond.or", userId) return # 查看noticereward buttonText = data['buttonText'] if "sub_action" in data: if "noticereward" in data["sub_action"]: info = gamedata.getGameAttr(userId, HALL_GAMEID, NPW_ + "noticereward") if info: info = json.loads(info) if not info or info != data["sub_action"]["noticereward"]: data['buttonText'] = "领 取" ftlog.debug("noticereward|buttonText", userId, info, data["sub_action"]["noticereward"]) ftlog.debug("noticereward|buttonText2", userId, data["buttonText"]) sendMsg2client(gameId, userId, "newpop_notice", data) gamedata.incrGameAttr(userId, HALL_GAMEID, NPW_ + NPW_NOTICE, 1) data['buttonText'] = buttonText
def loginGame(userId, gameId, clientId, clipboard=None): """ 用户登录一个游戏, 检查用户的游戏数据是否存在(创建用户数据) """ # 确认用户的游戏数据是否存在 iscreate = ensureGameDataExists(userId, gameId, clientId) if not iscreate: _moveHall51DataBack(userId, gameId, clientId) # 游戏登录次数加1,每次bind_user都会加1,包括断线重连 loginsum = gamedata.incrGameAttr(userId, gameId, 'loginsum', 1) # 确认是否是今日第一次登录 isdayfirst = False datas = day1st.getDay1stDatas(userId, gameId) if 'daylogin' not in datas: isdayfirst = True datas['daylogin'] = 1 datas['iscreate'] = 1 else: datas['daylogin'] += 1 datas['iscreate'] = 0 day1st.setDay1stDatas(userId, gameId, datas) if isdayfirst: # 消息的数据结构新旧转换 message.convertOldData(gameId, userId) # 插件的登录补充处理 TYGame(gameId).loginGame(userId, gameId, clientId, iscreate, isdayfirst) try: from poker.entity.configure import pokerconf numClientId = pokerconf.clientIdToNumber(clientId) updateHistoryClientIdsIfNeed(userId, gameId, numClientId) except: pass evt = EventUserLogin(userId, gameId, isdayfirst, iscreate, clientId) evt.clipboard = clipboard TYGame(gameId).getEventBus().publishEvent(evt) userdata.updateUserGameDataAuthorTime(userId, gameId) # 新大厅v4.56功能入口 # from hall.entity.localservice import localservice # localservice.loginGame_v456(userId, gameId, clientId, loginsum, isdayfirst, datas['daylogin']) return isdayfirst, iscreate
def sendSingleOldUserPrize(cls, userId, gameId, chip, coupon): ftlog.info("sendSingleOldUserPrize userId=", userId, "gameId=", gameId, "chip=", chip, "coupon=", coupon) notify = [] if chip != 0: userchip.incrChip(userId, gameId, chip, daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO, 'ACTIVITY_REWARD', 0, None) notify.append('chip') gamedata.incrGameAttr(userId, gameId, cls.attrname_succchip, chip) gamedata.incrGameAttr(userId, gameId, cls.attrname_failchip, -chip) if coupon != 0: userchip.incrCoupon(userId, gameId, coupon, daoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE, 'COUPON_DIZHU_NEI_TUI_GUANG', 0, None) gamedata.incrGameAttr(userId, gameId, cls.attrname_succcoupon, coupon) gamedata.incrGameAttr(userId, gameId, cls.attrname_failcoupon, -coupon) notify.append('item') cls.updateNotify(gameId, userId, notify)
def addOneHistory(userId, otherUserId, type, ftId, rewards=None): ftlog.debug("addOneHistory->", userId, otherUserId, type, rewards) curTime = int(time.time()) desc = "" rewards = rewards or [] otherUserId = otherUserId or 0 # 添加对战详情到发件人发件箱 if userId > 10000: otherUserName = "" if otherUserId: otherUserName = util.getNickname(otherUserId) # if type == HistoryType.CreatRoom: # if rewards: # desc = u"创建了奖励为%s的竞技房间" % (getRewardDesc(rewards)) # else: # desc = "创建了竞技房间" # elif type == HistoryType.Unbind: # if rewards: # desc = u"解散了奖励为%s的竞技房间" % (getRewardDesc(rewards)) # else: # desc = "解散了房间" # elif type == HistoryType.Win: # if rewards: # desc = u"在和%s(账号:%d)的竞技中获得第1名,赢了%s" % (otherUserName, otherId, getRewardDesc(rewards)) # else: # desc = u"在和%s(账号:%d)的竞技中获得第1名" % (otherUserName, otherId) # elif type == HistoryType.Lose: # desc = u"在和%s(账号:%d)的竞技中获得第2名" % (otherUserName, otherId) historyId = gamedata.incrGameAttr(userId, FISH_GAMEID, GameData.fightHistoryId, 1) historyInfos = gamedata.getGameAttrJson(userId, FISH_GAMEID, GameData.fightHistory, []) historyInfos.append({ "id": historyId, "userId": otherUserId, "time": curTime, "name": otherUserName, "reward": rewards, "type": type, "ftId": ftId, "desc": desc }) historyInfos = _removeHistoryExpData(historyInfos, 50) gamedata.setGameAttr(userId, FISH_GAMEID, GameData.fightHistory, json.dumps(historyInfos))
def incrSkillScore(userId, add_score): assert (add_score >= 0) tootle = gamedata.incrGameAttr(userId, DIZHU_GAMEID, 'skillscore', add_score) # 大师分增量榜 ftlog.debug('setUserByInputType userId=', userId, 'add_score=', add_score, TYRankingInputTypes.DASHIFEN_INCR) hallranking.rankingSystem.setUserByInputType( 6, TYRankingInputTypes.DASHIFEN_INCR, userId, add_score, timestamp.getCurrentTimestamp()) oldScore = tootle - add_score level_old = get_skill_level(oldScore) level_new = get_skill_level(tootle) sinfo = score_info(userId) sinfo['userId'] = userId sinfo['addScore'] = add_score # add by wuyangwei if level_old != level_new: # 修改昵称 change_name = False need_level = dizhuconf.getChangeNickNameLevel() if need_level == level_new: set_name_sum = hallrename.getRenameSum(DIZHU_GAMEID, userId) if set_name_sum <= 0: sinfo['changename'] = 1 #服务器修改此标记,客户端识别弹出改昵称界面 change_name = True # 升级奖励 up_info = get_skill_level_reward(userId, level_old, level_new) if (not change_name) and up_info: sinfo['rewards'] = up_info # 是否升级, 以前通过升级奖励配置, 配置去掉后会有问题 sinfo['isLevelUp'] = True from dizhu.game import TGDizhu TGDizhu.getEventBus().publishEvent( SkillScoreIncrEvent(DIZHU_GAMEID, userId, oldScore, level_old, tootle, level_new)) ftlog.debug('SkillScore.incrSkillScore gameId=', DIZHU_GAMEID, 'userId=', userId, 'addScore=', add_score, 'newScore=', tootle, 'oldLevel=', level_old, 'newLevel=', level_new, 'skillInfo=', sinfo) return sinfo
def sendMailToReceiver(senderUserId, receiverUserId, type, reward=None, desc=None, title=None): """ 添加邮件到收件人收件箱 :param senderUserId: 发件人 :param receiverUserId: 收件人 :param type: 邮件类型 :param reward: 附件奖励 :param desc: 邮件内容 :param title: 标题 """ curTime = int(time.time()) desc = desc or "" reward = reward or [] title = title or "" mailSendId = gamedata.incrGameAttr(receiverUserId, FISH_GAMEID, GameData.mailId, 1) # 邮件的有效期 mailSenderType = MailSenderType.MT_SYS if senderUserId == config.ROBOT_MAX_USER_ID else MailSenderType.MT_USERS expireTs = curTime + _getMailExpireTime(mailSenderType) # 邮件数据存储key(系统邮件、玩家邮件) mailKey = GameData.mailInfos if senderUserId == config.ROBOT_MAX_USER_ID else GameData.userMailInfos mailInfos = gamedata.getGameAttrJson(receiverUserId, FISH_GAMEID, mailKey, []) senderUserName = util.getNickname(senderUserId) mailInfos.insert(0, { "id": mailSendId, "userId": senderUserId, "time": curTime, "expireTime": expireTs, "name": senderUserName, "reward": reward, "type": type, "desc": desc, "state": MailState.Default, "title": title }) mailInfos = _removeMailExpData(mailInfos, MAIL_DISPLAY_COUNT) gamedata.setGameAttr(receiverUserId, FISH_GAMEID, mailKey, json.dumps(mailInfos)) _dealTips(receiverUserId, mailInfos, mailSenderType) if type == MailRewardType.Present: lang = util.getLanguage(receiverUserId) message = config.getMultiLangTextConf("ID_ACCEPT_PRESENT_MSG", lang=lang) message = message.format(senderUserName, senderUserId, util.buildRewardsDesc(reward, lang)) GameMsg.sendPrivate(FISH_GAMEID, receiverUserId, 0, message)
def findRewardUsers(gameId, issue, reward, clientId): x = random.randint(1, hallroulette.soldierSysTem.getSoldierNumber()) soldier = hallroulette.soldierSysTem.getSoldierforsId(x) count = 3 while (count): if soldier: break x = random.randint(1, hallroulette.soldierSysTem.getSoldierNumber()) soldier = hallroulette.soldierSysTem.getSoldierforsId(x) count -= 1 ftlog.info('findRewardUsers.gameId=', gameId, 'issue=', issue, 'reward=', reward, 'clientId=', clientId, 'x=', x, 'soldier=', soldier) if not soldier: ftlog.info('findRewardUsers.gameId=', gameId, 'issue=', issue, 'reward=', reward, 'errorMessage=', 'not find the soldier user!') return 0, 0 nowUserId = soldier.get('userId', 0) chip = pkuserchip.getUserChipAll(nowUserId) vip = hallvip.userVipSystem.getUserVip(nowUserId).vipLevel.level userInfo = halluser.getUserInfo(nowUserId, gameId, clientId) result = {} result['chip'] = chip result['vip'] = vip result['sex'] = userInfo.get('sex', 0) result['purl'] = userInfo.get('purl', '') result['sId'] = '%07d' % x result['uId'] = nowUserId result['issue'] = issue result['name'] = userInfo.get('name', '') result['nowReward'] = reward nowRewardNumber = pkgamedata.incrGameAttr(nowUserId, 9999, 'getRewardNumber', 1) result['getRewardNumber'] = nowRewardNumber result['isCheckin'] = 0 result['checkinSoldiers'] = pkgamedata.getGameAttrInt( nowUserId, 9999, 'checkinSoldiers') ftlog.info('findRewardUsers.gameId=', gameId, 'nowUserId=', nowUserId, 'result=', result) return nowUserId, result
def send(gameid, typeid, touid, text, fromuid=None, attachment=None): """ 发送消息给指定用户 @param gameid: 哪个游戏发的 @param typeid: 类型, L{message.MESSAGE_TYPES} @param touid: 接收用户id @param text: 消息文本 @param fromuid: 发送用户id, 默认系统 @param attachment: 消息附件, 默认没有 @return: """ if typeid not in MESSAGE_TYPES: raise Exception("message.send, unkown type:{}".format(typeid)) ct = timestamp.formatTimeSecond() msg = {'gameid': gameid, 'time': ct, 'text': text} if fromuid: msg['from'] = fromuid if attachment: if not isinstance(attachment, Attachment): raise Exception("message.send, unkown attachment!!") msg['attachment'] = attachment.marshal() rediskey = REDIS_KEY.format(typeid, HALL_GAMEID, touid) msglist = _msg_load_and_expire(touid, rediskey) if len(msglist) >= MAX_SIZE: # 超50条删除 lastmsgval = None for msgval in msglist: if lastmsgval: if _msg_order(lastmsgval) > _msg_order(msgval): continue lastmsgval = msgval if lastmsgval: daobase.executeUserCmd(touid, 'HDEL', rediskey, lastmsgval['id']) maxid = gamedata.incrGameAttr(touid, HALL_GAMEID, 'msg.id.max', 1) daobase.executeUserCmd(touid, 'HSET', rediskey, maxid, strutil.dumps(msg)) tip = ModuleTipEvent(touid, HALL_GAMEID, "message", 1) pkeventbus.globalEventBus.publishEvent(tip) return maxid
def updateLoginData(userId): """ 更新用户登录数据 """ curTime = int(time.time()) lastLoginTime = gamedata.getGameAttrInt(userId, FISH_GAMEID, GameData.lastloginTime) or curTime returner_mission.refreshReturnerMissionData(userId, lastLoginTime) # 刷新回归豪礼数据 lastLoginTime = util.getDayStartTimestamp(lastLoginTime) todayStartTime = util.getDayStartTimestamp(curTime) gamedata.setGameAttr(userId, FISH_GAMEID, GameData.lastloginTime, curTime) # 过天 if todayStartTime - lastLoginTime > 24 * 3600: gamedata.incrGameAttr(userId, FISH_GAMEID, GameData.loginDays, 1) gamedata.setGameAttr(userId, FISH_GAMEID, GameData.continuousLogin, 1) elif todayStartTime - lastLoginTime == 24 * 3600: # 正好一天 gamedata.incrGameAttr(userId, FISH_GAMEID, GameData.loginDays, 1) gamedata.incrGameAttr(userId, FISH_GAMEID, GameData.continuousLogin, 1)
def getShareReward(gameId, userId, share, shareLoc, timestamp): ''' 给用户发放分享奖励 ''' # 分享BI日志汇报 clientId = sessiondata.getClientId(userId) bireport.reportGameEvent('SHARE_CALLBACK', userId, gameId, share.shareId, 0, 0, 0, 0, 0, [], clientId) # 记录分享次数 gamedata.incrGameAttr(userId, HALL_GAMEID, 'shareCount', 1) TGHall.getEventBus().publishEvent(HallShareEvent(gameId, userId, share.shareId, shareLoc)) # 首先处理 分享相关的通知 notifyInfoStr = pkgamedata.getGameAttr(userId, HALL_GAMEID, 'shareInfo') newInfo = {} pkgamedata.setGameAttr(userId, HALL_GAMEID, 'shareInfo', json.dumps(newInfo)) if notifyInfoStr: notifyInfo = json.loads(notifyInfoStr) shareId = notifyInfo.get('shareId', 0) if shareId == share.shareId: # 通知 info = notifyInfo.get('info', '') module = notifyInfo.get('module', '') if module == hall_red_envelope.TYRedEnvelope.EVENTID: hall_red_envelope.TYRedEnvelopeMgr.changeRedEnvelopeState(info, hall_red_envelope.TYRedEnvelope.STATE_SHARED) from poker.entity.game.game import TYGame clientId = sessiondata.getClientId(userId) gameids = hallconf.getDaShiFenFilter(clientId) for gid in gameids: TYGame(gid).sendTuyooRedEnvelopeCallBack(userId, clientId, info) # 分享奖励 ok, rewardCount = incrRewardCount(userId, share, timestamp) if not ok: if ftlog.is_debug(): ftlog.debug('hallshare.getShareReward already no share, check update share promote ...') ftlog.debug('hallshare.getShareReward fail gameId=', gameId, 'userId=', userId, 'shareId=', share.shareId, 'shareLoc=', shareLoc, 'rewardCount=', rewardCount, 'maxRewardCount=', share.maxRewardCount) return False assetList = sendReward(gameId, userId, share, shareLoc) if assetList and share.mail: TodoTaskHelper.sendTodoTask(gameId, userId, TodoTaskGoldRain(share.mail)) ftlog.debug('hallshare.getShareReward ok gameId=', gameId, 'userId=', userId, 'shareId=', share.shareId, 'shareLoc=', shareLoc, 'rewardCount=', rewardCount, 'maxRewardCount=', share.maxRewardCount, 'reward=', [(at[0].kindId, at[1]) for at in assetList] if assetList else []) if share.mail: pkmessage.send(gameId, pkmessage.MESSAGE_TYPE_SYSTEM, userId, share.mail) # udpate free & promotion_loc datachangenotify.sendDataChangeNotify(gameId, userId, ['free', 'promotion_loc']) return True
def findRewardUsers(gameId, issue, reward): ''' 开奖: 从本期小兵中获取一个中奖的小兵,并且返回 修改 首先,判断是否有多余的小兵,对多余的小兵进行管理 ''' needNumber = getSnatchConf().get('needNumber', 0) nowNumber = getSoldierNumber() if needNumber > nowNumber: return 0, 0, {} # 中奖序号 x = random.randint(1, needNumber) # 本期小兵list soldiers = daobase.executeMixCmd('LRANGE', CURKEY, 0, needNumber - 1) if not soldiers: return 0, 0 # 移除本期小兵,留下下一期小兵 daobase.executeMixCmd('LTRIM', CURKEY, needNumber, -1) # 开奖的时候,对每一个参与人的夺宝次数加1 uids = [] for soldier in soldiers: if soldier not in uids: pkgamedata.incrGameAttr(soldier, HALL_GAMEID, 'checkinSoldiers', 1) uids.append(soldier) # 生成中奖结果 nowUserId = soldiers[x] chip = pkuserchip.getUserChipAll(nowUserId) vip = hallvip.userVipSystem.getUserVip(nowUserId).vipLevel.level userInfo = halluser.getUserInfo(nowUserId, gameId, sessiondata.getClientId(nowUserId)) result = {} result['chip'] = chip result['vip'] = vip result['sex'] = userInfo.get('sex', 0) result['purl'] = userInfo.get('purl', '') result['sId'] = getSoldierIdByIndex(x) result['uId'] = nowUserId result['issue'] = issue result['name'] = userInfo.get('name', '') result['nowReward'] = reward # 添加夺宝次数 # 夺宝人的夺宝次数 nowRewardNumber = pkgamedata.incrGameAttr(nowUserId, HALL_GAMEID, 'getRewardNumber', 1) result['getRewardNumber'] = nowRewardNumber result['isCheckin'] = 0 # 添加夺宝人的夺宝次数 result['checkinSoldiers'] = pkgamedata.getGameAttrInt(nowUserId, HALL_GAMEID, 'checkinSoldiers') # 下发奖励的时候,全服广播,发led strLed = '恭喜' + userInfo.get('name', '') + '玩家在转盘夺宝活动中,斩获' + issue + '期' + reward + '大奖,不要再等了,你就是下一位夺宝王!' from hall.servers.util.rpc import user_remote as SendLed SendLed.sendHallLed(gameId, strLed, 1, 'hall') # 打印开奖日志 ftlog.hinfo('findRewardUsers.gameId=', gameId, 'issue=', issue, 'userId=', nowUserId, 'reward=', reward, 'soldiers=', soldiers, 'result=', result, 'x=', x, 'snatchConf=', getSnatchConf()) # 保存历史中奖信息 issueObj = {} issueObj['issue'] = issue issueObj['soldiers'] = soldiers issueObj['result'] = result issueObj['time'] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) # 保存本期中奖信息 daobase.executeMixCmd('HSET', HISKEYDETAIL + str(issue), 'info', json.dumps(issueObj)) daobase.executeMixCmd('LPUSH', HISKEY, issue) if daobase.executeMixCmd('LLEN', HISKEY) > 10: delIssue = daobase.executeMixCmd('RPOP', HISKEY) if ftlog.is_debug(): ftlog.debug('hallroulette.findRewardUsers delIssue:', delIssue) # 删除过期记录 if delIssue: daobase.executeMixCmd('DEL', HISKEYDETAIL + str(delIssue)) return nowUserId, result