def sendLedText(self, activityGameId, userId, prize): ledsMap = Tool.dictGet(self._clientConf, 'config.server.ledsMap', {}) prizes = Tool.dictGet(self._clientConf, 'config.server.prizes', []) for item in prizes: # 根据奖励itemId找到奖励配置 if item['itemId'] != prize['itemId']: continue # 获取led发送的配置 ledItem = ledsMap.get(item.get('ledKey')) if not ledItem: continue # 查看是否满足LED发送条件 if ledItem.get('minCount', 0) > prize['count']: continue text = ledItem.get('text') if not text: continue prizeContent = hallitem.buildContent(prize['itemId'], prize['count'], True) ledtext = strutil.replaceParams( text, { 'nickname': UserInfo.getNickname(userId), 'prizeContent': prizeContent }) hallled.sendLed(activityGameId, ledtext, 0, scope='hall6') if ftlog.is_debug(): ftlog.debug('LuckyMoneyNew.sendLedText', 'activityGameId=', activityGameId, 'activityId=', self._clientConf['id'], 'userId=', userId, 'ledtext=', ledtext) break
def sendGiftsToUser(userId, gameId, clientId, items): ''' 多个奖品时的发奖,或者一个奖品的发奖,items为数组 ''' contentItemList = [] rouletteMap = getRouletteMap() for item in items: itemMap = rouletteMap.get(item, {}) if itemMap: # 添加判断流程,判断奖励是否需要发送led if itemMap.get('isSendLed', False): userInfo = halluser.getUserInfo(userId, gameId, clientId) msgstr = '恭喜' + userInfo.get( 'name', '') + '玩家在幸运大转盘中,抽中了' + itemMap.get( 'itemDesc', '') + '大奖!快来参与,大奖得主就是你!' hallled.sendLed(HALL_GAMEID, msgstr, 1, 'hall') # 添加中奖内容 contentItemList.append( TYContentItem.decodeFromDict({ 'itemId': itemMap.get('itemId'), 'count': itemMap.get('count') })) userAssets = hallitem.itemSystem.loadUserAssets(userId) results = userAssets.sendContentItemList(gameId, contentItemList, 1, True, int(time.time()), 'ROULETTE_GOLD', 0) datachangenotify.sendDataChangeNotify( gameId, userId, TYAssetUtils.getChangeDataNames(results))
def _onHeartBeat(event): leds, ismgr = matchLed() if leds: for led in leds: hallled.sendLed(DIZHU_GAMEID, led, ismgr) return led, ismgr = _randLed() if ftlog.is_debug(): ftlog.debug('dizhuled._onHeartBeat, led=', led) if led: hallled.sendLed(DIZHU_GAMEID, led, ismgr)
def sendGiftsToUser(userId, gameId, clientId, items): ''' 多个奖品时的发奖,或者一个奖品的发奖,items为数组 ''' contentItemList = [] rouletteMap = getRouletteMap() for item in items: itemMap = rouletteMap.get(item, {}) if itemMap: #添加判断流程,判断奖励是否需要发送led if itemMap.get('isSendLed', False): userInfo = halluser.getUserInfo(userId, gameId, clientId) msgstr = '恭喜玩家' + userInfo.get( 'name', '') + '在幸运大转盘中,抽中了' + itemMap.get( 'itemDesc', '') + '大奖!快来参与,大奖得主就是你!' hallled.sendLed(HALL_GAMEID, msgstr, 0, 'hall') # 轮播LED仅保留最近10条中奖记录 doRouletteRecordKey = "roulette:recordLed" try: datas = { 'name': userInfo.get('name', ''), 'itemDesc': itemMap.get('itemDesc', '') } recordledLen = daobase.executeMixCmd( 'RPUSH', doRouletteRecordKey, json.dumps(datas)) if recordledLen > 10: # 超过10个就截取后10个 daobase.executeMixCmd('LTRIM', doRouletteRecordKey, -10, -1) except: ftlog.warn("redis rpush|ltrim roulette:recordLed error", gameId, userId, clientId, msgstr) ftlog.debug("sendGiftsToUser|1", userId, gameId, clientId, msgstr) ftlog.debug("sendGiftsToUser|2", userId, gameId, clientId, itemMap.get('isSendLed')) # 添加中奖内容 contentItemList.append( TYContentItem.decodeFromDict({ 'itemId': itemMap.get('itemId'), 'count': itemMap.get('count') })) userAssets = hallitem.itemSystem.loadUserAssets(userId) results = userAssets.sendContentItemList(gameId, contentItemList, 1, True, int(time.time()), 'ROULETTE_GOLD', 0) datachangenotify.sendDataChangeNotify( gameId, userId, TYAssetUtils.getChangeDataNames(results))
def sendGiftsToUser(userId, gameId, clientId, items): ''' 多个奖品时的发奖,或者一个奖品的发奖,items为数组 ''' contentItemList = [] rouletteMap = getRouletteMap() for item in items: itemMap = rouletteMap.get(item, {}) if itemMap: # 添加判断流程,判断奖励是否需要发送led if itemMap.get('isSendLed', False): userInfo = halluser.getUserInfo(userId, gameId, clientId) msgstr = '恭喜' + userInfo.get('name', '') + '玩家在幸运大转盘中,抽中了' + itemMap.get('itemDesc', '') + '大奖!快来参与,大奖得主就是你!' hallled.sendLed(HALL_GAMEID, msgstr, 1, 'hall') # 添加中奖内容 contentItemList.append( TYContentItem.decodeFromDict({'itemId': itemMap.get('itemId'), 'count': itemMap.get('count')})) userAssets = hallitem.itemSystem.loadUserAssets(userId) results = userAssets.sendContentItemList(gameId, contentItemList, 1, True, int(time.time()), 'ROULETTE_GOLD', 0) datachangenotify.sendDataChangeNotify(gameId, userId, TYAssetUtils.getChangeDataNames(results))
def sendLed(cls, text): ''' 只在地主大厅和地主插件中播放LED ''' hallled.sendLed(DIZHU_GAMEID, text, 0, scope='hall6')
def send_led(cls, gameId, msg): '''系统led''' hallled.sendLed(gameId, msg, 0)
def _sendHallLed(intServerId, gameId, msgstr, ismgr, scope, clientIds): hallled.sendLed(gameId, msgstr, ismgr, scope, clientIds)
def _sendHallLed(intServerId, gameId, msgstr, ismgr, scope, clientIds, **kwargs): hallled.sendLed(gameId, msgstr, ismgr, scope, clientIds, **kwargs)
def doSendLed(self, gameId, msg, ismgr, scope='hall', clientIds=[]): hallled.sendLed(gameId, msg, ismgr, scope, clientIds)
def doSendLed(self, gameId, msg, ismgr, scope='hall', clientIds=[], isStopServer=False): hallled.sendLed(gameId, msg, ismgr, scope, clientIds, isStopServer)
def sendLed(text, scope='6', clientIds=[]): if text: ftlog.debug('matchled sendLed text=', text, ' scope=', scope, ' clientIds:', clientIds) hallled.sendLed(DIZHU_GAMEID, text, 1, scope, clientIds)