コード例 #1
0
ファイル: group_match_room.py プロジェクト: zhaozw/hall37
    def _notifyRobotSigninMatch(self, signer):
        if self._logger.isDebug():
            self._logger.warn('TYGroupMatchRoom._notifyRobotSigninMatch',
                              'userId=', signer.userId,
                              'instId=', signer.inst)

        if self.roomConf.get('hasrobot'):
            startConf = self.match.matchConf.start
            if self.roomConf['robotUserMaxCount'] == -1:
                if startConf.isTimingType():
                    minsize = startConf.userMinCount
                else:
                    minsize = startConf.userCount - 2
            else:
                minsize = self.roomConf['robotUserMaxCount']

            if signer.inst.signerCount >= minsize:
                return

            mo = MsgPack()
            mo.setCmd('robotmgr')
            mo.setAction('callmatch')
            mo.setParam('gameId', self.gameId)
            mo.setParam('roomId', self.bigRoomId)
            mo.setParam('robotCount', 4)
            router.sendRobotServer(mo, signer.userId)

            func = functools.partial(self._notifyRobotSigninMatch, signer)
            FTTimer(15, func)
コード例 #2
0
    def _notifyRobotSigninMatch(self, signer):
        if self._logger.isDebug():
            self._logger.warn('TYGroupMatchRoom._notifyRobotSigninMatch',
                              'userId=', signer.userId, 'instId=', signer.inst)

        if self.roomConf.get('hasrobot'):
            startConf = self.match.matchConf.start
            if self.roomConf['robotUserMaxCount'] == -1:
                if startConf.isTimingType():
                    minsize = startConf.userMinCount
                else:
                    minsize = startConf.userCount - 2
            else:
                minsize = self.roomConf['robotUserMaxCount']

            if signer.inst.signerCount >= minsize:
                return

            mo = MsgPack()
            mo.setCmd('robotmgr')
            mo.setAction('callmatch')
            mo.setParam('gameId', self.gameId)
            mo.setParam('roomId', self.bigRoomId)
            mo.setParam('robotCount', 4)
            router.sendRobotServer(mo, signer.userId)

            func = functools.partial(self._notifyRobotSigninMatch, signer)
            FTTimer(15, func)
コード例 #3
0
ファイル: big_match_room.py プロジェクト: zhaozw/hall37
    def __notifyRobotSigninMatch(self, player):
        ftlog.debug("<< |roomId, instId, playerId :", self.roomId, player.inst.instId, player.userId, caller=self)
        #         if hasattr(player.inst, "calledRobot") : #同一个比赛实例只召唤一次机器人
        #             return

        if player.inst.state >= player.inst.STATE_PREPARE:
            return

        if self.roomConf.get('hasrobot'):
            #             player.inst.calledRobot = True #同一个比赛实例只召唤一次机器人
            startConf = player.inst.conf.start
            if self.roomConf["robotUserMaxCount"] == -1:
                if startConf.isTimingType():
                    minsize = startConf.userMinCount
                else:
                    minsize = startConf.userCount - 2
            else:
                minsize = self.roomConf["robotUserMaxCount"]

            cur_p = len(player.inst.playerMap)
            if cur_p >= minsize:
                return

            mo = MsgPack()
            mo.setCmd('robotmgr')
            mo.setAction('callmatch')
            mo.setParam('gameId', self.gameId)
            mo.setParam('roomId', self.roomId)
            mo.setParam('robotCount', 4)
            router.sendRobotServer(mo, player.userId)

            func = functools.partial(self.__notifyRobotSigninMatch, player)
            FTTimer(15, func)
コード例 #4
0
ファイル: ftroom.py プロジェクト: luningcowboy/tuyoo
 def unbindTable(self, table):
     msg = MsgPack()
     msg.setCmd('table_manage')
     msg.setAction('ft_unbind')
     msg.setParam('roomId', table.roomId)
     msg.setParam('tableId', table.tableId)
     msg.setParam('ftId', table.ftTable.ftId)
     router.sendTableServer(msg, table.roomId)
