def _onChargeNotify(self, event): if ftlog.is_debug(): ftlog.debug('ChargeSendPresentNum._onChargeNotify gameId=', event.gameId, 'userId=', event.userId, 'clientId=', event.clientId, 'presentNumActId=', self._presentNumActId, 'rmbs=', event.rmbs, 'productId=', event.productId, 'hallGameIds=', self._hallGameIds) hallGameId = strutil.getGameIdFromHallClientId(event.clientId) if hallGameId not in self._hallGameIds: if ftlog.is_debug(): ftlog.debug('ChargeSendPresentNum._onChargeNotify gameId=', event.gameId, 'userId=', event.userId, 'presentNumActId=', self._presentNumActId, 'clientId=', event.clientId, 'rmbs=', event.rmbs, 'productId=', event.productId, 'hallGameIds=', self._hallGameIds) return sendPresentNum = int(self._rate * event.rmbs) if sendPresentNum > 0: actObj = self._findActObj(event.gameId, event.userId, event.clientId) if actObj: actObj.addPresentNum(HALL_GAMEID, event.userId, event.clientId, sendPresentNum) ftlog.debug('ChargeSendPresentNum._onChargeNotify gameId=', event.gameId, 'userId=', event.userId, 'presentNumActId=', self._presentNumActId, 'clientId=', event.clientId, 'rmbs=', event.rmbs, 'productId=', event.productId, 'rate=', self._rate, 'sendPresentNum=', sendPresentNum)
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 addUserItemByKindId(cls, userId, gameId, clientId, kindId, count): timestamp = pktimestamp.getCurrentTimestamp() userAssets = hallitem.itemSystem.loadUserAssets(userId) calcGameId = strutil.getGameIdFromHallClientId(clientId) userAssets.addAsset(calcGameId, kindId, count, timestamp, 'MAJIANG_FANGKA_INVITE_REWARD', 0) datachangenotify.sendDataChangeNotify(gameId, userId, 'item') ftlog.debug('addUserItemByKindId userId:', userId, ' gameId:', gameId, 'kindId', kindId, 'count', count)
def onOrderDelivery(cls, event): ok = cls.checkActivityDate() if not ok: if ftlog.is_debug(): ftlog.debug('ActivityDdzFund.onOrderDelivery OutDate userId=', event.userId, 'clientId=', event.orderDeliveryResult.order.clientId, 'productId=', event.orderDeliveryResult.order.productId) return if event.orderDeliveryResult.order.productId not in cls.conf.productIds: return hallGameId = strutil.getGameIdFromHallClientId(event.orderDeliveryResult.order.clientId) if cls.conf.hallGameIds and hallGameId not in cls.conf.hallGameIds: if ftlog.is_debug(): ftlog.debug('ActivityDdzFund.onOrderDelivery OutHallGameId userId=', event.userId, 'clientId=', event.orderDeliveryResult.order.clientId, 'productId=', event.orderDeliveryResult.order.productId, 'hallGameId=', hallGameId, 'hallGameIds=', cls.conf.hallGameIds) return status = cls.loadFundStatus(event.userId, event.timestamp) if not status.isActivated: status.isActivated = 1 status.updateTime = event.timestamp ftlog.info('ActivityDdzFund.onOrderDelivery SetActivated userId=', event.userId, 'productId=', event.orderDeliveryResult.order.productId, 'status=', status.__dict__) cls.saveFundStatus(status)
def addUserItemByKindId(cls, userId, gameId, clientId, kindId, count): timestamp = pktimestamp.getCurrentTimestamp() userAssets = hallitem.itemSystem.loadUserAssets(userId) calcGameId = strutil.getGameIdFromHallClientId(clientId) userAssets.addAsset(calcGameId, kindId, count, timestamp, 'MAJIANG_FANGKA_INVITE_REWARD', pokerconf.clientIdToNumber(clientId)) datachangenotify.sendDataChangeNotify(gameId, userId, 'item') ftlog.debug('addUserItemByKindId userId:', userId, ' gameId:', gameId, 'kindId', kindId, 'count', count)
def handle_event(self, event): if not self.act.checkOperative(): return if not isinstance(event, GameOverEvent): return if self.play_result is not None and self.play_result != event.gameResult: return # 历史原因,很多插件都写成9999了,尽量纠正一把 gameid = event.gameId if event.gameId != HALL_GAMEID else strutil.getGameIdFromHallClientId( event.clientId) if gameid != self.gameid: return bigRoomId = gdata.getBigRoomId(event.roomId) bigroom = bigRoomId if bigRoomId else event.roomId credit = self.room2credit.get(str(bigroom), 0) if ftlog.is_debug(): ftlog.debug('CreditSourceGamePlay.handle_event userId=', event.userId, 'gameId=', gameid, 'self.gameId=', self.gameid, 'bigroom=', bigroom, 'credit=', credit, 'event.roomId=', event.roomId, 'room2credit', self.room2credit) if credit <= 0: return self._add_credit(event.userId, credit, event.roundNum)
def _onOrderDelivery(self, event): if ftlog.is_debug(): ftlog.debug('BuySendPrize._onOrderDelivery gameId=', event.gameId, 'userId=', event.userId, 'clientId=', event.orderDeliveryResult.order.clientId, 'productId=', event.orderDeliveryResult.order.productId, 'hallGameIds=', self._hallGameIds) hallGameId = strutil.getGameIdFromHallClientId( event.orderDeliveryResult.order.clientId) if (not self._hallGameIds or hallGameId in self._hallGameIds) and self.checkTime(event.timestamp) == 0: product, content = self.findPrize( event.gameId, event.userId, event.orderDeliveryResult.order.clientId, event.orderDeliveryResult.order.productId) if ftlog.is_debug(): ftlog.debug('BuySendPrize._onOrderDelivery gameId=', event.gameId, 'userId=', event.userId, 'productId=', event.orderDeliveryResult.order.productId, 'hallGameIds=', self._hallGameIds, 'prize=', (product, content)) if product and product.buyType != TYProductBuyType.BUY_TYPE_CHARGE: self._sendPrizeIfNeed(DIZHU_GAMEID, event.userId, event.orderDeliveryResult.order.clientId, product, content, event.timestamp)
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 onUserLogin(cls, event): ftlog.debug("SkillLevelGift.onUserLogin: event=", event) # gameId = 6 userId = event.userId clientId = sessiondata.getClientId(userId) gameId = strutil.getGameIdFromHallClientId(clientId) ddzconf = cls.getDdzActivityConf() mapkey = "SkillLevelGift" + ddzconf.get("start", "") if gameId != DIZHU_GAMEID: return toggle = ddzconf.get("toggle", False) ftlog.debug("SkillLevelGift.onUserLogin: userId=", userId, "open_toggle=", toggle) if not toggle: return isFirst = Redis.isFirst(userId, mapkey) ftlog.debug("SkillLevelGift.onUserLogin: userId=", userId, "isFirst=", isFirst) if not isFirst: return # 发放道具 mail = ddzconf.get("mail", "") assets = ddzconf.get("assets") UserBag.sendAssetsToUser(gameId, userId, assets, 'DDZ_ATC_SKILLLEVEL_GIFT', mail) ftlog.debug("SkillLevelGift.onUserLogin: userId=", userId, "send assets=", assets, "mail=", mail)
def sendShareForWXRedEnvelope(userId, record, item): try: action = item.itemKind.findActionByName('exchange') from hall.entity.hallitem import TYItemActionExchange if isinstance( action, TYItemActionExchange) and action.isWechatRedPack(): # 微信红包 from poker.util import strutil from poker.entity.dao import sessiondata clientId = sessiondata.getClientId(userId) _, cVer, _ = strutil.parseClientId(clientId) if cVer >= 3.90: from hall.entity import hallshare gameId = strutil.getGameIdFromHallClientId(clientId) shareId = hallshare.getShareId('wxRedEnvelope', userId, gameId) share = hallshare.findShare(shareId) if share: todotask = share.buildTodotask(HALL_GAMEID, userId, 'wxRedEnvelope') if todotask: from hall.entity.todotask import TodoTaskHelper TodoTaskHelper.sendTodoTask(gameId, userId, todotask) except: ftlog.error('sendShareForWXRedEnvelope', 'userId=', userId, 'exchangeId=', record.exchangeId, 'itemId=', item.itemId, 'itemKindId=', item.kindId)
def onChargeNotify(cls, event): ''' 充值监听,监听并更新排行和redis记录的RMB,过期不会监听 ''' userId = event.userId ftlog.debug("DumplingHandler.onChargeNotify: " "userId=", userId, "isOutdate=", DumplingsUtil.isOutdate()) if DumplingsUtil.isOutdate(): return clientGameId = strutil.getGameIdFromHallClientId(event.clientId) if clientGameId not in [6, 7]: return DumplingsUtil.updateRankingStatus(userId) # 若排行榜重置,则重置积分记录 rediskey = DumplingsUtil.getRedisKey() jsondict = Redis.readJson(userId, rediskey) rmb_count = 0 if jsondict: rmb_count = jsondict.get("rmb", 0) rmb_count = rmb_count + (event.rmbs or 0) jsondict['rmb'] = rmb_count Redis.writeJson(userId, rediskey, jsondict) DumplingsUtil.updateRankScore(userId, event.timestamp) ftlog.debug("DumplingHandler.onChargeNotify: userId=", userId, "event=", event, "jsondict=", jsondict)
def enterpopwnd(userId, gameId, clientId, loginsum, isdayfirst, daylogin): ftlog.info("newstartflow|enterpopwnd1", userId, gameId, clientId, loginsum, isdayfirst, daylogin) package_gameId = strutil.getGameIdFromHallClientId(clientId) if isdayfirst: initNPWredis(userId) datas = actualTcContent(clientId, package_gameId) if len(datas) == 0: ftlog.info("newstartflow|package_gameId|noTc.json", userId, gameId, package_gameId) return popwndBaseData = getpopwndBaseData() npwsList = [] for data in datas['list']: npwId = data['npwId'] if npwId in popwndBaseData: npwsList.append((popwndBaseData[npwId], data)) else: ftlog.info("npwId[%s] not in newstartflow" % npwId) npwsList.sort(key=lambda d: d[0]['sortId']) for npws_data in npwsList: dispatcher(userId, gameId, clientId, loginsum, isdayfirst, daylogin, npws_data) # ftlog.info("npws_data", userId, gameId, clientId, loginsum, isdayfirst, daylogin) ftlog.info("newstartflow|enterpopwnd2", userId, gameId, clientId, package_gameId, npwsList)
def getVcTemplate(moduleKey, clientId, gameId=None): """ http://192.168.10.93:8090/pages/viewpage.action?pageId=1868148 """ if isinstance(clientId, int): strClientId = numberToClientId(clientId) numClientId = clientIdToNumber(strClientId) else: numClientId = clientIdToNumber(clientId) strClientId = numberToClientId(numClientId) assert (numClientId > 0), 'the clientId int value error, input=' + str(clientId) + ' convert=' + str( numClientId) + ' ' + str(strClientId) assert (strClientId != ''), 'the clientId str value error, input=' + str(clientId) + ' convert=' + str( numClientId) + ' ' + str(strClientId) if not gameId: gameId = strutil.getGameIdFromHallClientId(strClientId) assert (gameId > 0), 'the gameId error, input=' + str(strClientId) + ' convert=' + str(gameId) + ' ' + str( numClientId) + ' ' + str(strClientId) xkey = 'game:' + str(gameId) + ':' + moduleKey + ':' + CLIENT_ID_MATCHER datas = _get(xkey, {}) if not '_cache' in datas: strutil.replaceObjRefValue(datas) datas['_cache'] = {} _cache = datas['_cache'] tname = _cache.get(numClientId, None) if tname == None: # 先判定1:1真实映射 actual = datas.get('actual', {}) tname = actual.get(strClientId, None) if tname == None: tname = actual.get(str(numClientId), None) # 第二优先级判定主次渠道,主次渠道可覆盖大部分的批量配置需求,比正则表达式配置难度低 if tname == None: channel = strutil.getChannelFromHallClientId(clientId) tname = actual.get(channel, None) # 再判定正则表达式映射 if tname == None: for vm in datas.get('virtual', []): if strutil.regMatch(vm[0], strClientId): tname = vm[1] break # 最后取缺省值 if tname == None: clientSys, _, _ = strutil.parseClientId(strClientId) tname = datas.get('default_' + str(clientSys).lower(), None) # 最后取缺省值 if tname == None: tname = datas.get('default', None) if tname == None: ftlog.warn('the clientId can not find template name ' + str(moduleKey) + ' ' + str( numClientId) + ' ' + strClientId) _cache[numClientId] = tname return tname
def gameCheck(cls, userId, gameId): userGameId = strutil.getGameIdFromHallClientId( sessiondata.getClientId(userId)) ftlog.debug('dashisend gameId=', gameId, 'userGameId=', userGameId) if userGameId != gameId: return False else: return True
def isSendModuleTip(self, gameId, userId, clientId): if clientId and gameId and userId: _, clientVer, _ = strutil.parseClientId(clientId) if clientVer >= 3.9: listConfig = self._dao.getActivitiesForClient(clientId) gId = strutil.getGameIdFromHallClientId(clientId) if listConfig: for actName in listConfig: self.getActState(userId, gId, actName)
def _checkInNotSendGameIds(self, userId): ''' 检查无需发放救济金的游戏id ''' clientId = sessiondata.getClientId(userId) gameId = strutil.getGameIdFromHallClientId(clientId) if gameId in self._notSendGameIds: return True return False
def queryLocalNotification(gameId, userId, clientId): ''' @return: TYLocalNotification array ''' global _lnConfig game = strutil.getGameIdFromHallClientId(clientId) ftlog.debug('halllocalnotification.queryLocalNotification game=', game, 'userId=', userId, 'clientId=', clientId, 'local_notification=', _lnConfig) return _lnConfig.get(str(game), [])
def doSendLedToUser(userId): global _ledClosesConf gameIdList = onlinedata.getGameEnterIds(userId) lastGameId = onlinedata.getLastGameId(userId) if not HALL_GAMEID in gameIdList: gameIdList.append(HALL_GAMEID) if not lastGameId in gameIdList: gameIdList.append(lastGameId) clientId = sessiondata.getClientId(userId) gameIdInClientId = strutil.getGameIdFromHallClientId(clientId) if not gameIdInClientId in gameIdList: gameIdList.append(gameIdInClientId) if ftlog.is_debug(): ftlog.debug('hallled.doSendLedToUser userId=', userId, 'gameIdList=', gameIdList, 'clientId=', clientId, 'gameIdInClientId=', gameIdInClientId, 'lastGameId=', lastGameId) _, clientVer, _ = strutil.parseClientId(clientId) for gameId in gameIdList: try: leds = getLedMsgList(gameId) if ftlog.is_debug(): ftlog.debug('hallled.doSendLedToUser gameId=', gameId, 'userId=', userId, 'clientId=', clientId, 'leds=', leds) if leds: for led in leds: if canSendToUser(userId, clientId, led): msgDict = led[2] if clientVer >= 3.6: mo = MsgPack() mo.setCmd('led') for k, v in msgDict.iteritems(): mo.setResult(k, v) mo.setResult('scope', led[3]) else: mo = MsgPack() mo.setCmd('led') if gameId in (1, 8): msgDictV2 = translateToMsgDictV2(msgDict) if msgDictV2: mo.setKey('richText', msgDictV2.get('richText')) msgV1 = translateToMsgDictV1(msgDict) if msgV1: gameId = msgDict.get('gameId', led[1]) mo.setKey('result', [[led[0], gameId, msgV1]]) router.sendToUser(mo, userId) except: ftlog.error("error leds:", leds)
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 needSendGameList(self, userId, gameId, clientId, isdayfirst): from poker.util import strutil from hall.entity import hallconf from hall.entity.hallconf import HALL_GAMEID from datetime import datetime if not isdayfirst or gameId != HALL_GAMEID: if ftlog.is_debug(): ftlog.debug('UtilHelper.needSendGameList NotDayFirstOrHallGameId', 'userId=', userId, 'gameId=', gameId, 'clientId=', clientId, 'isdayfirst=', isdayfirst) return False autoSendGameList = hallconf.getPublicConf('autoSendGameList', {}) if autoSendGameList.get('close', 0): if ftlog.is_debug(): ftlog.debug('UtilHelper.needSendGameList Closed', 'userId=', userId, 'gameId=', gameId, 'clientId=', clientId, 'isdayfirst=', isdayfirst) return False games = autoSendGameList.get('games', []) if not games: if ftlog.is_debug(): ftlog.debug('UtilHelper.needSendGameList NotConfGames', 'userId=', userId, 'gameId=', gameId, 'clientId=', clientId, 'isdayfirst=', isdayfirst) return False nowT = datetime.now() hallGameId = strutil.getGameIdFromHallClientId(clientId) for gameConf in games: if gameConf.get('gameId') == hallGameId: timeRange = gameConf.get('timeRange') if not timeRange: return True sTime = datetime.strptime(timeRange[0], '%Y-%m-%d %H:%M:%S') eTime = datetime.strptime(timeRange[1], '%Y-%m-%d %H:%M:%S') if nowT >= sTime and nowT < eTime: return True if ftlog.is_debug(): ftlog.debug('UtilHelper.needSendGameList NotInTimeRange', 'userId=', userId, 'gameId=', gameId, 'clientId=', clientId, 'isdayfirst=', isdayfirst, 'timeRange=', timeRange) return False if ftlog.is_debug(): ftlog.debug('UtilHelper.needSendGameList NotInGames', 'userId=', userId, 'gameId=', gameId, 'clientId=', clientId, 'isdayfirst=', isdayfirst, 'timeRange=', timeRange) return False
def isGameDdz(cls, userId): ''' 检测是否为地主大厅 ''' user_gameid = strutil.getGameIdFromHallClientId( sessiondata.getClientId(userId)) ftlog.debug('Tool.isGameDdz: userId=', userId, 'gameId=', 6, 'user_gameid=', user_gameid) if user_gameid != 6: return False return True
def getTcTemplatesByClientId(moduleKey, funDecode, clientId): ''' 取得配置系统的一个游戏相关的键值的json对象值(list或dict类型) ''' if isinstance(clientId, int): strClientId = numberToClientId(clientId) else: numClientId = clientIdToNumber(clientId) strClientId = numberToClientId(numClientId) gameId = strutil.getGameIdFromHallClientId(strClientId) return getTcTemplatesByGameId(moduleKey, funDecode, gameId)
def getNoticeRewardData(userId, gameId, clientId): package_gameId = strutil.getGameIdFromHallClientId(clientId) datas = actualTcContent(clientId, package_gameId) if len(datas) == 0: ftlog.warn("getNoticeRewardData|newstartflow|package_gameId|noTc.json", userId, gameId, package_gameId) return for data in datas['list']: if "notice" == data['npwId']: return data
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 getTcTemplatesByClientId(moduleKey, funDecode, clientId): ''' 取得配置系统的一个游戏相关的键值的json对象值(list或dict类型) ''' if isinstance(clientId, int): strClientId = numberToClientId(clientId) numClientId = clientIdToNumber(strClientId) else: numClientId = clientIdToNumber(clientId) strClientId = numberToClientId(numClientId) gameId = strutil.getGameIdFromHallClientId(strClientId) return getTcTemplatesByGameId(moduleKey, funDecode, gameId)
def _handleTableWinlose(self, event): clientId = sessiondata.getClientId(event.userId) # 检查这个clientId是否配置了本活动 if not self.isSupportedClient(clientId): if ftlog.is_debug(): ftlog.debug( 'PlayGameTodotask._handleTableWinlose NotSupportedClientId gameId=', event.gameId, 'userId=', event.userId, 'clientId=', clientId, 'actId=', self.actId, 'hallGameIds=', self._hallGameIds) return hallGameId = strutil.getGameIdFromHallClientId(clientId) if hallGameId not in self._hallGameIds: if ftlog.is_debug(): ftlog.debug( 'PlayGameTodotask._handleTableWinlose NotSupportedHallGameId gameId=', event.gameId, 'userId=', event.userId, 'clientId=', clientId, 'actId=', self.actId, 'hallGameIds=', self._hallGameIds) return if not self._condition.check(event.gameId, event.userId, clientId, event.timestamp): if ftlog.is_debug(): ftlog.debug( 'PlayGameTodotask._handleTableWinlose CheckCond gameId=', event.gameId, 'userId=', event.userId, 'clientId=', clientId, 'actId=', self.actId, 'hallGameIds=', self._hallGameIds) return status = self.loadStatus(event.userId, event.timestamp) status.playRound += 1 status.lastUpdateTime = event.timestamp self.saveStatus(status) todotaskFac = self._findTodotaskByPlayRound(status.playRound) if todotaskFac: todotask = todotaskFac.newTodoTask(event.gameId, event.userId, clientId) if not todotask: ftlog.warn( 'PlayGameTodotask._handleTableWinlose CreateTodotask gameId=', event.gameId, 'userId=', event.userId, 'clientId=', clientId, 'actId=', self.actId, 'hallGameIds=', self._hallGameIds, 'playRound=', status.playRound, 'todotaskFac=', todotaskFac) return TodoTaskHelper.sendTodoTask(event.gameId, event.userId, todotask)
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 handleEvent(cls, event): clientId = sessiondata.getClientId(event.userId) hallGameId = strutil.getGameIdFromHallClientId(clientId) if hallGameId != DIZHU_GAMEID: return actObj = cls._findActObj(event.gameId, event.userId, clientId) if actObj: actObj.addPresentNum(HALL_GAMEID, event.userId, clientId, cls.presentNum) ftlog.info('MonthCheckinGiftNum.handleEvent gameId=', event.gameId, 'userId=', event.userId, 'presentNumActId=', cls.activityId, 'clientId=', clientId, 'sendPresentNum=', cls.presentNum)
def getTcContent(moduleKey, funDecode, clientId): if isinstance(clientId, int): strClientId = numberToClientId(clientId) else: numClientId = clientIdToNumber(clientId) strClientId = numberToClientId(numClientId) gameId = strutil.getGameIdFromHallClientId(strClientId) moduleKey = str(gameId) + ':' + str(moduleKey) templates = getTcTemplates(moduleKey, funDecode) tname = getVcTemplate(moduleKey, clientId) try: return templates[tname] except: ftlog.error('getTcContent', moduleKey, funDecode, clientId) return None
def handle_event(self, event): if not self.act.checkOperative(): return if not isinstance(event, GameOverEvent): return if self.play_result is not None and self.play_result != event.gameResult: return # 历史原因,很多插件都写成9999了,尽量纠正一把 gameid = event.gameId if event.gameId != HALL_GAMEID else strutil.getGameIdFromHallClientId(event.clientId) if gameid != self.gameid: return bigroom = gdata.getBigRoomId(event.roomId) credit = self.room2credit.get(str(bigroom), 0) if credit <= 0: return self._add_credit(event.userId, credit, event.roundNum)
def onUserVipLevelUp(self, event): if ftlog.is_debug(): ftlog.debug('VipHandlerImpl.onUserVipLevelUp userId=', event.userId, 'gameId=', event.gameId, 'oldLevel=', event.oldVipLevel.level, 'newLevel=', event.userVip.vipLevel.level) todotask = TodoTaskVipLevelUp( VipHelper.buildVipInfo(event.userVip), self.buildVipLevelUpDesc(event.userId, event.oldVipLevel, event.userVip)) userGameId = strutil.getGameIdFromHallClientId( sessiondata.getClientId(event.userId)) if userGameId in hallvip.vipSystem.getLevelUpErrorGameIds(): msg = "恭喜您升级为VIP %s!" % event.userVip.vipLevel.level todotask = TodoTaskShowInfo(msg, True) TodoTaskHelper.sendTodoTask(event.gameId, event.userId, todotask)
def getTcContent(moduleKey, funDecode, clientId): if isinstance(clientId, int): strClientId = numberToClientId(clientId) numClientId = clientIdToNumber(strClientId) else: numClientId = clientIdToNumber(clientId) strClientId = numberToClientId(numClientId) gameId = strutil.getGameIdFromHallClientId(strClientId) moduleKey = str(gameId) + ':' + str(moduleKey) templates = getTcTemplates(moduleKey, funDecode) tname = getVcTemplate(moduleKey, clientId) try: return templates[tname] except: ftlog.error('getTcContent', moduleKey, funDecode, clientId) return None
def check(self, task, event): ''' 判断是否符合条件 @return: True/False ''' from poker.entity.dao import sessiondata clientId = event.clientId if not clientId: clientId = sessiondata.getClientId(task.userId) clientGameId = strutil.getGameIdFromHallClientId(clientId) if ftlog.is_debug(): ftlog.debug('TYTaskConditionIsMyGameIdClient.check' 'userId=', task.userId, 'clientId=', clientId, 'clientGameId=', clientGameId, 'myGameId=', self.myGameId) return clientGameId == self.myGameId
def handle_event(self, event): if not self.act.checkOperative(): return if not isinstance(event, GameOverEvent): return if self.play_result is not None and self.play_result != event.gameResult: return # 历史原因,很多插件都写成9999了,尽量纠正一把 gameid = event.gameId if event.gameId != HALL_GAMEID else strutil.getGameIdFromHallClientId( event.clientId) if gameid != self.gameid: return bigroom = gdata.getBigRoomId(event.roomId) credit = self.room2credit.get(str(bigroom), 0) if credit <= 0: return self._add_credit(event.userId, credit, event.roundNum)
def getAllLabelConf(clientId): conf = getConf() childGameId = strutil.getGameIdFromHallClientId(clientId) checkinClickLabel = conf.get('checkinClickLabel', {}) checkinNormalLabel = conf.get('checkinNormalLabel', {}) specailDayLabel = conf.get('specailDayLabel', {}) ftlog.debug('getAllLabelConf.childGameId=', childGameId, 'checkinClickLabel=', checkinClickLabel, 'checkinNormalLabel=', checkinNormalLabel, 'specailDayLabel=', specailDayLabel) childNormal = checkinNormalLabel.get(str(childGameId), {}) childClick = checkinClickLabel.get(str(childGameId), {}) childSpecail = specailDayLabel.get(str(childGameId), {}) ftlog.debug('getAllLabelConf.childNormal=', childNormal, 'childClick=', childClick, 'childSpecail=', childSpecail) return {'childNormal': childNormal, 'childClick': childClick, 'childSpecail': childSpecail}
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 getClientModuleDefaultConf(clientId, moduleName): ''' @return: 默认配置 如果没有 返回None ''' # 提取版本号 提取游戏ID clientOS, ver, info = strutil.parseClientId(clientId) ftlog.debug('getClientModuleDefaultConf clientOS:', clientOS, ' ver:', ver, ' info:', info) gameId = strutil.getGameIdFromHallClientId(clientId) tName = 'hall' + str(gameId) + '_' + str("%.2f" % ver) ftlog.debug('getClientModuleDefaultConf tName:', tName) if tName in _defaultTemplateMap: tConf = _defaultTemplateMap[tName] if moduleName in tConf: # 格式化返回数据 conf = {} conf['template'] = tConf[moduleName] return conf else: ftlog.debug('No default module, module:', moduleName) else: ftlog.debug('No default module config, clientId:', clientId) return None
def _onOrderDelivery(event): from hall.entity import hallitem nowDT = datetime.now() order = event.orderDeliveryResult.order if ((_conf.startDT and nowDT < _conf.startDT) or (_conf.endDT and nowDT >= _conf.endDT)): if ftlog.is_debug(): ftlog.debug('buy_send_gift._onOrderDelivery outofTime userId=', event.userId, 'orderId=', order.orderId, 'productId=', order.productId, 'nowDT=', nowDT.strftime('%Y-%m-%d %H:%M:%S'), 'startDT=', _conf.startDT.strftime('%Y-%m-%d %H:%M:%S'), 'endDT=', _conf.endDT.strftime('%Y-%m-%d %H:%M:%S')) return giftConf = _conf.findGiftConf(order.productId) if not giftConf: if ftlog.is_debug(): ftlog.debug('buy_send_gift._onOrderDelivery noGiftConf userId=', event.userId, 'orderId=', order.orderId, 'productId=', order.productId, 'orderClientId=', order.clientId) return hallGameId = strutil.getGameIdFromHallClientId(order.clientId) if hallGameId not in giftConf.gameIds: if ftlog.is_debug(): ftlog.debug('buy_send_gift._onOrderDelivery notInGameIds userId=', event.userId, 'orderId=', order.orderId, 'productId=', order.productId, 'giftConf=', giftConf.conf, 'orderClientId=', order.clientId, 'hallGameId=', hallGameId, 'gameIds=', giftConf.gameIds) return count = 0 if giftConf.maxCount >= 0: limitD = gamedata.getGameAttrJson(order.userId, hallGameId, 'act.buy_send_gift', {}) count = limitD.get(order.productId, 0) if count + 1 > giftConf.maxCount: ftlog.info('buy_send_gift._onOrderDelivery overLimit userId=', event.userId, 'orderId=', order.orderId, 'productId=', order.productId, 'giftConf=', giftConf.conf if giftConf else None, 'orderClientId=', order.clientId, 'count=', count, 'maxCount=', giftConf.maxCount) return count += 1 limitD[order.productId] = count gamedata.setGameAttr(order.userId, hallGameId, 'act.buy_send_gift', strutil.dumps(limitD)) assetList = None if giftConf.giftContent: userAssets = hallitem.itemSystem.loadUserAssets(order.userId) # def sendContent(self, gameId, content, count, ignoreUnknown, timestamp, eventId, intEventParam): assetList = userAssets.sendContent(hallGameId, giftConf.giftContent, 1, True, pktimestamp.getCurrentTimestamp(), 'ACTIVITY_REWARD', 10043) changedDataNames = TYAssetUtils.getChangeDataNames(assetList) if assetList else set() contentStr = TYAssetUtils.buildContentsString(assetList) if assetList else '' if giftConf.mail: mail = strutil.replaceParams(giftConf.mail, {'gotContent': contentStr, 'price': order.product.price}) message.send(hallGameId, message.MESSAGE_TYPE_SYSTEM, order.userId, mail) changedDataNames.add('message') if changedDataNames: datachangenotify.sendDataChangeNotify(HALL_GAMEID, order.userId, changedDataNames) ftlog.info('buy_send_gift._onOrderDelivery sendGift userId=', event.userId, 'orderId=', order.orderId, 'productId=', order.productId, 'giftConf=', giftConf.conf if giftConf else None, 'orderClientId=', order.clientId, 'count=', count, 'maxCount=', giftConf.maxCount, 'assetList=', [(a[0].kindId, a[1]) for a in assetList] if assetList else None)
def doSendLedToUser(userId): global _ledClosesConf gameIdList = onlinedata.getGameEnterIds(userId) lastGameId = onlinedata.getLastGameId(userId) if not HALL_GAMEID in gameIdList: gameIdList.append(HALL_GAMEID) if not lastGameId in gameIdList: gameIdList.append(lastGameId) clientId = sessiondata.getClientId(userId) if clientId in _ledClosesConf: if ftlog.is_debug(): ftlog.debug('hallled.doSendLedToUser clientId:', clientId, ' is in closes list:', _ledClosesConf, ' return') return gameIdInClientId = strutil.getGameIdFromHallClientId(clientId) if not gameIdInClientId in gameIdList: gameIdList.append(gameIdInClientId) if ftlog.is_debug(): ftlog.debug('hallled.doSendLedToUser userId=', userId, 'gameIdList=', gameIdList, 'clientId=', clientId, 'gameIdInClientId=', gameIdInClientId, 'lastGameId=', lastGameId) _, clientVer, _ = strutil.parseClientId(clientId) for gameId in gameIdList: try: leds = getLedMsgList(gameId) if ftlog.is_debug(): ftlog.debug('hallled.doSendLedToUser gameId=', gameId, 'userId=', userId, 'clientId=', clientId, 'leds=', leds) if leds: for led in leds: msgDict = led[2] if clientVer >= 3.6: mo = MsgPack() mo.setCmd('led') for k, v in msgDict.iteritems(): mo.setResult(k, v) mo.setResult('scope', led[3]) else: mo = MsgPack() mo.setCmd('led') if gameId in (1, 8): msgDictV2 = translateToMsgDictV2(msgDict) if msgDictV2: mo.setKey('richText', msgDictV2.get('richText')) msgV1 = translateToMsgDictV1(msgDict) if msgV1: gameId = msgDict.get('gameId', led[1]) mo.setKey('result', [[led[0], gameId, msgV1]]) # 过滤LED clientIdFilter = led[4] if len(clientIdFilter) == 0 or clientId in clientIdFilter: if ftlog.is_debug(): ftlog.debug('sendLed to user='******'msg=', mo) router.sendToUser(mo, userId) except: ftlog.error("error leds:", leds)
def queryExitRemind(gameId, userId, clientId): 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 hall_exit_remind._ordersMap: if ftlog.is_debug(): ftlog.debug('hall_exit_remind.queryExitRemind no this game exit remind config....') return orders = hall_exit_remind._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) 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 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)