def powerTest(self, userId): ftlog.debug('MJAdmin.powerTest userId:', userId) roomId, checkResult = MajiangCreateTable._chooseCreateRoom( userId, GAMEID, 'queshou', 3) ftlog.debug('MajiangCreateTable._chooseCreateRoom roomId:', roomId, ' checkResult:', checkResult) msg = MsgPack() msg.setCmdAction("room", "create_table") msg.setParam("roomId", roomId) msg.setParam("gameId", GAMEID) msg.setParam("userId", userId) msg.setParam( "itemParams", { "sanQiBian": 1, "playerType": 3, "cardCount": 1, "chunJia": 0, "guaDaFeng": 0, "hongZhongBao": 0 }) msg.setParam('needFangka', 0) ftlog.debug( 'MajiangCreateTable._chooseCreateRoom send message to room:', msg) router.sendRoomServer(msg, roomId) return {'info': 'ok', 'code': 0}
def _sendWinloseToMatch(self, result): # 发送给match manager users = [] for sst in result.seatStatements: user = {} user['userId'] = sst.seat.userId user['deltaScore'] = sst.delta user['seatId'] = sst.seat.seatId user['isTuoguan'] = sst.seat.status.isTuoguan user[ 'winloseForTuoguanCount'] = sst.seat.player.winloseForTuoguanCount user['stageRewardTotal'] = sst.seat.player.stageRewardTotal users.append(user) mp = MsgPack() mp.setCmd('room') mp.setParam('action', 'm_winlose') mp.setParam('gameId', self.gameId) mp.setParam('matchId', self.room.bigmatchId) mp.setParam('roomId', self.room.ctrlRoomId) mp.setParam('tableId', self.tableId) mp.setParam('users', users) mp.setParam('ccrc', self.table.matchTableInfo['ccrc']) if ftlog.is_debug(): ftlog.debug('groupMatch._sendWinloseToMatch users=', users) if self.WINLOSE_SLEEP > 0: FTTasklet.getCurrentFTTasklet().sleepNb(self.WINLOSE_SLEEP) router.sendRoomServer(mp, self.room.ctrlRoomId)
def sendRoomLeaveReq(self, userId, reason, needSendRes=True): mpReqRoomLeave = self.createMsgPackRequest("room", "leave") mpReqRoomLeave.setParam("userId", userId) mpReqRoomLeave.setParam('roomId', self.table.room.ctrlRoomId) mpReqRoomLeave.setParam('reason', reason) mpReqRoomLeave.setParam('needSendRes', needSendRes) router.sendRoomServer(mpReqRoomLeave, self.table.room.ctrlRoomId)
def _sendWinloseToMatch(self, result): # 发送给match manager users = [] for sst in result.seatStatements: if not sst.seat.player.isAI: user = {} user['userId'] = sst.seat.userId user['deltaScore'] = sst.delta user['finalScore'] = sst.final user['seatId'] = sst.seat.seatId users.append(user) if ftlog.is_debug(): ftlog.debug( 'DizhuTableProtoGroupMatch._sendWinloseToMatch', 'userId=', sst.seat.userId, 'delta=', sst.delta, 'final=', sst.final, 'seatId=', sst.seat.seatId) mp = MsgPack() mp.setCmd('room') mp.setParam('action', 'm_winlose') mp.setParam('gameId', self.gameId) mp.setParam('matchId', self.room.bigmatchId) mp.setParam('roomId', self.room.ctrlRoomId) mp.setParam('tableId', self.tableId) mp.setParam('users', users) mp.setParam('ccrc', self.table.matchTableInfo['ccrc']) if self.WINLOSE_SLEEP > 0: FTTasklet.getCurrentFTTasklet().sleepNb(self.WINLOSE_SLEEP) router.sendRoomServer(mp, self.room.ctrlRoomId)
def _applyAdjustTablePlayers(self): '''向GR申请调整牌桌玩家''' if not self.gamePlay.isWaitingState(): self.gamePlay.transitToStateWait() mpReqRecycleTable = self.createMsgPackRequest("room", "adjust_table_players") mpReqRecycleTable.setParam("roomId", self.room.ctrlRoomId) mpReqRecycleTable.setParam("tableId", self.tableId) router.sendRoomServer(mpReqRecycleTable, self.room.ctrlRoomId)
def sendRoomQuickStartReq(cls, msg, roomId, tableId, **kwargs): msg.setCmd("room") msg.setParam("action", "quick_start") msg.setParam("roomId", roomId) msg.setParam("tableId", tableId) for key in kwargs: msg.setParam(key, kwargs[key]) if ftlog.is_debug(): ftlog.debug(msg, caller=cls) router.sendRoomServer(msg, roomId)
def powerTest(self, userId): ftlog.debug('MJAdmin.powerTest userId:', userId) roomId, checkResult = MajiangCreateTable._chooseCreateRoom(userId, GAMEID, 'luosihu', 3) ftlog.debug('MajiangCreateTable._chooseCreateRoom roomId:', roomId, ' checkResult:', checkResult) msg = MsgPack() msg.setCmdAction("room", "create_table") msg.setParam("roomId", roomId) msg.setParam("gameId", GAMEID) msg.setParam("userId", userId) msg.setParam("itemParams", {"sanQiBian":1,"playerType":3,"cardCount":1,"chunJia":0,"guaDaFeng":0,"hongZhongBao":0}) msg.setParam('needFangka', 0) ftlog.debug('MajiangCreateTable._chooseCreateRoom send message to room:', msg) router.sendRoomServer(msg, roomId) return {'info': 'ok', 'code': 0}
def doJoinCreateTable(self, userId, gameId, clientId, roomId0, tableId0, playMode): """用户加入自建牌桌 """ loc = onlinedata.checkUserLoc(userId, clientId, gameId) lgameId, lroomId, ltableId, lseatId = loc.split('.') lgameId, lroomId, ltableId, lseatId = strutil.parseInts( lgameId, lroomId, ltableId, lseatId) if lgameId > 0 and lroomId > 0 and ltableId > 0 and lseatId >= 0: ftlog.warn('create_table error, user in table') sendPopTipMsg(userId, "请稍候,正在进桌...") config = { "type": "quickstart", "pluginParams": { "roomId": lroomId, "tableId": ltableId, "seatId": lseatId } } todotask = TodoTaskEnterGameNew(lgameId, config) mo = MsgPack() mo.setCmd('todo_tasks') mo.setResult('gameId', gameId) mo.setResult('pluginId', lgameId) mo.setResult('userId', userId) mo.setResult('tasks', TodoTaskHelper.encodeTodoTasks(todotask)) router.sendToUser(mo, userId) else: msg = runcmd.getMsgPack() createTableNo = msg.getParam('createTableNo', 0) if not createTableNo: return tableId0, roomId0 = CreateTableData.getTableIdByCreateTableNo( createTableNo) if not tableId0 or not roomId0: sendPopTipMsg(userId, "找不到您输入的房间号") return msg = runcmd.getMsgPack() msg.setParam("shadowRoomId", roomId0) msg.setParam("roomId", roomId0) msg.setParam("tableId", tableId0) msg.setCmdAction("room", "join_create_table") router.sendRoomServer(msg, roomId0) if router.isQuery(): mo = runcmd.newOkMsgPack(1) router.responseQurery(mo, '', str(userId))
def doAwardCertificate(self, userId, gameId, match_id, clientId): ''' TCP 发送的至UTIL服务的quick_start暂时不能用lock userid的方式, 因为,消息流 CO->UT->GR->GT->UT会死锁 ''' msg = runcmd.getMsgPack() roomId = msg.getParam("roomId") ftlog.debug('doAwardCertificate', userId, gameId, roomId, match_id, caller=self) if len(str(roomId)) != 4 and len(str(roomId)) != 8 and len( str(roomId)) != 0: roomIdx = roomId roomId = roomId * 100 ftlog.info( "doAwardCertificate roomID error, from %d change to %d" % (roomIdx, roomId)) allrooms = gdata.roomIdDefineMap() ctrlRoomId = roomId if roomId in allrooms: roomDef = allrooms[roomId] if roomDef.parentId > 0: # this roomId is shadowRoomId ctrlRoomId = roomDef.parentId else: ftlog.warn("doAwardCertificate, error roomId", roomId) return ftlog.debug("ctrlRoomId:", ctrlRoomId) msg1 = MsgPack() msg1.setCmd('room') msg1.setParam('gameId', gameId) msg1.setParam('userId', userId) msg1.setParam('roomId', ctrlRoomId) msg1.setParam('action', "match_award_certificate") msg1.setParam('match_id', match_id) msg1.setParam('clientId', clientId) router.sendRoomServer(msg1, roomId) if router.isQuery(): mo = runcmd.newOkMsgPack(1) router.responseQurery(mo, '', str(userId))
def doJoinCreateTable(self, userId, gameId, clientId, roomId0, tableId0, playMode): """用户加入自建牌桌 """ loc = onlinedata.checkUserLoc(userId, clientId, gameId) lgameId, lroomId, ltableId, lseatId = loc.split('.') lgameId, lroomId, ltableId, lseatId = strutil.parseInts(lgameId, lroomId, ltableId, lseatId) if lgameId > 0 and lroomId > 0 and ltableId > 0 and lseatId >= 0: ftlog.warn('create_table error, user in table') sendPopTipMsg(userId, "请稍候,正在进桌...") config = { "type": "quickstart", "pluginParams": { "roomId": lroomId, "tableId": ltableId, "seatId": lseatId } } todotask = TodoTaskEnterGameNew(lgameId, config) mo = MsgPack() mo.setCmd('todo_tasks') mo.setResult('gameId', gameId) mo.setResult('pluginId', lgameId) mo.setResult('userId', userId) mo.setResult('tasks', TodoTaskHelper.encodeTodoTasks(todotask)) router.sendToUser(mo, userId) else: msg = runcmd.getMsgPack() createTableNo = msg.getParam('createTableNo', 0) if not createTableNo: return tableId0, roomId0 = CreateTableData.getTableIdByCreateTableNo(createTableNo) if not tableId0 or not roomId0: sendPopTipMsg(userId, "找不到您输入的房间号") return msg = runcmd.getMsgPack() msg.setParam("shadowRoomId", roomId0) msg.setParam("roomId", roomId0) msg.setParam("tableId", tableId0) msg.setCmdAction("room", "join_create_table") router.sendRoomServer(msg, roomId0) if router.isQuery(): mo = runcmd.newOkMsgPack(1) router.responseQurery(mo, '', str(userId))
def _leaveFromMatchs(userId): from dizhu.servers.util.rpc import match_remote from dizhu.servers.util.rpc.match_remote import UserMatchInfo userMatchInfoMap = match_remote.loadAllUserMatchInfo(DIZHU_GAMEID, userId) if ftlog.is_debug(): ftlog.debug('dizhuonlinedata._leaveFromMatchs userId=', userId, 'infos=', [(rid, umi.state) for rid, umi in userMatchInfoMap.iteritems()]) for _, userMatchInfo in userMatchInfoMap.iteritems(): if userMatchInfo.state == UserMatchInfo.ST_SIGNIN: msg = MsgPack() msg.setCmdAction('room', 'leave') msg.setParam('userId', userId) msg.setParam('roomId', userMatchInfo.ctrlRoomId) msg.setParam( 'gameId', strutil.getGameIdFromInstanceRoomId(userMatchInfo.ctrlRoomId)) msg.setParam('reason', TYRoom.LEAVE_ROOM_REASON_LOST_CONNECTION) router.sendRoomServer(msg, userMatchInfo.ctrlRoomId)
def _sendWinloseToMatch(self, result): # 发送给match manager seatWinloses = [] for sst in result.seatStatements: seatWinloses.append(sst.delta) mp = MsgPack() mp.setCmd('custom_match') mp.setParam('action', 'winlose') mp.setParam('gameId', self.gameId) mp.setParam('matchId', self.table.matchTableInfo['matchId']) mp.setParam('roomId', self.room.ctrlRoomId) mp.setParam('tableId', self.tableId) mp.setParam('seatWinloses', seatWinloses) mp.setParam('ccrc', self.table.matchTableInfo['ccrc']) if self.WINLOSE_SLEEP > 0: FTTasklet.getCurrentFTTasklet().sleepNb(self.WINLOSE_SLEEP) router.sendRoomServer(mp, self.room.ctrlRoomId)
def doAwardCertificate(self, userId, gameId, match_id, clientId): ''' TCP 发送的至UTIL服务的quick_start暂时不能用lock userid的方式, 因为,消息流 CO->UT->GR->GT->UT会死锁 ''' msg = runcmd.getMsgPack() roomId = msg.getParam("roomId") ftlog.debug('doAwardCertificate', userId, gameId, roomId, match_id, caller=self) if len(str(roomId)) != 4 and len(str(roomId)) != 8 and len(str(roomId)) != 0: roomIdx = roomId roomId = roomId * 100 ftlog.info("doAwardCertificate roomID error, from %d change to %d" % (roomIdx, roomId)) allrooms = gdata.roomIdDefineMap() ctrlRoomId = roomId if roomId in allrooms: roomDef = allrooms[roomId] if roomDef.parentId > 0: # this roomId is shadowRoomId ctrlRoomId = roomDef.parentId else: ftlog.warn("doAwardCertificate, error roomId", roomId) return ftlog.debug("ctrlRoomId:", ctrlRoomId) msg1 = MsgPack() msg1.setCmd('room') msg1.setParam('gameId', gameId) msg1.setParam('userId', userId) msg1.setParam('roomId', ctrlRoomId) msg1.setParam('action', "match_award_certificate") msg1.setParam('match_id', match_id) msg1.setParam('clientId', clientId) router.sendRoomServer(msg1, roomId) if router.isQuery(): mo = runcmd.newOkMsgPack(1) router.responseQurery(mo, '', str(userId))
def doUserOffline(self, userId, clientId): evt = OnLineTcpChangedEvent(userId, HALL_GAMEID, 0) TGHall.getEventBus().publishEvent(evt) # 补发room_leave消息 olist = onlinedata.getOnlineLocList(userId) ftlog.debug('doUserOffline onlines->', olist) for ol in olist: roomId, _, _ = ol[0], ol[1], ol[2] if roomId > 0: msg = MsgPack() msg.setCmdAction('room', 'leave') msg.setParam('userId', userId) msg.setParam('roomId', roomId) msg.setParam('gameId', strutil.getGameIdFromInstanceRoomId(roomId)) msg.setParam('clientId', clientId) msg.setParam('reason', TYRoom.LEAVE_ROOM_REASON_LOST_CONNECTION) router.sendRoomServer(msg, roomId) # offline_geoc处理 onlinedata.setUserGeoOffline(userId, HALL_GAMEID) # 通知push服务 self._notifyPushUserOnlineStateChanged(userId, 0, clientId)
def doWinLose(cls, room, table, seatId, isTimeOutKill=False): # TODO: # 计算春天 dizhuseatId = table.status.diZhu if seatId != dizhuseatId: if table.seats[dizhuseatId - 1].outCardCount == 1: table.status.chuntian = 2 else: s1 = table.seats[(dizhuseatId - 1 + 1) % table.maxSeatN] s2 = table.seats[(dizhuseatId - 1 + 2) % table.maxSeatN] if s1.outCardCount == 0 and s2.outCardCount == 0: table.status.chuntian = 2 # 翻倍计算 叫地主的倍数 windoubles = table.status.callGrade # 炸弹倍数 windoubles *= pow(2, table.status.bomb) # 春天倍数 windoubles *= table.status.chuntian # 底牌倍数 windoubles *= table.status.baseCardMulti # 明牌倍数 windoubles *= table.status.show dizhuwin = 0 if seatId == dizhuseatId: dizhuwin = 1 if seatId == 0 : # 流局 dizhuwin = 0 windoubles = 1 else: windoubles = abs(windoubles) userids = [] detalChips = [] seat_coin = [] baseBetChip = table._match_table_info['baseChip'] robot_card_count = [0] * len(table.seats) # 每个座位 for x in xrange(len(table.seats)): uid = table.seats[x].userId userInfo = table._match_table_info['users'][x] userids.append(uid) if seatId == 0 : # 流局 detalChip = -baseBetChip else: if dizhuwin : if x + 1 == dizhuseatId : detalChip = baseBetChip + baseBetChip else: detalChip = -baseBetChip else: if x + 1 == dizhuseatId : detalChip = -baseBetChip - baseBetChip else: detalChip = baseBetChip detalChip *= windoubles detalChips.append(detalChip) seat_coin.append(userInfo['score'] + detalChip) robot_card_count[x] = table.seats[x].robotCardCount ftlog.info('dizhu.game_win userId=', uid, 'roomId=', room.roomId, 'tableId=', table.tableId, 'delta=', detalChip) ftlog.debug('doWinLose->after room fee->robot_card_count=', robot_card_count) punish.Punish.doWinLosePunish(table.runConfig.punishCardCount, table.runConfig.isMatch, seat_coin, detalChips, robot_card_count) for x in xrange(len(table.seats)): uid = table.seats[x].userId userInfo = table._match_table_info['users'][x] userInfo['score'] = seat_coin[x] # 返回当前Table的game_win moWin = MsgPack() moWin.setCmd('table_call') moWin.setResult('action', 'game_win') moWin.setResult('isMatch', 1) moWin.setResult('gameId', table.gameId) moWin.setResult('roomId', table.roomId) moWin.setResult('tableId', table.tableId) moWin.setResult('stat', table.status.toInfoDictExt()) moWin.setResult('dizhuwin', dizhuwin) if seatId == 0: moWin.setResult('nowin', 1) moWin.setResult('slam', 0) moWin.setResult('cards', [seat.cards for seat in table.seats]) roundId = table.gameRound.number table.clear(userids) for x in xrange(len(userids)): uid = userids[x] mrank = 3 mtableRanking = 3 moWin.setResult('seat' + str(x + 1), [detalChips[x], seat_coin[x], 0, 0, 0, 0, mrank, mtableRanking]) #增加经验 exp = userdata.incrExp(uid, 20) explevel = dizhuaccount.getExpLevel(exp) gamedata.setGameAttr(uid, table.gameId, 'level', explevel) ftlog.debug('AsyncUpgradeHeroMatch.doWinLoseTable add 20 exp, tootle', exp, 'level', explevel) table.gamePlay.sender.sendToAllTableUser(moWin) # 发送给match manager users = [] for x in xrange(len(userids)): user = {} user['userId'] = userids[x] user['deltaScore'] = int(detalChips[x]) user['seatId'] = x + 1 user['score'] = seat_coin[x] users.append(user) mnr_msg = MsgPack() mnr_msg.setCmd('room') mnr_msg.setParam('action', 'm_winlose') mnr_msg.setParam('gameId', table.gameId) mnr_msg.setParam('roomId', table.room.ctrlRoomId) mnr_msg.setParam('tableId', table.tableId) mnr_msg.setParam('users', users) # 记录游戏winlose try: for u in users: table.room.reportBiGameEvent("TABLE_WIN", u['userId'], table.roomId, table.tableId, roundId, u['deltaScore'], 0, 0, [], 'table_win') # cls.report_bi_game_event(TyContext.BIEventId.TABLE_WIN, u['userId'], table._rid, table._id, table._roundId, u['deltaScore'], 0, 0, [], 'table_win') except: if ftlog.is_debug(): ftlog.exception() router.sendRoomServer(mnr_msg, table.room.ctrlRoomId)
onlinedata.cleanOnlineLoc(userId) userdata.setSessionData(userId, {"ci": "robot_3.7_-hall6-robot"}) luckyValue = random.randint(1, 10000) rankArr = [] for _ in xrange(5): rankArr.append(random.randint(0,50)) gamedata.setGameAttrs(userId, 44, ["level", "gunSkinId", "userGuideStep","m.44101"], [1, 0, json.dumps([1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2200, 2300]), json.dumps({"bestRank": 1, "bestRankDate": 1523956838, "isGroup": 0, "crownCount": 4, "playCount": 4, "luckyValue": luckyValue, "recentRank": rankArr})]) mo = MsgPack() mo.setCmd("room") mo.setParam("action", "signin") mo.setParam("userId", userId) mo.setParam("gameId", 44) mo.setParam("roomId", roomId) mo.setParam("clientId", "robot_3.7_-hall6-robot") router.sendRoomServer(mo, roomId) mo.setParam("action", "enter") router.sendRoomServer(mo, roomId) # 机器人参加比赛 # 50%概率捕获,SERVERIDS填写:GT0044001_999 from newfish.table.table_base import FishTable from newfish.table.multiple_table import FishMultipleTable def getCatchProbb(self, player, wpConf, fId, fIdsCount=1, superBullet=None, extendId=0, aloofOdds=0, nonAloofOdds=0, stageId=0, datas=None): # 以下注释打开即为正常概率 # return self._getCatchProbb(player, wpConf, fId, fIdsCount, superBullet, extendId, aloofOdds, nonAloofOdds, stageId, datas) return 5000 FishTable.getCatchProbb = getCatchProbb
def _quickStart(cls, msg, userId, gameId, roomId, tableId, playMode, clientId): '''UT server中处理来自客户端的quick_start请求 Args: msg cmd : quick_start if roomId == 0: 表示快速开始,服务器为玩家选择房间,然后将请求转给GR if roomId > 0 and tableId == 0 : 表示玩家选择了房间,将请求转给GR if roomId > 0 and tableId == roomId * 10000 : 表示玩家在队列里断线重连,将请求转给GR if roomId > 0 and tableId > 0: if onlineSeatId > 0: 表示玩家在牌桌里断线重连,将请求转给GT else: 表示玩家选择了桌子,将请求转给GR ''' assert isinstance(userId, int) and userId > 0 assert isinstance(roomId, int) and roomId >= 0 assert isinstance(tableId, int) and tableId >= 0 mixId = msg.getParam('mixId', '') _, version, _ = strutil.parseClientId(clientId) if ftlog.is_debug(): ftlog.debug("DizhuQuickStart._quickStart: clientId=", clientId, "userId=", userId, "roomId=", roomId, "tableId=", tableId, "mixId=", mixId, "version=", version, "type:", type(version), "playMode=", playMode) if playMode == "match": playMode = dizhuconf.PLAYMODE_123 if ftlog.is_debug(): ftlog.debug("DizhuQuickStart << |clientId:", clientId, "mixId:", mixId, "|userId, roomId, tableId:", userId, roomId, tableId, "|gameId, playMode:", gameId, playMode, caller=cls) bigRoomId = gdata.getBigRoomId(roomId) if ftlog.is_debug(): ftlog.debug('DizhuQuickStart bigRoomId:', bigRoomId) if bigRoomId == 0: cls._onEnterRoomFailed(msg, ENTER_ROOM_REASON_ROOM_ID_ERROR, userId, clientId, roomId) return if strutil.getGameIdFromBigRoomId(bigRoomId) != gameId: cls._onEnterRoomFailed(msg, ENTER_ROOM_REASON_ROOM_ID_ERROR, userId, clientId, roomId) return if tableId == 0: # 玩家只选择了房间 if roomId != bigRoomId: ctrlRoomId = gdata.roomIdDefineMap()[roomId].parentId or roomId queryRoomId = roomId else: ctrRoomIds = gdata.bigRoomidsMap()[bigRoomId] ctrlRoomId = ctrRoomIds[userId % len(ctrRoomIds)] queryRoomId = ctrlRoomId buyin = msg.getParam("buyin", 0) # 兼容 pc innerTable = msg.getParam("innerTable", 0) # innerTable 区分不同版本弹窗 if ftlog.is_debug(): ftlog.debug('DizhuQuickStart._quickStart', 'buyin=', buyin, 'innerTable=', innerTable, 'mixId=', mixId) if buyin: innerTable = 1 roomdef = gdata.roomIdDefineMap()[ctrlRoomId] roomConf = roomdef.configure # 免费场重起maxCoin配置 maxCoin = roomConf.get('maxCoin', 0) userChip = userchip.getChip(userId) if maxCoin > 0 and userChip >= maxCoin and innerTable == 0: cls._onEnterRoomFailed(msg, ENTER_ROOM_REASON_GREATER_MAX, userId, clientId, roomId) return # 混房的话从大到小选择一个mixId if roomConf.get('isMix') and not mixId: _, _, mixId = cls._chooseRoom(userId, [ctrlRoomId]) if mixId: msg.setParam('mixId', mixId) else: msg.setParam('mixId', roomConf.get('mixConf')[0].get('mixId')) if innerTable == 0: cls._onEnterRoomFailed(msg, ENTER_ROOM_REASON_LESS_MIN, userId, clientId, roomId) else: mixConf = cls.getMixConf( roomConf, roomConf.get('mixConf')[0].get('mixId')) new_table_remote.processLoseRoundOver( DIZHU_GAMEID, userId, clientId, mixConf.get('roomId'), minCoin=mixConf.get('minCoin')) return reasonType, reason = cls._canQuickEnterRoom(userId, ctrlRoomId, innerTable, mixId) if reason == ENTER_ROOM_REASON_OK: TYRoomMixin.queryRoomQuickStartReq(msg, queryRoomId, 0) # 请求转给GR或GT else: if reasonType == ENTER_ROOM_REASON_TYPE_NORMAL: if reason == ENTER_ROOM_REASON_NOT_OPEN and innerTable == 1: if ftlog.is_debug(): ftlog.debug( 'DizhuQuickStart._quickStart not open userId=', userId, 'roomId=', ctrlRoomId, 'msg=', msg, 'playmode=', playMode) # 直接踢出房间 mp = MsgPack() mp.setCmd('room') mp.setParam('action', 'leave') mp.setParam('reason', TYRoom.LEAVE_ROOM_REASON_ACTIVE) mp.setParam('gameId', gameId) mp.setParam('roomId', roomId) mp.setParam('userId', userId) router.sendRoomServer(mp, roomId) return if reason == ENTER_ROOM_REASON_LESS_MIN or reason == ENTER_ROOM_REASON_GREATER_MAX: if innerTable == 1: ctrRoomIds = gdata.bigRoomidsMap()[bigRoomId] ctrlRoomId = ctrRoomIds[userId % len(ctrRoomIds)] if roomdef.configure.get('isMix', 0): continueLuckyGift = cls.getMixConf( roomdef.configure, mixId).get('continueLuckyGift', 0) continueLuckyVer = cls.getMixConf( roomdef.configure, mixId).get('continueLuckyVer', 0) else: continueLuckyGift = roomdef.configure.get( 'continueLuckyGift', 0) continueLuckyVer = roomdef.configure.get( 'continueLuckyVer', 0) dizhuVersion = SessionDizhuVersion.getVersionNumber( userId) if continueLuckyGift and dizhuVersion >= continueLuckyVer: # 发送转运礼包 if ftlog.is_debug(): ftlog.debug( 'DizhuQuickStart._quickStart _less_min userId=', userId, 'roomId=', ctrlRoomId, 'msg=', msg, 'playmode=', playMode, 'continueLuckyGift=', continueLuckyGift, 'continueLuckyVer=', continueLuckyVer, 'dizhuVersion=', dizhuVersion) if mixId and roomConf.get('isMix'): mixConf = cls.getMixConf(roomConf, mixId) new_table_remote.processLoseRoundOver( DIZHU_GAMEID, userId, clientId, mixConf.get('roomId'), minCoin=mixConf.get('minCoin')) else: new_table_remote.processLoseRoundOver( DIZHU_GAMEID, userId, clientId, roomId) else: roomDef = gdata.roomIdDefineMap()[ctrlRoomId] playMode = roomDef.configure.get('playMode', None) if ftlog.is_debug(): ftlog.debug( 'DizhuQuickStart._quickStart _less_min userId=', userId, 'roomId=', ctrlRoomId, 'msg=', msg, 'playmode=', playMode) msgpack = MsgPack() msgpack.setCmd("quick_start") msgpack.setParam("userId", userId) msgpack.setParam("gameId", gameId) msgpack.setParam("clientId", clientId) msgpack.setParam("innerTable", 1) msgpack.setParam("apiver", msg.getParam("apiver", 3.7)) cls.onCmdQuickStart(msgpack, userId, gameId, 0, 0, playMode, clientId) if ftlog.is_debug(): ftlog.debug( 'DizhuQuickStart._quickStart reenter_less_min userId=', userId, 'roomId=', ctrlRoomId, 'msgpack=', msgpack.pack()) else: cls._onEnterRoomFailed(msg, reason, userId, clientId, roomId) else: cls._onEnterRoomFailed(msg, reason, userId, clientId, roomId) else: cls._sendTodoTaskToUserWithTip(userId, reason) return if tableId == roomId * 10000: # 玩家在队列里断线重连 TYRoomMixin.queryRoomQuickStartReq(msg, roomId, tableId) # 请求转给GR return onlineSeat = onlinedata.getOnlineLocSeatId(userId, roomId, tableId) if onlineSeat: # 牌桌里坐着的玩家断线重连,请求转给GT # TYRoomMixin.querySitReq(userId, roomId, tableId, clientId) # GT人多时会有超时异常 TYRoomMixin.sendSitReq(userId, roomId, tableId, clientId) else: # 玩家选择了桌子, shadowRoomId = tableId / 10000 ctrRoomId = gdata.roomIdDefineMap()[shadowRoomId].parentId TYRoomMixin.queryRoomQuickStartReq(msg, ctrRoomId, tableId, shadowRoomId=shadowRoomId) # 请求转给GR return
def doWinLose(cls, room, table, seatId, isTimeOutKill=False): # TODO: if not table._match_table_info: ftlog.warn('GroupMatch.doWinLoseTable roomId=', room.roomId, 'tableId=', table.tableId, 'seatId=', seatId, 'isTimeOutKill=', isTimeOutKill, 'err=', 'not matchTableInfo') return if ftlog.is_debug(): ftlog.debug('GroupMatch.doWinLose roomId=', room.roomId, 'tableId=', table.tableId, 'seatId=', seatId, 'isTimeOutKill=', isTimeOutKill, 'stageReward=', table.group.stageConf.conf.get('stageReward')) # 计算春天 dizhuseatId = table.status.diZhu if seatId != dizhuseatId: if table.seats[dizhuseatId - 1].outCardCount == 1: table.status.chuntian = 2 else: s1 = table.seats[(dizhuseatId - 1 + 1) % table.maxSeatN] s2 = table.seats[(dizhuseatId - 1 + 2) % table.maxSeatN] if s1.outCardCount == 0 and s2.outCardCount == 0: table.status.chuntian = 2 # 翻倍计算 叫地主的倍数 windoubles = table.status.callGrade # 炸弹倍数 windoubles *= pow(2, table.status.bomb) # 春天倍数 windoubles *= table.status.chuntian # 底牌倍数 windoubles *= table.status.baseCardMulti # 明牌倍数 windoubles *= table.status.show dizhuwin = 0 if seatId == dizhuseatId: dizhuwin = 1 if seatId == 0 : # 流局 dizhuwin = 0 windoubles = 1 else: windoubles = abs(windoubles) userids = [] detalChips = [] seat_coin = [] baseBetChip = table._match_table_info['mInfos']['basescore'] robot_card_count = [0] * len(table.seats) # 每个座位 for x in xrange(len(table.seats)): uid = table.seats[x].userId userids.append(uid) if seatId == 0 : # 流局 detalChip = -baseBetChip else: if dizhuwin : if x + 1 == dizhuseatId : detalChip = baseBetChip + baseBetChip else: detalChip = -baseBetChip else: if x + 1 == dizhuseatId : detalChip = -baseBetChip - baseBetChip else: detalChip = baseBetChip detalChip *= windoubles detalChips.append(detalChip) seat_coin.append(table._match_table_info['mInfos']['scores'][x] + detalChip) robot_card_count[x] = table.seats[x].robotCardCount ftlog.info('dizhu.game_win userId=', uid, 'roomId=', room.roomId, 'tableId=', table.tableId, 'delta=', detalChip) punish.Punish.doWinLosePunish(table.runConfig.punishCardCount, table.runConfig.isMatch, seat_coin, detalChips, robot_card_count) for x in xrange(len(table.seats)): uid = table.seats[x].userId table._match_table_info['mInfos']['scores'][x] = seat_coin[x] # 返回当前Table的game_win moWin = MsgPack() moWin.setCmd('table_call') moWin.setResult('action', 'game_win') moWin.setResult('isMatch', 1) moWin.setResult('gameId', table.gameId) moWin.setResult('roomId', table.roomId) moWin.setResult('tableId', table.tableId) # moWin.setResult('stat', dict(zip(tdz_stat_title, table.status))) moWin.setResult('stat', table.status.toInfoDictExt()) moWin.setResult('dizhuwin', dizhuwin) if seatId == 0: moWin.setResult('nowin', 1) moWin.setResult('slam', 0) moWin.setResult('cards', [seat.cards for seat in table.seats]) roundId = table.gameRound.number table.clear(userids) for x in xrange(len(userids)): uid = userids[x] mrank = 3 mtableRanking = 3 moWin.setResult('seat' + str(x + 1), [detalChips[x], seat_coin[x], 0, 0, 0, 0, mrank, mtableRanking]) if detalChips[x] > 0: stageRewards = table.group.stageConf.conf.get('stageReward', None) if table.group.stageConf else None if stageRewards: contentItems = TYContentItem.decodeList(stageRewards) assetList = dizhu_util.sendRewardItems(uid, contentItems, '', 'DIZHU_STAGE_REWARD', 0) moWin.setResult('stageReward', stageRewards) ftlog.info('stageRewards send. userId=', uid, 'stageRewards=', stageRewards, 'assetList=', assetList) #增加经验 exp = userdata.incrExp(uid, 20) explevel = dizhuaccount.getExpLevel(exp) gamedata.setGameAttr(uid, table.gameId, 'level', explevel) if ftlog.is_debug(): ftlog.debug('BigMatch.doWinLoseTable', 'addExp=', 20, 'curExp=', exp, 'curLevel=', explevel) table.gamePlay.sender.sendToAllTableUser(moWin) # 发送给match manager users = [] for x in xrange(len(userids)): user = {} user['userId'] = userids[x] user['deltaScore'] = int(detalChips[x]) user['seatId'] = x + 1 users.append(user) mnr_msg = MsgPack() mnr_msg.setCmd('room') mnr_msg.setParam('action', 'm_winlose') mnr_msg.setParam('gameId', table.gameId) mnr_msg.setParam('matchId', table.room.bigmatchId) mnr_msg.setParam('roomId', table.room.ctrlRoomId) mnr_msg.setParam('tableId', table.tableId) mnr_msg.setParam('users', users) mnr_msg.setParam('ccrc', table._match_table_info['ccrc']) if cls.WINLOSE_SLEEP > 0: FTTasklet.getCurrentFTTasklet().sleepNb(cls.WINLOSE_SLEEP) # 记录游戏winlose try: for u in users: table.room.reportBiGameEvent('TABLE_WIN', u['userId'], table.roomId, table.tableId, roundId, u['deltaScore'], 0, 0, [], 'table_win') except: if ftlog.is_debug(): ftlog.exception() router.sendRoomServer(mnr_msg, table.room.ctrlRoomId)
def doWinLose(cls, room, table, seatId, isTimeOutKill=False): # TODO: if not table._match_table_info: ftlog.warn('BigMatch.doWinLoseTable roomId=', room.roomId, 'tableId=', table.tableId, 'seatId=', seatId, 'isTimeOutKill=', isTimeOutKill, 'not matchTableInfo') return # 计算春天 dizhuseatId = table.status.diZhu if seatId != dizhuseatId: if table.seats[dizhuseatId - 1].outCardCount == 1: table.status.chuntian = 2 else: s1 = table.seats[(dizhuseatId - 1 + 1) % table.maxSeatN] s2 = table.seats[(dizhuseatId - 1 + 2) % table.maxSeatN] if s1.outCardCount == 0 and s2.outCardCount == 0: table.status.chuntian = 2 # 翻倍计算 叫地主的倍数 windoubles = table.status.callGrade # 炸弹倍数 windoubles *= pow(2, table.status.bomb) # 春天倍数 windoubles *= table.status.chuntian # 底牌倍数 windoubles *= table.status.baseCardMulti # 明牌倍数 windoubles *= table.status.show dizhuwin = 0 if seatId == dizhuseatId: dizhuwin = 1 if seatId == 0: # 流局 dizhuwin = 0 windoubles = 1 else: windoubles = abs(windoubles) # matchlog('Match->doWinLose dizhuwin=', dizhuwin , 'dizhuseatId=', dizhuseatId, 'windoubles=', windoubles) userids = [] detalChips = [] seat_coin = [] baseBetChip = table._match_table_info['mInfos']['basescore'] robot_card_count = [0] * len(table.seats) # 每个座位 for x in xrange(len(table.seats)): uid = table.seats[x].userId userids.append(uid) if seatId == 0: # 流局 detalChip = -baseBetChip else: if dizhuwin: if x + 1 == dizhuseatId: detalChip = baseBetChip + baseBetChip else: detalChip = -baseBetChip else: if x + 1 == dizhuseatId: detalChip = -baseBetChip - baseBetChip else: detalChip = baseBetChip detalChip *= windoubles detalChips.append(detalChip) seat_coin.append(table._match_table_info['mInfos']['scores'][x] + detalChip) robot_card_count[x] = table.seats[x].robotCardCount ftlog.info('dizhu.game_win userId=', uid, 'roomId=', room.roomId, 'tableId=', table.tableId, 'delta=', detalChip) ftlog.debug('doWinLose->after room fee->robot_card_count=', robot_card_count) # table.punishClass().doWinLosePunish(table, seat_coin, detalChips) punish.Punish.doWinLosePunish(table.runConfig.punishCardCount, table.runConfig.isMatch, seat_coin, detalChips, robot_card_count) for x in xrange(len(table.seats)): uid = table.seats[x].userId table._match_table_info['mInfos']['scores'][x] = seat_coin[x] # 返回当前Table的game_win moWin = MsgPack() moWin.setCmd('table_call') moWin.setResult('action', 'game_win') moWin.setResult('isMatch', 1) moWin.setResult('gameId', table.gameId) moWin.setResult('roomId', table.roomId) moWin.setResult('tableId', table.tableId) # moWin.setResult('stat', dict(zip(tdz_stat_title, table.status))) moWin.setResult('stat', table.status.toInfoDictExt()) moWin.setResult('dizhuwin', dizhuwin) if seatId == 0: moWin.setResult('nowin', 1) moWin.setResult('slam', 0) moWin.setResult('cards', [seat.cards for seat in table.seats]) roundId = table.gameRound.number table.clear(userids) for x in xrange(len(table.seats)): uid = table.seats[x].userId mrank = 3 mtableRanking = 3 moWin.setResult('seat' + str(x + 1), [ detalChips[x], seat_coin[x], 0, 0, 0, 0, mrank, mtableRanking ]) #增加经验 exp = userdata.incrExp(uid, 20) explevel = dizhuaccount.getExpLevel(exp) gamedata.setGameAttr(uid, table.gameId, 'level', explevel) ftlog.debug('BigMatch.doWinLoseTable add 20 exp, tootle', exp, 'level', explevel) # nhWin = [] # table.makeBroadCastUsers(nhWin) # tasklet.sendUdpToMainServer(moWin, nhWin) table.gamePlay.sender.sendToAllTableUser(moWin) # 发送给match manager users = [] for x in xrange(len(table.seats)): user = {} user['userId'] = table.seats[x].userId user['deltaScore'] = int(detalChips[x]) user['seatId'] = x + 1 users.append(user) mnr_msg = MsgPack() mnr_msg.setCmd('room') mnr_msg.setParam('action', 'm_winlose') mnr_msg.setParam('gameId', table.gameId) mnr_msg.setParam('matchId', table.room.bigmatchId) mnr_msg.setParam('roomId', table.room.ctrlRoomId) mnr_msg.setParam('tableId', table.tableId) mnr_msg.setParam('users', users) mnr_msg.setParam('ccrc', table._match_table_info['ccrc']) if cls.WINLOSE_SLEEP > 0: FTTasklet.getCurrentFTTasklet().sleepNb(cls.WINLOSE_SLEEP) # 记录游戏winlose try: for u in users: table.room.reportBiGameEvent("TABLE_WIN", u['userId'], table.roomId, table.tableId, roundId, u['deltaScore'], 0, 0, [], 'table_win') # cls.report_bi_game_event(TyContext.BIEventId.TABLE_WIN, u['userId'], table._rid, table._id, table._roundId, u['deltaScore'], 0, 0, [], 'table_win') except: if ftlog.is_debug(): ftlog.exception() # serverids = tasklet.gdata.map_room_servers[table.room.bigmatchId] # mainClient = tasklet.gdata.clientmap[serverids[0]] # mainClient.sendMessage2(None, mnr_msg.pack()) router.sendRoomServer(mnr_msg, table.room.ctrlRoomId)
def doCreateTable(self, userId, gameId, clientId, roomId0, tableId0, playMode, hasRobot=0): #临时硬编码,解决91晃晃提审问题 if gameId == 791 and playMode == "queshou-lianjiang" and clientId == "IOS_3.901_weixin.appStore,weixinPay.0-hall791.queshou.iostsljmj": hasRobot = 1 if gameId == 790 and playMode == 'luosihu-luosihuts' and clientId == "IOS_3.901_weixin.appStore,weixinPay.0-hall790.laodao.iostsxjmj": hasRobot = 1 """房主创建牌桌""" if not playMode: ftlog.error( 'game_handler, cat not create table without playMode...') loc = onlinedata.checkUserLoc(userId, clientId, gameId) lgameId, lroomId, ltableId, lseatId = loc.split('.') lgameId, lroomId, ltableId, lseatId = strutil.parseInts( lgameId, lroomId, ltableId, lseatId) if lgameId > 0 and lroomId > 0 and ltableId > 0 and lseatId >= 0: ftlog.warn('create_table error, user in table', lgameId, lroomId, ltableId, lseatId) sendPopTipMsg(userId, "请稍候,正在进桌...") config = { "type": "quickstart", "pluginParams": { "roomId": lroomId, "tableId": ltableId, "seatId": lseatId } } todotask = TodoTaskEnterGameNew(lgameId, config) mo = MsgPack() mo.setCmd('todo_tasks') mo.setResult('gameId', gameId) mo.setResult('pluginId', lgameId) mo.setResult('userId', userId) mo.setResult('tasks', TodoTaskHelper.encodeTodoTasks(todotask)) router.sendToUser(mo, userId) elif self._canEnterGame(userId, gameId): # 保存建桌时间戳 gamedata.setGameAttr(userId, gameId, 'createTableTime', pktimestamp.getCurrentTimestamp()) msg = runcmd.getMsgPack() itemParams = msg.getParam("itemParams") playerCount = 4 playerTypeId = itemParams.get(MFTDefine.PLAYER_TYPE, 1) playerTypeConfig = majiang_conf.getCreateTableConfig( gameId, playMode, MFTDefine.PLAYER_TYPE, playerTypeId) if not playerTypeConfig: sendPopTipMsg(userId, '人数配置有误,请稍后重试') return playerCount = playerTypeConfig.get('count', 4) ftlog.debug('MajiangCreateTable.create_table playerCount:', playerCount) cardCountKey = playerTypeConfig.get(MFTDefine.CARD_COUNT, MFTDefine.CARD_COUNT) cardCountId = itemParams.get(cardCountKey, 0) cardCountConfig = majiang_conf.getCreateTableConfig( gameId, playMode, cardCountKey, cardCountId) if not cardCountConfig: sendPopTipMsg(userId, '房卡配置有误,请稍后重试') return if hasRobot == 1 and 'hasRobot' in cardCountConfig: cardCountConfig = cardCountConfig.get('hasRobot', {}) ftlog.debug('MajiangCreateTable.create_table hasRobot == 1:') fangka_count = cardCountConfig.get('fangka_count', 1) ftlog.debug('MajiangCreateTable.create_table fangka_count:', fangka_count, ' cardCountConfig:', cardCountConfig) msg.setParam('isCreateTable', 1) #标记创建的桌子是 自建桌 from poker.entity.game.rooms.room import TYRoom ''' 根据五个因素筛选合适的房间 1)gameId 游戏ID 2)playMode 游戏玩法 3)playerCount 玩家个数 4)hasRobot 是否有机器人 5)itemId 房卡道具 ''' itemId = hall_fangka.queryFangKaItem(gameId, userId, clientId) if itemId: ftlog.debug( 'MajiangCreateTable._chooseCreateRoom fangKa itemId:', itemId) roomId, checkResult = MajiangCreateTable._chooseCreateRoom( userId, gameId, playMode, playerCount, hasRobot, itemId) ftlog.debug('MajiangCreateTable._chooseCreateRoom roomId:', roomId, ' checkResult:', checkResult) if checkResult == TYRoom.ENTER_ROOM_REASON_OK: msg = runcmd.getMsgPack() msg.setCmdAction("room", "create_table") msg.setParam("roomId", roomId) msg.setParam("itemParams", itemParams) msg.setParam('needFangka', fangka_count) ftlog.debug( 'MajiangCreateTable._chooseCreateRoom send message to room:', msg) router.sendRoomServer(msg, roomId) else: sendPopTipMsg(userId, "暂时无法创建请稍后重试") if router.isQuery(): mo = runcmd.newOkMsgPack(1) router.responseQurery(mo, '', str(userId)) else: ftlog.info('majiang2 game_handler, ignore enter game request...')
def doWinLose(cls, room, table, seatId, isTimeOutKill=False): if not table._match_table_info: ftlog.warn('ErdayiMatch.doWinLoseTable roomId=', room.roomId, 'tableId=', table.tableId, 'seatId=', seatId, 'isTimeOutKill=', isTimeOutKill, 'err=', 'not matchTableInfo') return # 计算春天 dizhuseatId = table.status.diZhu if seatId != dizhuseatId: if table.seats[dizhuseatId - 1].outCardCount == 1: table.status.chuntian = 2 else: s1 = table.seats[(dizhuseatId - 1 + 1) % table.maxSeatN] s2 = table.seats[(dizhuseatId - 1 + 2) % table.maxSeatN] if s1.outCardCount == 0 and s2.outCardCount == 0: table.status.chuntian = 2 # 翻倍计算 叫地主的倍数 windoubles = table.status.callGrade # 炸弹倍数 windoubles *= pow(2, table.status.bomb) # 春天倍数 windoubles *= table.status.chuntian # 底牌倍数 windoubles *= table.status.baseCardMulti # 明牌倍数 windoubles *= table.status.show dizhuwin = 0 if seatId == dizhuseatId: dizhuwin = 1 if seatId == 0: # 流局 dizhuwin = 0 windoubles = 1 else: windoubles = abs(windoubles) userids = [seat.userId for seat in table.seats] seat_coin = [0] * len(table.seats) detalChips = [0] * len(table.seats) baseBetChip = table._match_table_info['step']['basescore'] robot_card_count = [0] * len(table.seats) # 每个座位 # 计算所有农民的输赢 for i, player in enumerate(table.players): userids.append(player.userId) if seatId == 0: detalChips[i] = -baseBetChip if i + 1 == dizhuseatId: continue detalChip = baseBetChip * windoubles # 计算本农民的倍数 seatMulti = max(table.seats[i].seatMulti, 1) * max( table.seats[dizhuseatId - 1].seatMulti, 1) detalChip *= seatMulti if dizhuwin: detalChip *= -1 detalChips[i] = detalChip detalChips[dizhuseatId - 1] -= detalChip if ftlog.is_debug(): ftlog.debug('ErdayiMatch.doWinLoseTable roomId=', room.roomId, 'tableId=', table.tableId, 'seatId=', seatId, 'dizhuseatId=', dizhuseatId, 'detalChip=', detalChip, 'dizhuDetalChip=', detalChips[dizhuseatId - 1]) punish.Punish.doWinLosePunish(table.runConfig.punishCardCount, table.runConfig.isMatch, seat_coin, detalChips, robot_card_count) seat_coin = [0] * len(table.seats) for i, seatInfo in enumerate(table._match_table_info['seats']): seat_coin[i] = seatInfo['score'] # 返回当前Table的game_win moWin = MsgPack() moWin.setCmd('table_call') moWin.setResult('action', 'game_win') moWin.setResult('isMatch', 1) moWin.setResult('gameId', table.gameId) moWin.setResult('roomId', table.roomId) moWin.setResult('tableId', table.tableId) # moWin.setResult('stat', dict(zip(tdz_stat_title, table.status))) moWin.setResult('stat', table.status.toInfoDictExt()) moWin.setResult('dizhuwin', dizhuwin) if seatId == 0: moWin.setResult('nowin', 1) moWin.setResult('slam', 0) moWin.setResult('cards', [seat.cards for seat in table.seats]) roundId = table.gameRound.number table.clear(userids) for i, player in enumerate(table.players): uid = player.userId mrank = 3 mtableRanking = 3 moWin.setResult('seat' + str(player.seatId), [ detalChips[i], seat_coin[i], 0, 0, 0, 0, mrank, mtableRanking ]) if not player.isAI: #增加经验 exp = userdata.incrExp(uid, 20) explevel = dizhuaccount.getExpLevel(exp) gamedata.setGameAttr(uid, table.gameId, 'level', explevel) if ftlog.is_debug(): ftlog.debug('ErdayiMatch.doWinLoseTable', 'addExp=', 20, 'curExp=', exp, 'curLevel=', explevel) table.gamePlay.sender.sendToAllTableUser(moWin) # 发送给match manager users = [] for i, player in enumerate(table.players): if not player.isAI: user = {} user['userId'] = player.userId user['deltaScore'] = int(detalChips[i]) user['seatId'] = player.seatId users.append(user) mnr_msg = MsgPack() mnr_msg.setCmd('room') mnr_msg.setParam('action', 'm_winlose') mnr_msg.setParam('gameId', table.gameId) mnr_msg.setParam('matchId', table.room.bigmatchId) mnr_msg.setParam('roomId', table.room.ctrlRoomId) mnr_msg.setParam('tableId', table.tableId) mnr_msg.setParam('users', users) mnr_msg.setParam('ccrc', table._match_table_info['ccrc']) if cls.WINLOSE_SLEEP > 0: FTTasklet.getCurrentFTTasklet().sleepNb(cls.WINLOSE_SLEEP) # 记录游戏winlose try: for u in users: table.room.reportBiGameEvent('TABLE_WIN', u['userId'], table.roomId, table.tableId, roundId, u['deltaScore'], 0, 0, [], 'table_win') except: if ftlog.is_debug(): ftlog.exception() router.sendRoomServer(mnr_msg, table.room.ctrlRoomId)
def doCreateTable(self, userId, gameId, clientId, roomId0, tableId0, playMode, hasRobot = 0): #临时硬编码,解决91晃晃提审问题 if gameId==791 and playMode=="queshou-lianjiang" and clientId=="IOS_3.901_weixin.appStore,weixinPay.0-hall791.queshou.iostsljmj": hasRobot=1 if gameId == 790 and playMode == 'luosihu-luosihuts' and clientId=="IOS_3.901_weixin.appStore,weixinPay.0-hall790.laodao.iostsxjmj": hasRobot=1 """房主创建牌桌""" if not playMode: ftlog.error('game_handler, cat not create table without playMode...') loc = onlinedata.checkUserLoc(userId, clientId, gameId) lgameId, lroomId, ltableId, lseatId = loc.split('.') lgameId, lroomId, ltableId, lseatId = strutil.parseInts(lgameId, lroomId, ltableId, lseatId) if lgameId > 0 and lroomId > 0 and ltableId > 0 and lseatId >=0: ftlog.warn('create_table error, user in table',lgameId, lroomId, ltableId, lseatId) sendPopTipMsg(userId, "请稍候,正在进桌...") config = { "type":"quickstart", "pluginParams": { "roomId": lroomId, "tableId": ltableId, "seatId": lseatId } } todotask = TodoTaskEnterGameNew(lgameId, config) mo = MsgPack() mo.setCmd('todo_tasks') mo.setResult('gameId', gameId) mo.setResult('pluginId', lgameId) mo.setResult('userId', userId) mo.setResult('tasks', TodoTaskHelper.encodeTodoTasks(todotask)) router.sendToUser(mo, userId) elif self._canEnterGame(userId, gameId): # 保存建桌时间戳 gamedata.setGameAttr(userId, gameId, 'createTableTime', pktimestamp.getCurrentTimestamp()) msg = runcmd.getMsgPack() itemParams = msg.getParam("itemParams") playerCount = 4 playerTypeId = itemParams.get(MFTDefine.PLAYER_TYPE, 1) playerTypeConfig = majiang_conf.getCreateTableConfig(gameId, playMode, MFTDefine.PLAYER_TYPE, playerTypeId) if not playerTypeConfig: sendPopTipMsg(userId, '人数配置有误,请稍后重试') return playerCount = playerTypeConfig.get('count', 4) ftlog.debug('MajiangCreateTable.create_table playerCount:', playerCount) cardCountKey = playerTypeConfig.get(MFTDefine.CARD_COUNT, MFTDefine.CARD_COUNT) cardCountId = itemParams.get(cardCountKey, 0) cardCountConfig = majiang_conf.getCreateTableConfig(gameId, playMode, cardCountKey, cardCountId) if not cardCountConfig: sendPopTipMsg(userId, '房卡配置有误,请稍后重试') return if hasRobot == 1 and 'hasRobot' in cardCountConfig: cardCountConfig = cardCountConfig.get('hasRobot', {}) ftlog.debug('MajiangCreateTable.create_table hasRobot == 1:') fangka_count = cardCountConfig.get('fangka_count', 1) ftlog.debug('MajiangCreateTable.create_table fangka_count:', fangka_count , ' cardCountConfig:', cardCountConfig) msg.setParam('isCreateTable', 1) #标记创建的桌子是 自建桌 from poker.entity.game.rooms.room import TYRoom ''' 根据五个因素筛选合适的房间 1)gameId 游戏ID 2)playMode 游戏玩法 3)playerCount 玩家个数 4)hasRobot 是否有机器人 5)itemId 房卡道具 ''' itemId = hall_fangka.queryFangKaItem(gameId, userId, clientId) if itemId: ftlog.debug('MajiangCreateTable._chooseCreateRoom fangKa itemId:', itemId) roomId, checkResult = MajiangCreateTable._chooseCreateRoom(userId, gameId, playMode, playerCount, hasRobot, itemId) ftlog.debug('MajiangCreateTable._chooseCreateRoom roomId:', roomId, ' checkResult:', checkResult) if checkResult==TYRoom.ENTER_ROOM_REASON_OK: msg = runcmd.getMsgPack() msg.setCmdAction("room", "create_table") msg.setParam("roomId", roomId) msg.setParam("itemParams", itemParams) msg.setParam('needFangka', fangka_count) ftlog.debug('MajiangCreateTable._chooseCreateRoom send message to room:', msg) router.sendRoomServer(msg, roomId) else: sendPopTipMsg(userId, "暂时无法创建请稍后重试") if router.isQuery() : mo = runcmd.newOkMsgPack(1) router.responseQurery(mo, '', str(userId)) else: ftlog.info('majiang2 game_handler, ignore enter game request...')
def doCreateTable(self, userId, gameId, clientId, roomId0, tableId0, playMode): """ 房主创建牌桌 """ if not playMode: ftlog.error('game_handler, cat not create table without playMode...') loc = onlinedata.checkUserLoc(userId, clientId, gameId) lgameId, lroomId, ltableId, lseatId = loc.split('.') lgameId, lroomId, ltableId, lseatId = strutil.parseInts(lgameId, lroomId, ltableId, lseatId) if lgameId > 0 and lroomId > 0 and ltableId > 0 and lseatId >= 0: ftlog.warn('create_table error, user in table', lgameId, lroomId, ltableId, lseatId) sendPopTipMsg(userId, "请稍候,正在进桌...") config = { "type": "quickstart", "pluginParams": { "roomId": lroomId, "tableId": ltableId, "seatId": lseatId } } todotask = TodoTaskEnterGameNew(lgameId, config) mo = MsgPack() mo.setCmd('todo_tasks') mo.setResult('gameId', gameId) mo.setResult('pluginId', lgameId) mo.setResult('userId', userId) mo.setResult('tasks', TodoTaskHelper.encodeTodoTasks(todotask)) router.sendToUser(mo, userId) elif self._canEnterGame(userId, gameId): # 保存建桌时间戳 gamedata.setGameAttr(userId, gameId, 'createTableTime', pktimestamp.getCurrentTimestamp()) msg = runcmd.getMsgPack() itemParams = msg.getParam("itemParams") # cardCount为总局数 if "cardCount" in itemParams: cardCountId = itemParams.get('cardCount', 0) cardCountConfig = majiang_conf.getCreateTableConfig(gameId, playMode, 'cardCount', cardCountId) fangka_count = cardCountConfig.get('fangka_count', 1) ftlog.debug('MajiangCreateTable.create_table fangka_count:', fangka_count) playerCount = 4 playerTypeId = itemParams.get('playerType', 1) if playerTypeId: playerTypeConfig = majiang_conf.getCreateTableConfig(gameId, playMode, 'playerType', playerTypeId) playerCount = playerTypeConfig.get('count', 4) ftlog.debug('MajiangCreateTable.create_table playerCount:', playerCount) msg.setParam('isCreateTable', 1) # 标记创建的桌子是 自建桌 from poker.entity.game.rooms.room import TYRoom roomId, checkResult = MajiangCreateTable._chooseCreateRoom(userId, gameId, playMode, playerCount) ftlog.debug('MajiangCreateTable._chooseCreateRoom roomId:', roomId, ' checkResult:', checkResult) if checkResult == TYRoom.ENTER_ROOM_REASON_OK: msg = runcmd.getMsgPack() msg.setCmdAction("room", "create_table") msg.setParam("roomId", roomId) msg.setParam("itemParams", itemParams) msg.setParam('needFangka', fangka_count) ftlog.debug('MajiangCreateTable._chooseCreateRoom send message to room:', msg) router.sendRoomServer(msg, roomId) else: sendPopTipMsg(userId, "暂时无法创建请稍后重试") else: sendPopTipMsg(userId, "暂时无法创建请稍后重试") if router.isQuery(): mo = runcmd.newOkMsgPack(1) router.responseQurery(mo, '', str(userId)) else: ftlog.info('majiang2 game_handler, ignore enter game request...')