コード例 #5
0
 def _callRobotSigninMatch(self, count=1):
     mo = MsgPack()
     mo.setCmd("robotmgr")
     mo.setAction("callmatch")
     mo.setParam("gameId", self.gameId)
     mo.setParam("roomId", self.roomId)
     mo.setParam("robotCount", count)
     router.sendRobotServer(mo)
コード例 #6
0
ファイル: ftroom.py プロジェクト: luningcowboy/tuyoo
 def bindTable(self, table):
     msg = MsgPack()
     msg.setCmd('table_manage')
     msg.setAction('ft_bind')
     msg.setParam('roomId', table.roomId)
     msg.setParam('tableId', table.tableId)
     msg.setParam('ftTable', self.buildFTTableDetails(table.ftTable))
     router.sendTableServer(msg, table.roomId)
コード例 #7
0
ファイル: ftroom.py プロジェクト: luningcowboy/tuyoo
 def continueTable(self, table):
     msg = MsgPack()
     msg.setCmd('table_manage')
     msg.setAction('ft_continue')
     msg.setParam('roomId', table.roomId)
     msg.setParam('tableId', table.tableId)
     msg.setParam('ftId', table.ftTable.ftId)
     msg.setParam('expires', table.ftTable.expires)
     router.sendTableServer(msg, table.roomId)
コード例 #8
0
ファイル: admin.py プロジェクト: zhaozw/hall37
    def checkTableTiles(self, roomId, tableId):
        ftlog.debug('MJAdmin.checkTableTiles roomId:', roomId, ' tableId:', tableId)

        mo = MsgPack()
        mo.setCmd('table_manage')
        mo.setAction('tableTiles')
        mo.setParam('roomId', roomId)
        mo.setParam('tableId', tableId)
        router.sendTableServer(mo, roomId)
        return {'info': 'ok', 'code': 0}
コード例 #9
0
 def checkTableTiles(self, roomId, tableId):
     ftlog.debug('MJAdmin.checkTableTiles roomId:', roomId, ' tableId:', tableId)
     
     mo = MsgPack()
     mo.setCmd('table_manage')
     mo.setAction('tableTiles')
     mo.setParam('roomId', roomId)
     mo.setParam('tableId', tableId)
     router.sendTableServer(mo, roomId)
     return {'info': 'ok', 'code': 0}
コード例 #10
0
ファイル: admin.py プロジェクト: zhaozw/hall37
    def kickUser(self, userId, roomId, tableId):
        ftlog.debug('MJAdmin.kickUser roomId:', roomId, ' tableId:', tableId, ' userId:', userId)

        mo = MsgPack()
        mo.setCmd('table_manage')
        mo.setAction('leave')
        mo.setParam('roomId', roomId)
        mo.setParam('tableId', tableId)
        mo.setParam('userId', userId)
        router.sendTableServer(mo, roomId)
        return {'info': 'ok', 'code': 0}
コード例 #11
0
 def kickUser(self, userId, roomId, tableId):
     ftlog.debug('MJAdmin.kickUser roomId:', roomId, ' tableId:', tableId, ' userId:', userId)
     
     mo = MsgPack()
     mo.setCmd('table_manage')
     mo.setAction('leave')
     mo.setParam('roomId', roomId)
     mo.setParam('tableId', tableId)
     mo.setParam('userId', userId)
     router.sendTableServer(mo, roomId)
     return {'info': 'ok', 'code': 0}
コード例 #12
0
ファイル: dtg_room.py プロジェクト: zhaozw/hall37
    def notifyRobot(self, robotN=1):
        if ftlog.is_debug():
            ftlog.debug("<< |roomId:", self.room.roomId, caller=self)

        if self.room.roomConf.get('hasrobot'):
            mo = MsgPack()
            mo.setCmd('robotmgr')
            mo.setAction('callmatch')
            mo.setParam('gameId', self.room.gameId)
            mo.setParam('roomId', self.room.roomId)
            mo.setParam('robotCount', robotN)
            router.sendRobotServer(mo)
コード例 #13
0
    def notifyRobot(self, robotN=1):
        if ftlog.is_debug():
            ftlog.debug("<< |roomId:", self.room.roomId, caller=self)

        if self.room.roomConf.get('hasrobot'):
            mo = MsgPack()
            mo.setCmd('robotmgr')
            mo.setAction('callmatch')
            mo.setParam('gameId', self.room.gameId)
            mo.setParam('roomId', self.room.roomId)
            mo.setParam('robotCount', robotN)
            router.sendRobotServer(mo)
