Ejemplo n.º 1
0
 def sendLed(ledStr):
     '''
     发送LED
     '''
     scope = 'hall' + str(DIZHU_GAMEID)
     ftlog.debug('led scope:', scope)
     user_remote.sendHallLed(DIZHU_GAMEID, ledStr, 0, scope)
Ejemplo n.º 2
0
    def sendColorfulLed(cls, gameId, content, scope=None):
        """ 发送一条彩色LED消息
        gameId - 参数,gameId
        content - 参数,LED发送内容
        """
        if not LED_ON:
            ftlog.debug("<< not LED_ON")
            return

        if not scope:
            scope = "hall%d" % gameId
        user_remote.sendHallLed(gameId,
                                json.dumps(
                                    {'text': cls.mkRichTextBody(content)}),
                                ismgr=1,
                                scope=scope)
Ejemplo n.º 3
0
 def sendLed(cls, fmtstr, scope=None, active=0):
     """
     发送Led消息到UT服
     param:gameId 插件Id
     param:scope LED显示级别
            详细参考http://192.168.10.93:8090/pages/viewpage.action?pageId=1281059
     param:fmtstr 格式化富文本串[['RRGGBB', 'text']]
     """
     richText = cls.makeRichTextBody(fmtstr)
     if ftlog.is_debug():
         ftlog.debug('sendLed rich text',
                     'text=',
                     richText,
                     'dumptext=',
                     json.dumps({'text': richText}),
                     caller=cls)
     if not scope:
         scope = 'hall%d' % DIZHU_GAMEID
     user_remote.sendHallLed(DIZHU_GAMEID,
                             json.dumps({'text': richText}),
                             ismgr=1,
                             scope=scope,
                             active=active)
     cls.saveLedText(richText)
Ejemplo n.º 4
0
def loginGame_v456(userId, gameId, clientId, loginsum, isdayfirst, daylogin):
    ftlog.info("loginGame_v456|", userId, gameId, clientId, loginsum,
               isdayfirst, daylogin)

    # 是否是登录大厅
    if gameId != HALL_GAMEID:
        ftlog.debug("loginGame_v456|isnotloginHall", gameId)
        return

    if isdayfirst:  #每日首次登陆vip补足,全放开不做版本限制2017.8.2
        # from hall.entity.newcheckin import complementByVip
        # complementByVip(userId, gameId, clientId)

        from hall.entity import hallitem
        userAssets = hallitem.itemSystem.loadUserAssets(userId)
        userBag = userAssets.getUserBag()
        if ftlog.is_debug():
            ftlog.debug('isdayfirst=', userId, gameId, clientId, loginsum,
                        isdayfirst, daylogin)
        for itemKindId in [
                hallitem.ITEM_CROWN_MONTHCARD_KIND_ID,
                hallitem.ITEM_HONOR_MONTHCARD_KIND_ID
        ]:
            item = userBag.getItemByKindId(itemKindId)
            if ftlog.is_debug():
                ftlog.debug('honor monthcard itemKindId', userId, itemKindId,
                            item)
            if item:
                timestamp = int(time.time())
                deltatime = item.expiresTime - timestamp
                if deltatime > 0 and deltatime < 48 * 3600:
                    msg = u"亲,您的月卡即将到期,明天以后就不能享受尊贵权益了,请及时续费吧~"
                    from hall.entity.todotask import TodoTaskShowInfo, TodoTaskHelper
                    infoTodoTask = TodoTaskShowInfo(msg, True)
                    TodoTaskHelper.sendTodoTask(gameId, userId, infoTodoTask)
                    if ftlog.is_debug():
                        ftlog.debug('honor monthcard expiresTime', userId,
                                    itemKindId)
        from poker.entity.dao import gamedata, userdata
        import json
        gamedata.setGameAttr(userId, HALL_GAMEID, "honormonthcardreward", 0)
        gamedata.setGameAttr(userId, HALL_GAMEID, 'todaynotifylist',
                             json.dumps([]))
        item = userBag.getItemByKindId(hallitem.ITEM_HONOR_MONTHCARD_KIND_ID)
        if item and item.expiresTime - (time.time()) > 24 * 3600:
            name = userdata.getAttr(userId, 'name')
            COLOR_DEFAULT = "F0F8FF"
            COLOR_SPECIAL = "FFFF00"
            content = [[COLOR_DEFAULT,
                        u'热烈欢迎尊贵的星耀月卡用户'], [COLOR_SPECIAL, name],
                       [COLOR_DEFAULT, u'登录游戏,祝愿您手气长虹~']]
            from hall.servers.util.rpc import user_remote as SendLed
            SendLed.sendHallLed(gameId,
                                json.dumps({
                                    'text': [{
                                        'color': color,
                                        'text': text
                                    } for color, text in content]
                                }),
                                ismgr=1)
            if ftlog.is_debug():
                ftlog.debug('honor monthcard led', userId, content)
    #是否是v4.56
    if not checkClientVer(userId, gameId, clientId):
        ftlog.info("loginGame_v456|failer|clientVer|isnotMatch|", userId,
                   gameId, clientId)
        return

    # checkinId客户端自己查找本地数据index
    checkinId = getCheckinId(clientId)
    sendCheckinId2client(gameId, userId, checkinId)

    # 价格列表
    pricelist = getPriceList(gameId, userId, clientId)
    sendPriceList2client(gameId, userId, clientId, pricelist)

    # 推送配置数据2c
    pushGameConfig(userId, gameId, clientId)

    # 新弹窗入口
    newpopwnd.enterpopwnd(userId, gameId, clientId, loginsum, isdayfirst,
                          daylogin)

    download_guide(userId, gameId, clientId)
