def _get_conf_by_client_id(clientId): """通过client id获取代理代理商场配置""" int_client_id = pokerconf.clientIdToNumber(clientId) for conf in configure.getGameJson(HALL_GAMEID, "inviter_shop")['conf']: if int_client_id in conf['clientIds']: return conf return {}
def queryExitSDK(gameId, userId, clientId): clientIdNum = pokerconf.clientIdToNumber(clientId) number = str(clientIdNum) actual = hall_exit_remind._vcConfig['actual'] if number in actual: return actual[number] return hall_exit_remind._vcConfig['default']
def checkUserData(userId, clientId=None, appId=0): ''' 检查当前用户的数据是否是热数据(即存储在REDIS), 如果不是热数据, 那么重MYSQL中读取冷数据导入至热数据中 同时更新当前用户的数据生命时间 导入导出的用户数据包括user和个个游戏的所有数据 返回: 如果用户数据的最终状态为热数据,返回1 如果用户数据不存在,返回0 ''' ftlog.debug('MySqlSwap checkUserData->userId=', userId, 'clientId=', clientId, 'appId=', appId) userId = int(userId) ctfull = timestamp.formatTimeMs() isok = daobase.executeUserLua(userId, dataswap_scripts.CHECK_USER_DATA_LUA_SCRIPT, 2, userId, ctfull) ftlog.debug('MySqlSwap checkUserData->userId=', userId, 'clientId=', clientId, 'appId=', appId, 'isok=', isok) if isok == 1: return 1 if clientId: intClientId = pokerconf.clientIdToNumber(clientId) else: intClientId = configure.DEFAULT_CLIENT_ID appId = int(appId) return _tryReadDataFromMySql(userId, intClientId, appId, ctfull)
def getGameListTemplateName(clientId): intClientId = pokerconf.clientIdToNumber(clientId) ftlog.debug("intClientId:", intClientId) if intClientId == 0: return 'hall_game_default' template = configure.getGameJson(HALL_GAMEID, 'gamelist', {}, intClientId) return template.get('template', 'hall_game_default')
def checkActivityActive(self, userId, timeStamp=None, clientId=None): if not self._open: return False timeStamp = pktimestamp.getCurrentTimestamp( ) if not timeStamp else timeStamp if self.checkTime(timeStamp) != 0: if ftlog.is_debug(): ftlog.debug('ActivityScoreRanking.checkActivityActive:', 'userId=', userId, 'actId=', self.actId, 'checkTime=False') return False if self.isOutOfTime(): if ftlog.is_debug(): ftlog.debug('ActivityScoreRanking.checkActivityActive:', 'userId=', userId, 'actId=', self.actId, 'outOfTime') return False clientId = clientId or sessiondata.getClientId(userId) user_gameId = strutil.getGameIdFromHallClientId(clientId) intClientId = pokerconf.clientIdToNumber(clientId) if user_gameId not in self._hallGameIds: return False if intClientId not in self._clientIds: if ftlog.is_debug(): ftlog.debug('ActivityScoreRanking.checkActiveFalse: userId=', userId, 'intClientId=', intClientId, 'clientIds=', self._clientIds) return False return True
def getNeedUpdateVersion(self, clientId, updatever): intClientId = pokerconf.clientIdToNumber(clientId) load_data = hallconf.getUpgradeIncConf(self.__gameId, clientId) clv = self._generateFrom(intClientId, load_data) if clv: return clv.makeNeedUpdateVersion(updatever) return None
def get_play_mode_config_by_clientId(clientId): """根据clientId获取自建桌支持的玩法列表""" key = 'room.other' intClientId = pokerconf.clientIdToNumber(clientId) play_mode_list = configure.getTcContentByClientId(key, None, intClientId, []) ftlog.debug('get_play_mode_config_by_clientId | clientId:', clientId, '| intClientId:', intClientId, '| play_mode_list:', play_mode_list) return play_mode_list
def queryExitSDK(gameId, userId, clientId): clientIdNum = pokerconf.clientIdToNumber(clientId) number = str(clientIdNum) actual = hall_exit_remind._vcConfig['actual'] if number in actual: return actual[number] return hall_exit_remind._vcConfig['default']
def getGameListTemplateName(clientId): intClientId = pokerconf.clientIdToNumber(clientId) ftlog.debug("intClientId:", intClientId) if intClientId == 0: return 'hall_game_default' template = configure.getGameJson(HALL_GAMEID, 'gamelist', {}, intClientId) return template.get('template', 'hall_game_default')
def getHallHtmlsInfo(clientId): try: gameId = strutil.getGameIdFromHallClientId(clientId) intClientId = pokerconf.clientIdToNumber(clientId) return configure.getGameTemplateInfo(gameId, 'htmls.info', intClientId, _adjustHallHtmlsInfo) except: ftlog.error('ERROR getHallHtmlsInfo clientId=', clientId)
def getNeedUpdateVersion(self, clientId, updatever): intClientId = pokerconf.clientIdToNumber(clientId) load_data = hallconf.getUpgradeIncConf(self.__gameId, clientId) clv = self._generateFrom(intClientId, load_data) if clv : return clv.makeNeedUpdateVersion(updatever) return None
def getRoomLevelNameWithClientId(gameId, bigRoomId, clientId): """ 通过clientId获取游戏模板配置,没有返回游戏模板配置默认模板0.json """ intClientidNum = pokerconf.clientIdToNumber(clientId) conf = configure.getGameJson(gameId, 'chargelead', None, intClientidNum) if conf: return conf.get(str(bigRoomId)) else: return getRoomLevelName(gameId, bigRoomId)
def getHallHtmlsInfo(clientId): try: gameId = strutil.getGameIdFromHallClientId(clientId) intClientId = pokerconf.clientIdToNumber(clientId) return configure.getGameTemplateInfo(gameId, 'htmls.info', intClientId, _adjustHallHtmlsInfo) except: ftlog.error('ERROR getHallHtmlsInfo clientId=', clientId)
def clientIdToNumber(clientId): cid = 0 try: cid = pokerconf.clientIdToNumber(clientId) except: pass if cid == 0: ftlog.warn('group_match_remote.clientIdToNumber failed:', clientId) return cid
def _findClientActId(cls, clientId): """ 用户对应的活动 Id, 没有返回 None """ for actConf in cls._getActIdList(): intClientId = pokerconf.clientIdToNumber(clientId) if intClientId in actConf.get('clientIds', []): return actConf.get('actId') return
def queryExitSDK(gameId, userId, clientId): global _vcConfig clientIdNum = pokerconf.clientIdToNumber(clientId) number = str(clientIdNum) actual = _vcConfig['actual'] if number in actual: return actual[number] return _vcConfig['default']
def clientIdToNumber(clientId): cid = 0 try: cid = pokerconf.clientIdToNumber(clientId) except: pass if cid == 0: ftlog.warn('group_match_remote.clientIdToNumber failed:', clientId) return cid
def queryExitSDK(gameId, userId, clientId): global _vcConfig clientIdNum = pokerconf.clientIdToNumber(clientId) number = str(clientIdNum) actual = _vcConfig['actual'] if number in actual: return actual[number] return _vcConfig['default']
def getClientRankTemplateName(rankingKey, clientId): intClientId = pokerconf.clientIdToNumber(clientId) if intClientId == 0: return None rankingKeys = configure.getGameJson(HALL_GAMEID, 'ranking', {}, intClientId).get('rankingKeys') if not rankingKeys: return None return rankingKeys.get(rankingKey)
def getClientRankTemplateName(rankingKey, clientId): intClientId = pokerconf.clientIdToNumber(clientId) if intClientId == 0: return None rankingKeys = configure.getGameJson(HALL_GAMEID, 'ranking', {}, intClientId).get('rankingKeys') if not rankingKeys: return None return rankingKeys.get(rankingKey)
def getMoreGamesUpdateApks(clientId): try: gameId = strutil.getGameIdFromHallClientId(clientId) intClientId = pokerconf.clientIdToNumber(clientId) apks = configure.getGameTemplateInfo(gameId, 'more.games.apks', intClientId, None) if not apks: ftlog.error('ERROR, getMoreGamesUpdateApks clientId=', clientId) return apks except: ftlog.error('ERROR, getMoreGamesUpdateApks clientId=', clientId) return None
def _parseClientIdNum(clientId): """ 解析客户端数字 :param clientId: :return: """ if isinstance(clientId, (str, unicode)): return pokerconf.clientIdToNumber(clientId) elif isinstance(clientId, (int, float)): return int(clientId) return 0
def getOnlineUserCountRate(clientId): gameId = strutil.getGameIdFromHallClientId(clientId) intClientidNum = pokerconf.clientIdToNumber(clientId) infos = configure.getGameJson(gameId, 'online.info', {}, intClientidNum) rate = infos.get('rate', None) if rate: return rate infos = configure.getGameJson(gameId, 'online.info', {}, 0) rate = infos.get('rate', None) if rate: return rate return 1
def handleRequest(self, msg): userId = msg.getParam('userId') action = msg.getParam("action") clientId = msg.getParam('clientId') intClientId = pokerconf.clientIdToNumber(clientId) actId = self.getActId() if ftlog.is_debug(): ftlog.debug('ActivityChristmasHandler.handleRequest', 'userId=', userId, 'action=', action, 'clientId=', clientId, 'intClientId=', intClientId, 'actId=', actId, 'msg=', msg) if not actId: ftlog.warn() return {'code': -1, 'info': 'please ensure act_ddz_christmas activity in [game/6/activity.new/0.json]'} from dizhu.activitynew import activitysystemnew actChristmas = activitysystemnew.findActivity(actId) if actChristmas: errInfo = u"" if self.ACTION_EXCHANGE == action: errInfo = actChristmas.exchange(userId) collectList = actChristmas.getUserCollectList(userId) socks = [] for collectItem in collectList: # [itemId, balance, itemCount, todotask] total = collectItem[1] done = collectItem[2] todotask = collectItem[3] d = {'total': total, 'done': done, 'todotask': todotask} socks.append(d) collectTimes = actChristmas.getCollectTimes(userId) rewardsInBag = actChristmas.getRewardCountInBag(userId) retInfo = { "errInfo": errInfo, "action": action, "isExchanged": collectTimes, "isInBag" : rewardsInBag, "socks" : socks, "tip" : actChristmas.tips } if ftlog.is_debug(): ftlog.debug('ActivityChristmasHandler.handleRequest userId=', userId, 'retInfo=', retInfo) return retInfo return {'code': -1, 'info': 'dizhu.ActivityChristmasHandler not inited'}
def getOnlineUserCountRate(clientId): gameId = strutil.getGameIdFromHallClientId(clientId) intClientidNum = pokerconf.clientIdToNumber(clientId) infos = configure.getGameJson(gameId, 'online.info', {}, intClientidNum) rate = infos.get('rate', None) if rate: return rate infos = configure.getGameJson(gameId, 'online.info', {}, 0) rate = infos.get('rate', None) if rate: return rate return 1
def getMoreGamesUpdateApks(clientId): try: gameId = strutil.getGameIdFromHallClientId(clientId) intClientId = pokerconf.clientIdToNumber(clientId) apks = configure.getGameTemplateInfo(gameId, 'more.games.apks', intClientId, None) if not apks: ftlog.error('ERROR, getMoreGamesUpdateApks clientId=', clientId) return apks except: ftlog.error('ERROR, getMoreGamesUpdateApks clientId=', clientId) return None
def getNeiTuiGuangConf(clientId): templates = configure.getGameJson(HALL_GAMEID, 'neituiguang', {}, configure.DEFAULT_CLIENT_ID).get('templates', {}) intClientId = pokerconf.clientIdToNumber(clientId) templateName = configure.getGameJson(HALL_GAMEID, 'neituiguang', {}, intClientId).get('template', '') if templateName: return templates.get(templateName, {}) else: _, clientVer, _ = strutil.parseClientId(clientId) if clientVer >= 3.372: return templates.get('default_neituiguang_new', {}) else: return templates.get('default_neituiguang_3_37', {})
def getRoomWinLosePayInfo(bigRoomId, clientId): intClientId = pokerconf.clientIdToNumber(clientId) info = configure.getGameTemplateInfo(DIZHU_GAMEID, 'room.pay', intClientId) if not info: systype, _, _ = strutil.parseClientId(clientId) defalut = 'default_android' if systype == strutil.CLIENT_SYS_IOS: defalut = 'default_ios' templates = configure.getGameTemplates(DIZHU_GAMEID, 'room.pay') info = templates.get(defalut) if info: return info.get(str(bigRoomId)) return None
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 getMoreGames(clientId): gameId = strutil.getGameIdFromHallClientId(clientId) intClientId = pokerconf.clientIdToNumber(clientId) templates = configure.getGameTemplates(HALL_GAMEID, 'more.games', _adjustMoreGameTemplates) template = configure.getGameJson(gameId, 'more.games', {}, intClientId) template = template.get('template', 'default') info = templates.get(template) ftlog.debug('hallconf.getMoreGames clientId=', clientId, 'gameId=', gameId, 'intClientId=', intClientId, 'template=', template, 'info=', info) if info: return info return templates.get('default')
def makeBeforeActivityTodoTasks(gameId, userId, clientId): try: intClientId = pokerconf.clientIdToNumber(clientId) enable = pkconfigure.getGameJson(gameId, 'pop.activity', {}, intClientId).get('enable', 0) if not enable: return None msg = pkconfigure.getGameJson(gameId, 'pop.activity', {}, pkconfigure.DEFAULT_CLIENT_ID) if msg: return TodoTaskShowInfo(msg) except: ftlog.exception() return None
def doHelloTuyou(self): gameId = runhttp.getParamInt('gameId') clientId = runhttp.getParamStr('clientId', '') ftlog.debug('Hello->gameId=', gameId, 'clientId=', clientId) mo = MsgPack() mo.setCmd('hello') if gameId not in gdata.gameIds(): mo.setError(1, 'gameId error !') ftlog.error('doHelloTuyou gameId error', runhttp.getDict()) return mo try: clientIdInt = pokerconf.clientIdToNumber(clientId) except: clientIdInt = 0 ftlog.error() if clientIdInt <= 0: mo.setError(2, 'clientId error !') ftlog.error('doHelloTuyou clientId error', runhttp.getDict()) return mo nicaiCode = runhttp.getParamStr('nicaiCode', '') if not nicaiCode: mo.setError(3, 'nicai error !') ftlog.error('doHelloTuyou nicai error', runhttp.getDict()) return mo # 1. 生存你猜CODE HelloTuyou.getNiCaiCode(mo, nicaiCode) # 2. 取得更新信息 updateVersion = runhttp.getParamInt('updateVersion') alphaVersion = runhttp.getParamInt('alphaVersion', 0) HelloTuyou.getUpdataInfo(mo, gameId, clientId, updateVersion, alphaVersion) # 3. 静态配置文件的MD5和URL staticConf = hallconf.getUpgradeStaticConf() mo.updateResult(staticConf) # 4. 返回三方SDK的控制开关 HelloTuyou.getThirdSwitches(mo, clientId) # 设置其他返回值 mo.setResult('gameId', gameId) mo.setResult('clientId', clientId) return mo
def isSupportedClient(self, clientId): intClientId = pokerconf.clientIdToNumber(clientId) if intClientId == 0: if ftlog.is_debug(): ftlog.debug( 'PlayGameShare.isSupportedClient BadClientId clientId=', clientId, 'intClientId=', intClientId) return False conf = configure.getGameJson(DIZHU_GAMEID, 'share.playgame', {}, intClientId) if ftlog.is_debug(): ftlog.debug('PlayGameShare.isSupportedClient clientId=', clientId, 'intClientId=', intClientId, 'conf=', conf) return True if self.actId in conf.get('acts', []) else False
def getMoreGames(clientId): gameId = strutil.getGameIdFromHallClientId(clientId) intClientId = pokerconf.clientIdToNumber(clientId) templates = configure.getGameTemplates(HALL_GAMEID, 'more.games', _adjustMoreGameTemplates) template = configure.getGameJson(gameId, 'more.games', {}, intClientId) template = template.get('template', 'default') info = templates.get(template) ftlog.debug('hallconf.getMoreGames clientId=', clientId, 'gameId=', gameId, 'intClientId=', intClientId, 'template=', template, 'info=', info) if info: return info return templates.get('default')
def getTableQuickInfo(clientId): intClientId = pokerconf.clientIdToNumber(clientId) info = configure.getGameTemplateInfo(DIZHU_GAMEID, 'table.quickpay', intClientId) ftlog.debug('quickpay->', intClientId, info) if not info: systype, _, _ = strutil.parseClientId(clientId) defalut = 'default_android' if systype == strutil.CLIENT_SYS_IOS: defalut = 'default_ios' ftlog.debug('quickpay defalut->', defalut) templates = configure.getGameTemplates(DIZHU_GAMEID, 'table.quickpay') info = templates.get(defalut) ftlog.debug('quickpay info->', info) return info
def getNeiTuiGuangConf(clientId): templates = configure.getGameJson(HALL_GAMEID, 'neituiguang', {}, configure.DEFAULT_CLIENT_ID).get( 'templates', {}) intClientId = pokerconf.clientIdToNumber(clientId) templateName = configure.getGameJson(HALL_GAMEID, 'neituiguang', {}, intClientId).get('template', '') if templateName: return templates.get(templateName, {}) else: _, clientVer, _ = strutil.parseClientId(clientId) if clientVer >= 3.372: return templates.get('default_neituiguang_new', {}) else: return templates.get('default_neituiguang_3_37', {})
def handleTaskFinishEvent(cls, event): ftlog.debug('handleTaskFinishEvent', event.task.__dict__) userId = event.userId gameId = event.gameId clientId = sessiondata.getClientId(userId) clientIdNum = pokerconf.clientIdToNumber(clientId) if clientIdNum != YOUKU_CLIENTID_NUM: return if event.task.taskUnitId != 'ddz.task.daily': return datas = cls._checkYoukuData(userId, gameId) datas_youku = datas.get('h5youku') finish_task_count = int(datas_youku.get('finish_task_count', 0)) finish_task_count += 1 datas_youku['finish_task_count'] = finish_task_count day1st.setDay1stDatas(userId, gameId, datas)
def doGameUpdateInfo(self): gameId = runhttp.getParamInt('gameId') clientId = runhttp.getParamStr('clientId', '') version = runhttp.getParamStr('version', '') updateVersion = runhttp.getParamInt('updateVersion', -1) ftlog.debug('http gameupdateinfo IN->gameId=', gameId, 'clientId=', clientId, 'version=', version, 'updateVersion=', updateVersion) mo = MsgPack() mo.setCmd('gameupdateinfo') if gameId not in gdata.gameIds(): mo.setError(1, 'gameId error !') return mo clientIdInt = pokerconf.clientIdToNumber(clientId) if clientIdInt <= 0: mo.setError(2, 'clientId error !') return mo if not version: mo.setError(3, 'version error !') return mo if updateVersion < 0: mo.setError(4, 'updateVersion error !') return mo updates = hall_game_update.getUpdateInfo2(gameId, version, updateVersion) ftlog.debug('http gameupdateinfo OUT->updates=', updates) mo.setResult('gameId', gameId) mo.setResult('clientId', clientId) mo.setResult('version', version) mo.setResult('updateVersion', updateVersion) mo.setResult('updates', updates) return mo
def getPopActivityTemplate(clientId): intClientId = pokerconf.clientIdToNumber(clientId) # 查看是否关闭了活动弹框 clientConf = configure.getGameJson(DIZHU_GAMEID, 'pop.activity', {}, intClientId) closed = clientConf.get('closed', 0) if closed: return None templateName = clientConf.get('template', 'default') templateMap = configure.getGameJson( DIZHU_GAMEID, 'pop.activity', {}, configure.DEFAULT_CLIENT_ID).get('templates') if ftlog.is_debug(): ftlog.debug('dizhuconf.getPopActivityTemplate clientId=', clientId, 'templateNames=', templateMap.keys() if templateMap else None) if not templateMap: return None return templateMap.get(templateName)
def doHelloTuyou(self): gameId = runhttp.getParamInt('gameId') clientId = runhttp.getParamStr('clientId', '') ftlog.debug('Hello->gameId=', gameId, 'clientId=', clientId) mo = MsgPack() mo.setCmd('hello') if gameId not in gdata.gameIds(): mo.setError(1, 'gameId error !') return mo clientIdInt = pokerconf.clientIdToNumber(clientId) if clientIdInt <= 0: mo.setError(2, 'clientId error !') return mo nicaiCode = runhttp.getParamStr('nicaiCode', '') if not nicaiCode: mo.setError(3, 'nicai error !') return mo # 1. 生存你猜CODE HelloTuyou.getNiCaiCode(mo, nicaiCode) # 2. 取得更新信息 updateVersion = runhttp.getParamInt('updateVersion') alphaVersion = runhttp.getParamInt('alphaVersion', 0) HelloTuyou.getUpdataInfo(mo, gameId, clientId, updateVersion, alphaVersion) # 3. 静态配置文件的MD5和URL staticConf = hallconf.getUpgradeStaticConf() mo.updateResult(staticConf) # 4. 返回三方SDK的控制开关 HelloTuyou.getThirdSwitches(mo, clientId) # 设置其他返回值 mo.setResult('gameId', gameId) mo.setResult('clientId', clientId) return mo
def queryFirstRecharge(gameId, userId, clientId): ''' @return: 首冲礼包道具ID 默认值:ITEM_FIRST_RECHARGE_GIFT_KIND_ID ''' # 首先查clientId对应的配置 intClientId = pokerconf.clientIdToNumber(clientId) strClientId = str(intClientId) if strClientId in _firstRechageVC: itemId = _firstRechageVC.get(strClientId, None) if itemId: if ftlog.is_debug(): ftlog.debug('hall_first_recharge.queryFirstRecharge clientId:', clientId, ' unique itemId:', itemId) return itemId # 再查gameId对应的配置 gId = strutil.getGameIdFromHallClientId(clientId) strId = str(gId) itemId = _firstRechage.get(strId, hallitem.ITEM_FIRST_RECHARGE_GIFT_KIND_ID) return itemId
def queryFirstRecharge(gameId, userId, clientId): ''' @return: 首冲礼包道具ID 默认值:ITEM_FIRST_RECHARGE_GIFT_KIND_ID ''' # 首先查clientId对应的配置 intClientId = pokerconf.clientIdToNumber(clientId) strClientId = str(intClientId) if strClientId in _firstRechageVC: itemId = _firstRechageVC.get(strClientId, None) if itemId: if ftlog.is_debug(): ftlog.debug('hall_first_recharge.queryFirstRecharge clientId:', clientId, ' unique itemId:', itemId) return itemId # 再查gameId对应的配置 gId = strutil.getGameIdFromHallClientId(clientId) strId = str(gId) itemId = _firstRechage.get(strId, hallitem.ITEM_FIRST_RECHARGE_GIFT_KIND_ID) return itemId
def handleRequest(self, msg): userId = msg.getParam('userId') action = msg.getParam("action") clientId = msg.getParam('clientId') activityType = msg.getParam('type') intClientId = pokerconf.clientIdToNumber(clientId) actIdList = getActIdList() actId = '' for actConf in actIdList: intClientIdList = actConf.get('clientIds') if intClientId in intClientIdList: actId = actConf.get('actId') break if ftlog.is_debug(): ftlog.debug('ActivityScoreRankingHandler.handleRequest', 'userId=', userId, 'action=', action, 'clientId=', clientId, 'intClientId=', intClientId, 'activityType=', activityType, 'actId=', actId, 'msg=', msg) if actId: from dizhu.activitynew import activitysystemnew scoreActivity = activitysystemnew.findActivity(actId) if scoreActivity: if self.ACTION_GET_REWARD_INFO == action: return self.getRewardInfo(userId, scoreActivity) elif self.ACTION_GAIN_REWARD == action: return self.gainReward(userId, scoreActivity) elif self.ACTION_GET_USER_ITEM_INFO == action: return self.getUserItemInfo(userId, scoreActivity) or { 'code': -1, 'info': 'activity not inited' } clientId = clientId or sessiondata.getClientId(userId) return self.getRankInfo(userId, clientId, scoreActivity, activityType) return {'code': -1, 'info': 'activity not inited'}
def checkUserData(userId, clientId=None, appId=0): ''' 检查当前用户的数据是否是热数据(即存储在REDIS), 如果不是热数据, 那么重MYSQL中读取冷数据导入至热数据中 同时更新当前用户的数据生命时间 导入导出的用户数据包括user和个个游戏的所有数据 返回: 如果用户数据的最终状态为热数据,返回1 如果用户数据不存在,返回0 ''' ftlog.debug('MySqlSwap checkUserData->userId=', userId, 'clientId=', clientId, 'appId=', appId) userId = int(userId) ctfull = timestamp.formatTimeMs() isok = daobase.executeUserLua(userId, dataswap_scripts.CHECK_USER_DATA_LUA_SCRIPT, 2, userId, ctfull) ftlog.debug('MySqlSwap checkUserData->userId=', userId, 'clientId=', clientId, 'appId=', appId, 'isok=', isok) if isok == 1: return 1 if clientId: intClientId = pokerconf.clientIdToNumber(clientId) else: intClientId = configure.DEFAULT_CLIENT_ID appId = int(appId) return _tryReadDataFromMySql(userId, intClientId, appId, ctfull)
def getClientCustomSkinsConf(clientId): intClientId = pokerconf.clientIdToNumber(clientId) if intClientId == 0: return {} return configure.getGameJson(HALL_GAMEID, 'customskins', {}, intClientId)
def getHallSessionInfo(gameId, clientId): if not gameId or gameId == HALL_GAMEID: gameId = strutil.getGameIdFromHallClientId(clientId) intClientId = pokerconf.clientIdToNumber(clientId) return configure.getGameTemplateInfo(gameId, 'hall.info', intClientId, _adjustHallSessionInfo)
def getClientLotteryConf(clientId): intClientId = pokerconf.clientIdToNumber(clientId) if intClientId == 0: return {} return configure.getGameJson(HALL_GAMEID, 'lottery', {}, intClientId)
def getFiveStarClientConf(clientId): intClientId = pokerconf.clientIdToNumber(clientId) if intClientId == 0: return {} return configure.getGameJson(HALL_GAMEID, 'fivestar', {}, intClientId)
def getClientRenameConf(clientId): intClientId = pokerconf.clientIdToNumber(clientId) if intClientId == 0: return {} return configure.getGameJson(HALL_GAMEID, 'rename', {}, intClientId)
def getClientItemConf(clientId): intClientId = pokerconf.clientIdToNumber(clientId) if intClientId == 0: return None return configure.getGameJson(HALL_GAMEID, 'item', {}, intClientId)
def getMonthDailyCheckinConf(clientId): intClientId = pokerconf.clientIdToNumber(clientId) if intClientId == 0: return {} return configure.getGameJson(HALL_GAMEID, 'monthcheckin', {}, intClientId)
def getShareUrl(gameId, clientId): intClientId = pokerconf.clientIdToNumber(clientId) return configure.getGameTemplateInfo(gameId, 'share.url', intClientId)
def _parseClientIdNum(clientId): if isinstance(clientId, (str, unicode)): return pokerconf.clientIdToNumber(clientId) elif isinstance(clientId, (int, float)): return int(clientId) return 0