コード例 #14
0
 def startTable(self, table):
     '''
     让桌子开始
     '''
     try:
         mo = MsgPack()
         mo.setCmd('table_manage')
         mo.setAction('m_table_start')
         mo.setParam('roomId', table.roomId)
         mo.setParam('tableId', table.tableId)
         mo.setParam('matchId', table.matchInst.matchId)
         mo.setParam('ccrc', table.ccrc)
         mo.setParam('baseScore', table.matchInst.matchConf.baseScore)
         userInfos = []
         ranks = []
         for seat in table.seats:
             player = seat.player
             if player:
                 ranks.append(player.tableDisplayRank)
                 userInfo = {
                     'userId': player.userId,
                     'seatId': seat.seatId,
                     'score': player.score,
                     'cardCount': player.cardCount,
                     'rank': player.tableDisplayRank,
                     'chiprank': player.tableDisplayRank,
                     'userName': player.userName,
                     'clientId': player.clientId,
                     'ranks': ranks,
                     'stage': {
                         'name': player.stage.stageConf.name,
                         'index': player.stage.stageConf.index,
                         'cardCount': player.stage.stageConf.cardCount,
                         'playerCount':
                         player.stage.stageConf.totalUserCount,
                         'riseCount': player.stage.stageConf.riseUserCount,
                         'animationType':
                         player.stage.stageConf.animationType
                     }
                 }
             else:
                 userInfo = None
             userInfos.append(userInfo)
         mo.setParam('userInfos', userInfos)
         if ftlog.is_debug():
             ftlog.debug('MatchTableControllerDizhu.startTable matchId=',
                         table.matchInst.matchId, 'instId=',
                         table.matchInst.instId, 'roomId=', table.roomId,
                         'tableId=', table.tableId, 'mo=', mo)
         router.sendTableServer(mo, table.roomId)
     except:
         ftlog.error()
コード例 #15
0
def queryAlarm(userId):
    alarms = AlarmDao.load(userId)
    if not alarms:
        return
    mo = MsgPack()
    mo.setCmd('game')
    mo.setAction('alarmList')
    mo.setResult('gameId', 9999)
    mo.setResult('userId', userId)
    mo.setResult('curtime', timestamp.getCurrentTimestamp())
    mo.setResult('alarms', alarms)
    router.sendToUser(mo, userId)
    return mo
コード例 #16
0
 def _callRobotSigninMatch(self, count=1):
     self._logger.debug("MatchRoom._callRobotSigninMatch", count)
     for _ in xrange(count):
         ruid = random.randint(1, 200)
         # 有机器人直接进榜.
         if userdata.checkUserData(ruid):
             rname = userdata.getAttr(ruid, "name")
             self.addMatchRobotUser(ruid, rname)
         else:  # 没有机器人召唤机器人登录.
             mo = MsgPack()
             mo.setCmd("robotmgr")
             mo.setAction("callmatch")
             mo.setParam("gameId", self.gameId)
             mo.setParam("roomId", self.roomId)
             mo.setParam("robotCount", 1)
             router.sendRobotServer(mo)
             self._logger.warn(
                 "_callRobotSigninMatch, add robot failed, ruid =", ruid)
コード例 #17
0
ファイル: httpgdss.py プロジェクト: zhaozw/hall37
    def do_gdss_clear_table(self, gameId, roomId0, tableId0):
        moCheck = MsgPack()
        ec, result = self.checkCode()
        if ec:
            moCheck.setError(ec, result)
            return

        from freetime.util import log as ftlog
        ftlog.debug('HALLAdmin.clearTable gameId:', gameId, ' roomId:',
                    roomId0, ' tableId:', tableId0)

        mo = MsgPack()
        mo.setCmd('table_manage')
        mo.setAction('clear_table')
        mo.setParam('gameId', gameId)
        mo.setParam('roomId', roomId0)
        mo.setParam('tableId', tableId0)
        from poker.protocol import router
        router.sendTableServer(mo, roomId0)

        return moCheck