Ejemplo n.º 5
0
    def notifyMatchOver(self, player, reason, rankRewards):
        '''
        通知用户比赛结束了
        '''
        try:
            if (reason == MatchFinishReason.USER_WIN
                    or reason == MatchFinishReason.USER_LOSER):
                try:
                    event_remote.publishMatchWinloseEvent(
                        self._room.gameId, player.userId,
                        self._room.match.matchId,
                        reason == MatchFinishReason.USER_WIN, player.rank,
                        player.group.startPlayerCount,
                        rankRewards.conf if rankRewards else None)
                    from dizhu.entity.matchhistory import MatchHistoryHandler
                    MatchHistoryHandler.onMatchOver(
                        player.userId, player.group.matchConf.recordId,
                        player.rank, reason == MatchFinishReason.USER_WIN,
                        rankRewards.conf if rankRewards else None,
                        player.group.isGrouping)
                except:
                    self._logger.error('PlayerNotifierDizhu.notifyMatchOver',
                                       'userId=', player.userId, 'groupId=',
                                       player.group.groupId, 'reason=', reason,
                                       'rankRewards=', rankRewards.rewards)

                # 比赛记录保存
                try:
                    event = {
                        'gameId': self._room.gameId,
                        'userId': player.userId,
                        'matchId': self._room.match.matchId,
                        'rank': player.rank,
                        'isGroup': 1 if player.group.isGrouping else 0
                    }
                    MatchRecord.updateAndSaveRecord(event)
                except:
                    self._logger.error('PlayerNotifierDizhu.notifyMatchOver',
                                       'gameId=', self._room.gameId, 'userId=',
                                       player.userId, 'reason=', reason,
                                       'matchId=', self._room.match.matchId,
                                       'rank=', player.rank)

            msg = MsgPack()
            msg.setCmd('m_over')
            msg.setResult('gameId', self._room.gameId)
            msg.setResult('roomId', self._room.bigRoomId)
            msg.setResult('userId', player.userId)
            msg.setResult('reason', reason)
            msg.setResult('rank', player.rank)
            try:
                msg.setResult('beatDownUser', player.beatDownUserName)
            except:
                ftlog.debug('NobeatDownUser group match')
                ftlog.exception()

            if rankRewards or reason == MatchFinishReason.USER_WIN:
                msg.setResult('info',
                              buildWinInfo(self._room, player, rankRewards))
                if rankRewards.todotask:
                    msg.setResult('todotask', rankRewards.todotask)
            else:
                msg.setResult('info', buildLoserInfo(self._room, player))

            msg.setResult(
                'mucount', player.group.startPlayerCount
                if player.group.isGrouping else player.group.totalPlayerCount)
            msg.setResult('date', str(datetime.now().date().today()))
            msg.setResult('time',
                          time.strftime('%H:%M', time.localtime(time.time())))
            msg.setResult('addInfo', '')
            rewardDesc = ''
            if rankRewards:
                from dizhu.bigmatch.match import BigMatch
                msg.setResult('reward', BigMatch.buildRewards(rankRewards))
                rewardDesc = BigMatch.buildRewardsDesc(rankRewards)
                if rewardDesc:
                    msg.setResult('rewardDesc', rewardDesc)
            msg.setResult('mname', getMatchName(self._room, player))

            record = MatchRecord.loadRecord(self._room.gameId, player.userId,
                                            self._room.match.matchId)
            if record:
                msg.setResult(
                    'mrecord', {
                        'bestRank': record.bestRank,
                        'bestRankDate': record.bestRankDate,
                        'isGroup': record.isGroup,
                        'crownCount': record.crownCount,
                        'playCount': record.playCount
                    })
            else:
                from dizhu.activities.toolbox import Tool
                msg.setResult(
                    'mrecord', {
                        'bestRank': player.rank,
                        'bestRankDate': Tool.datetimeToTimestamp(
                            datetime.now()),
                        'isGroup': 1 if player.group.isGrouping else 0,
                        'crownCount': 1 if player.rank == 1 else 0,
                        'playCount': 1
                    })

            try:
                # 设置奖状分享的todotask diplomaShare
                shareTodoTask = dizhudiplomashare.buildDiplomaShare(
                    player.userName, getMatchName(self._room, player),
                    player.rank, rewardDesc, player.userId)
                if shareTodoTask:
                    msg.setResult('shareTodoTask', shareTodoTask)
            except:
                ftlog.debug('NobeatDownUser group match')
                ftlog.exception()

            router.sendToUser(msg, player.userId)

            if reason in (MatchFinishReason.USER_NOT_ENOUGH,
                          MatchFinishReason.RESOURCE_NOT_ENOUGH):
                mo = MsgPack()
                mo.setCmd('m_signs')
                mo.setResult('gameId', self._room.gameId)
                mo.setResult('roomId', self._room.bigRoomId)
                mo.setResult('userId', player.userId)
                mo.setResult('signs', {self._room.bigRoomId: 0})
                router.sendToUser(mo, player.userId)

            if player.rank == 1 and self._room.roomConf.get('championLed'):
                ledtext = '玩家%s在斗地主"%s"中过五关斩六将夺得冠军,获得%s!' % (
                    player.userName, self._room.roomConf['name'], rewardDesc)
                user_remote.sendHallLed(DIZHU_GAMEID, ledtext, 1, 'global', [])

            sequence = int(player.group.instId.split('.')[1])
            self.report_bi_game_event("MATCH_FINISH", player.userId,
                                      player.group.matchId, 0, sequence, 0, 0,
                                      0, [], 'match_end')  #_stage.matchingId
        except:
            self._logger.error('PlayerNotifierDizhu.notifyMatchOver',
                               'userId=', player.userId, 'groupId=',
                               player.group.groupId, 'reason=', reason,
                               'rankRewards=',
                               rankRewards.rewards if rankRewards else None)
Ejemplo n.º 6
0
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
Ejemplo n.º 7
0
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