示例#1
0
    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)
示例#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
    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)
 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)
示例#5
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)
示例#6
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)
示例#7
0
 def sendRobotNotifyShutDown(self, params):
     hasrobot = self.table.runConfig.hasrobot
     ftlog.debug("|hasrobot, params", hasrobot, params, caller=self)
     if hasrobot:
         ucount, uids = self.table.getSeatUserIds()
         mo = self.createMsgPackRequest("robotmgr")
         if params:
             mo.updateParam(params)
         mo.setAction('shutdown')
         mo.setParam('userCount', ucount)
         mo.setParam('seatCount', len(uids))
         mo.setParam('users', uids)
         router.sendRobotServer(mo, self.table.tableId)
 def sendRobotNotifyCallUp(self, params):
     '''
     召唤机器人
     '''
     ucount, uids = self.table.getSeatUserIds()
     mo = self.createMsgPackRequest("robotmgr")
     if params:
         mo.updateParam(params)
     mo.setAction('callup')
     mo.setParam('userCount', ucount)
     mo.setParam('seatCount', len(uids))
     mo.setParam('users', uids)
     router.sendRobotServer(mo, self.table.tableId)
示例#9
0
 def sendRobotNotifyShutDown(self, params):
     hasrobot = self.table.runConfig["hasrobot"]
     if ftlog.is_debug():
         ftlog.debug("|hasrobot, params", hasrobot, params, caller=self)
     if hasrobot:
         ucount, uids = self.getSeatUserIds()
         mo = self.createMsgPackRequest("robotmgr")
         if params:
             mo.updateParam(params)
         mo.setAction('shutdown')
         mo.setParam('userCount', ucount)
         mo.setParam('seatCount', len(uids))
         mo.setParam('users', uids)
         router.sendRobotServer(mo, self.tableId)
示例#10
0
 def sendRobotNotifyCallUp(self, params):
     hasrobot = self.table.runConfig.get("hasrobot", 0)
     if ftlog.is_debug():
         ftlog.debug("|hasrobot, params", hasrobot, params, caller=self)
     if hasrobot:
         if params and params['test']:
             ucount, uids = 0, [0] * self.table.cMaxSeatNum
         else:
             ucount, uids = self.getSeatUserIds()
         mo = self.createMsgPackRequest("robotmgr")
         if params:
             mo.updateParam(params)
         mo.setAction('callup')
         mo.setParam('userCount', ucount)
         mo.setParam('seatCount', len(uids))
         mo.setParam('users', uids)
         router.sendRobotServer(mo, self.tableId)
示例#11
0
 def sendRobotNotifyCallUp(self, params):
     hasrobot = self.table.runConfig.get("hasrobot", 0)
     if ftlog.is_debug():
         ftlog.debug("|hasrobot, params", hasrobot, params, caller=self)
     if hasrobot:
         if params and params['test']:
             ucount, uids = 0, [0] * self.table.cMaxSeatNum
         else:
             ucount, uids = self.getSeatUserIds()
         mo = self.createMsgPackRequest("robotmgr")
         if params:
             mo.updateParam(params)
         mo.setAction('callup')
         mo.setParam('userCount', ucount)
         mo.setParam('seatCount', len(uids))
         mo.setParam('users', uids)
         router.sendRobotServer(mo, self.tableId)
示例#12
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)
示例#13
0
    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)