コード例 #18
0
ファイル: big_match_room.py プロジェクト: zhaozw/hall37
    def __notifyRobotSigninMatch(self, player):
        ftlog.debug("<< |roomId, instId, playerId :",
                    self.roomId,
                    player.inst.instId,
                    player.userId,
                    caller=self)
        #         if hasattr(player.inst, "calledRobot") : #同一个比赛实例只召唤一次机器人
        #             return

        if player.inst.state >= player.inst.STATE_PREPARE:
            return

        if self.roomConf.get('hasrobot'):
            #             player.inst.calledRobot = True #同一个比赛实例只召唤一次机器人
            startConf = player.inst.conf.start
            if self.roomConf["robotUserMaxCount"] == -1:
                if startConf.isTimingType():
                    minsize = startConf.userMinCount
                else:
                    minsize = startConf.userCount - 2
            else:
                minsize = self.roomConf["robotUserMaxCount"]

            cur_p = len(player.inst.playerMap)
            if cur_p >= minsize:
                return

            mo = MsgPack()
            mo.setCmd('robotmgr')
            mo.setAction('callmatch')
            mo.setParam('gameId', self.gameId)
            mo.setParam('roomId', self.roomId)
            mo.setParam('robotCount', 4)
            router.sendRobotServer(mo, player.userId)

            func = functools.partial(self.__notifyRobotSigninMatch, player)
            FTTimer(15, func)
コード例 #19
0
ファイル: interfacedizhu.py プロジェクト: luningcowboy/tuyoo
 def startTable(self, table):
     '''
     让桌子开始
     '''
     try:
         mo = MsgPack()
         mo.setCmd('table_manage')
         mo.setAction('m_table_start')
         mo.setParam('gameId', table.gameId)
         mo.setParam('roomId', table.roomId)
         mo.setParam('tableId', table.tableId)
         mo.setParam('matchId', table.matchInst.matchId)
         mo.setParam('ccrc', table.ccrc)
         mo.setParam('baseScore', table.matchInst.matchConf.baseScore)
         userInfos = []
         ranks = []
         for seat in table.seats:
             player = seat.player
             if player:
                 ranks.append(player.tableDisplayRank)
                 hasEnterRewards = False
                 try:
                     if ftlog.is_debug():
                         ftlog.debug(
                             'startTable playerId=', player.userId,
                             'stageIndex=', player.stage.index,
                             'hasRewardIndex=',
                             self._room.roomConf.get('hasRewardIndex'))
                     if player.stage.stageConf.cardCount == 1 and not player.isQuit and player.stage.index == self._room.roomConf.get(
                             'hasRewardIndex'):
                         hasEnterRewards = True
                 except Exception, e:
                     ftlog.error('hasEnterRewards ', 'instId=',
                                 table.matchInst.instId, 'roomId=',
                                 table.roomId, 'err=', e.message)
                 userInfo = {
                     'userId':
                     player.userId,
                     'seatId':
                     seat.seatId,
                     'score':
                     player.score,
                     'mixId':
                     player.mixId,
                     'isQuit':
                     player.isQuit,
                     'cardCount':
                     player.cardCount,
                     'rank':
                     player.tableDisplayRank,
                     'isLastStage':
                     table.matchInst._isLastStage(player.stage),
                     'chiprank':
                     player.tableDisplayRank,
                     'userName':
                     player.userName,
                     'clientId':
                     player.clientId,
                     'roomName':
                     table.matchInst.matchConf.getRoomName(player.mixId),
                     'winloseForTuoguan':
                     player.winloseForTuoguan,
                     'ranks':
                     ranks,
                     'hasEnterRewards':
                     hasEnterRewards,
                     'stage': {
                         'name': player.stage.stageConf.name,
                         'index': player.stage.stageConf.index,
                         'cardCount': player.stage.stageConf.cardCount,
                         'playerCount':
                         player.stage.stageConf.totalUserCount,
                         'riseCount': player.stage.stageConf.riseUserCount,
                         'animationType':
                         player.stage.stageConf.animationType
                     },
                     'stageRewardTotal':
                     seat.player.stageRewardTotal
                 }
             else:
                 userInfo = None
             userInfos.append(userInfo)
         mo.setParam('userInfos', userInfos)
         if ftlog.is_debug():
             ftlog.debug('MatchTableControllerDizhu.startTable matchId=',
                         table.matchInst.matchId, 'instId=',
                         table.matchInst.instId, 'roomId=', table.roomId,
                         'tableId=', table.tableId, 'mo=', mo)
         router.sendTableServer(mo, table.roomId)
