def clientReqCheckin(userId, clientId, gameId): from hall.entity.localservice import localservice ftlog.debug("|clientReqCheckin|freeItemId|", userId, gameId, clientId) if not localservice.checkClientVer(userId, gameId, clientId): if ftlog.is_debug(): ftlog.debug("clientReqCheckin|less|clientVer", userId, gameId, clientId, clientId) return info = gamedata.getGameAttr(userId, HALL_GAMEID, 'checkin_new') if not info: ftlog.hinfo("clientReqCheckin|redis|havenot|checkin_new|", userId, gameId, clientId) return checkinImpl(userId, json.loads(info), clientId, gameId, True, '', WHERE_REQ)
def queryExitRemind(gameId, userId, clientId): global _ordersMap exitSDK = queryExitSDK(gameId, userId, clientId) if ftlog.is_debug(): ftlog.debug('queryExitRemind exitSDK:', exitSDK) gameIdInClientId = strutil.getGameIdFromHallClientId(clientId) if ftlog.is_debug(): ftlog.debug('hall_exit_remind.queryExitRemind gameIdInClientId', gameIdInClientId) strGameId = str(gameIdInClientId) if strGameId not in _ordersMap: if ftlog.is_debug(): ftlog.debug( 'hall_exit_remind.queryExitRemind no this game exit remind config....' ) return orders = _ordersMap[strGameId] if ftlog.is_debug(): ftlog.debug('hall_exit_remind.queryExitRemind orders:', orders) for order in orders: if ftlog.is_debug(): ftlog.debug('hall_exit_remind.queryExitRemind order:', order) if order.get('name', '') == 'checkin': # 是否是v4.56 from hall.entity.localservice.localservice import checkClientVer if checkClientVer(userId, gameId, clientId): ftlog.hinfo("queryExitRemind|checkClientVer|clientVer|gt|", userId, gameId, clientId) continue conds = UserConditionRegister.decodeList(order.get('conditions', [])) if ftlog.is_debug(): ftlog.debug('hall_exit_remind.queryExitRemind conds:', conds) bCondsOK = False if len(conds) == 0: bCondsOK = True for cond in conds: if cond.check(HALL_GAMEID, userId, clientId, pktimestamp.getCurrentTimestamp()): if ftlog.is_debug(): ftlog.debug('hall_exit_remind.queryExitRemind cond ok: ', cond) bCondsOK = True break if bCondsOK: todotasksDict = order.get('todotasks', []) todotasks = TodoTaskRegister.decodeList(todotasksDict) if ftlog.is_debug(): ftlog.debug('hall_exit_remind.queryExitRemind todotasks:', todotasks) todos = TodoTaskHelper.makeTodoTasksByFactory( HALL_GAMEID, userId, clientId, todotasks) tasks = TodoTaskHelper.encodeTodoTasks(todos) if ftlog.is_debug(): ftlog.debug( 'hall_exit_remind.queryExitRemind build tasks ok: ', tasks) mo = MsgPack() mo.setCmd('game') mo.setResult('action', 'get_exit_remind') mo.setResult('gameId', gameId) mo.setResult('userId', userId) mo.setResult('button', order.get('button', '')) mo.setResult('tips', order.get('tips', '')) mo.setResult('tasks', tasks) mo.setResult('exitSDK', exitSDK) router.sendToUser(mo, userId) if ftlog.is_debug(): ftlog.debug('hall_exit_remind.queryExitRemind userId:', userId, ' clientId:', clientId, ' msg:', mo) return
def noticeReward(userId, gameId, clientId, msg): from hall.entity.localservice import localservice ftlog.debug("noticeReward:", userId, gameId, clientId, msg) # 是否是登录大厅 if gameId != HALL_GAMEID: ftlog.debug("noticeReward|isnotloginHall", gameId) return # 是否是v4.56 if not localservice.checkClientVer(userId, gameId, clientId): ftlog.debug("noticeReward|failer|clientVer|isnotMatch|", userId, gameId, clientId) return data = getNoticeRewardData(userId, gameId, clientId) if not data: ftlog.warn("noticeReward|haveNotConfig", userId, gameId, clientId) return ftlog.debug("noticeReward|data|", userId, "sub_action" in data, data) if "sub_action" in data: if "noticereward" in data["sub_action"]["params"]: info = gamedata.getGameAttr(userId, HALL_GAMEID, NPW_ + "noticereward") ftlog.debug("noticereward|redis", userId, info, type(info), data["sub_action"]["params"]["noticereward"], type(data["sub_action"]["params"]["noticereward"]), info == data["sub_action"]["params"]["noticereward"]) if info: info = json.loads(info) if not info or info != data["sub_action"]["params"]["noticereward"]: if "params" not in data["sub_action"] or "reward" not in data[ "sub_action"]["params"]: ftlog.warn("noticeReward|ConfigError!", userId, gameId, clientId) return rewardList = [] rewardds = data["sub_action"]["params"]["reward"] for rewardd in rewardds: addAssetnpw(userId, rewardd['itemId'], rewardd['count'], "HALL_NEWNOTICEREWARD") rewardList.append({ 'name': rewardd['name'], 'pic': rewardd['pic'], 'count': rewardd['count'] }) gamedata.setGameAttr( userId, HALL_GAMEID, NPW_ + "noticereward", json.dumps(data["sub_action"]["params"]["noticereward"])) rewardTodotask = TodoTaskShowRewards(rewardList) TodoTaskHelper.sendTodoTask(gameId, userId, rewardTodotask) ftlog.debug("noticereward|addAssetnpw。", userId) else: ftlog.debug("noticereward|alreadydone。", userId) msg = u"对不起,您已经领过该奖励了。" infoTodoTask = TodoTaskShowInfo(msg, True) TodoTaskHelper.sendTodoTask(gameId, userId, infoTodoTask)