コード例 #20
0
def getShareReward(gameId, userId, share, shareLoc, timestamp):
    '''
    给用户发放分享奖励
    '''
    # 分享BI日志汇报
    clientId = sessiondata.getClientId(userId)
    bireport.reportGameEvent('SHARE_CALLBACK', userId, gameId, share.shareId,
                             0, 0, 0, 0, 0, [], clientId)

    # 记录分享次数
    gamedata.incrGameAttr(userId, HALL_GAMEID, 'shareCount', 1)
    TGHall.getEventBus().publishEvent(
        HallShareEvent(gameId, userId, share.shareId, shareLoc))

    # 首先处理 分享相关的通知
    notifyInfoStr = pkgamedata.getGameAttr(userId, HALL_GAMEID, 'shareInfo')
    newInfo = {}
    pkgamedata.setGameAttr(userId, HALL_GAMEID, 'shareInfo',
                           json.dumps(newInfo))

    if notifyInfoStr:
        notifyInfo = json.loads(notifyInfoStr)
        shareId = notifyInfo.get('shareId', 0)
        if shareId == share.shareId:
            # 通知
            info = notifyInfo.get('info', '')
            module = notifyInfo.get('module', '')
            if module == hall_red_envelope.TYRedEnvelope.EVENTID:
                hall_red_envelope.TYRedEnvelopeMgr.changeRedEnvelopeState(
                    info, hall_red_envelope.TYRedEnvelope.STATE_SHARED)

                from poker.entity.game.game import TYGame
                clientId = sessiondata.getClientId(userId)
                gameids = hallconf.getDaShiFenFilter(clientId)
                for gid in gameids:
                    TYGame(gid).sendTuyooRedEnvelopeCallBack(
                        userId, clientId, info)

    # 分享奖励
    ok, rewardCount = incrRewardCount(userId, share, timestamp)
    if not ok:
        if ftlog.is_debug():
            ftlog.debug(
                'hallshare.getShareReward already no share, check update share promote ...'
            )
            ftlog.debug('hallshare.getShareReward fail gameId=', gameId,
                        'userId=', userId, 'shareId=', share.shareId,
                        'shareLoc=', shareLoc, 'rewardCount=', rewardCount,
                        'maxRewardCount=', share.maxRewardCount)
        return False

    assetList = sendReward(gameId, userId, share, shareLoc)
    if assetList and share.mail:
        TodoTaskHelper.sendTodoTask(gameId, userId,
                                    TodoTaskGoldRain(share.mail))

    ftlog.debug('hallshare.getShareReward ok gameId=', gameId, 'userId=',
                userId, 'shareId=', share.shareId, 'shareLoc=', shareLoc,
                'rewardCount=', rewardCount, 'maxRewardCount=',
                share.maxRewardCount, 'reward=',
                [(at[0].kindId, at[1])
                 for at in assetList] if assetList else [])
    if share.mail:
        pkmessage.send(gameId, pkmessage.MESSAGE_TYPE_SYSTEM, userId,
                       share.mail)
    # udpate free & promotion_loc
    datachangenotify.sendDataChangeNotify(gameId, userId,
                                          ['free', 'promotion_loc'])
    # 深圳研发中心修改,增加领奖后的返回指令
    from freetime.entity.msg import MsgPack
    from poker.protocol import router
    mp = MsgPack()
    mp.setCmd('share_hall')
    mp.setAction('reward')
    mp.setResult('gameId', gameId)
    mp.setResult('userId', userId)
    mp.setResult('shareId', share.shareId)
    mp.setResult('rewards', [(at[0].kindId, at[1])
                             for at in assetList] if assetList else [])
    router.sendToUser(mp, userId)
    return True