def _do_match__signin(self, msg): """ 比赛报名协议监听器. 调用赛区进行报名,成功返回roomId,userId;失败返回ec信息 :param msg: tcp消息 """ userId = msg.getParam('userId') feeIndex = msg.getParam('fee', 0) signinParams = msg.getParam('signinParams', {}) ftlog.info('StageMatchRoomMixin._do_match__signin roomId=', self.roomId, 'userId=', userId) # if not signinParams and tyglobal.enableTestHtml(): # signinParams = gamedata.getGameAttrJson(userId, self.gameId, 'test.signinParams') resp = MsgPack() resp.setCmd('match') resp.setResult('action', 'signin') resp.setResult('roomId', self.bigRoomId) resp.setResult('userId', userId) resp.setResult('gameId', self.gameId) try: self.matchArea.signin(userId, feeIndex, signinParams) resp.setResult('ok', 1) PokerMatchReport.reportMatchEvent('MATCH_SIGN_UP', userId, self.gameId, self.matchId, 0, 0, 0) except TYBizException, e: ftlog.info('StageMatchRoomMixin._do_match__signin Exception=', e) resp.setResult('ok', 0) resp.setError(e.errorCode, e.message)
def handleTableCallPeng(self, userId, seatId, message): """处理碰牌消息 { "cmd": "table_call", "params": { "gameId": 7, "clientId": "Android_3.90_360.360,yisdkpay.0-hall6.360.win", "userId": 10788, "roomId": 75041001, "tableId": 750410010200, "seatId": 0, "action": "peng", "action_id": 0, "tile": 7, "pattern": [7, 7, 7] } } """ actionId = self.getActionIdFromMessage(message) if actionId == self.table.actionID: tile = message.getParam('tile') pattern = message.getParam('pattern', None) self.table.pengTile(seatId, tile, pattern, MTableState.TABLE_STATE_PENG) else: ftlog.info('handleTableCallPeng message:', message, ' but actionID is wrong, actionIDInTable:', self.table.actionID, ' actionIDInMsg:', actionId)
def handleTableCallWin(self, userId, seatId, message): """处理和牌消息 { "cmd": "table_call", "params": { "gameId": 7, "clientId": "Android_3.90_360.360,yisdkpay.0-hall6.360.win", "userId": 10788, "roomId": 75041001, "tableId": 750410010200, "seatId": 0, "action": "win", "action_id": 14, "tile": 2 } } """ actionId = self.getActionIdFromMessage(message) if actionId == self.table.actionID: tile = message.getParam('tile') ftlog.debug('handleTableCallWin actionId =', actionId, 'tile', tile, 'seatId', seatId) self.table.gameWin(seatId, tile) else: ftlog.info('handleTableCallWin message:', message, ' but actionID is wrong, actionIDInTable:', self.table.actionID, ' actionIDInMsg:', actionId)
def __init__(self, gameId, cfg): ftlog.info('TYPlugin << |gameId, cfg:', gameId, cfg, caller=self) self.gameId = gameId self.name, self.module_name, self.class_name, self.object_name = ( cfg['name'], cfg['module'], cfg.get('class'), cfg.get('object')) old_mod = sys.modules.get(self.module_name) if old_mod: del sys.modules[self.module_name] self.old_mod = old_mod self.module = importlib.import_module(self.module_name) reload(self.module) if self.object_name: self.object = getattr(self.module, self.object_name)(gameId) self.handlers = getattr(self.object, cfg['handle'])(gameId) or {} else: self._class = getattr(self.module, self.class_name) self.handlers = getattr(self._class, cfg['handle'])(gameId) or {} ftlog.info('TYPlugin |', 'handler:', self.name, 'loaded:', cfg, 'old_mod:', id(old_mod), old_mod, 'new_mod:', id(self.module), 'module:', self.module, 'events:', self.handlers.keys(), caller=self)
def transitToStateStartGame(self): '''准备开始游戏, 减抽水、下前注、确定庄家和大小盲注 ''' self.__state = self.GAME_PLAY_STATE_START self.gameSeq += 1 self.startTime = time.time() ftlog.info("transitToStateStartGame <<", self.getBasicAttrsLog())
def recoverUserTableChips(self, userId, onTableIds, intClientId): deltaChips = 0 try: tableChips = pluginCross.halldata.getTableChipDict(userId) ftlog.debug('recoverUserTableChips->tableChips=', tableChips, 'onTableIds=', onTableIds) delTablesIds = [] for tableId, tchip in tableChips.iteritems(): tableId, tchip = ftstr.parseInts(tableId, tchip) if tableId in onTableIds: # the user is on the table, do not clear pass else: if tchip > 0: troomId = tableId / tyconfig.MAX_TABLE_ID gameId = troomId / tyconfig.MAX_ROOM_ID / tyconfig.MAX_ROOM_ID / tyconfig.MAX_CONFIG_ID ftlog.info('recoverUserTableChips->userId=', userId, 'gameId=', gameId, 'troomId=', troomId, 'tableId=', tableId, 'tchip=', tchip) _, _, delta = pluginCross.halldata.moveAllTableChipToChip( userId, gameId, 'TABLE_TCHIP_TO_CHIP', troomId, intClientId, tableId) deltaChips += delta delTablesIds.append(tableId) if delTablesIds: ftlog.info('recoverUserTableChips->delTableChips=', userId, 'delTablesIds=', delTablesIds) pluginCross.halldata.delTableChips(userId, delTablesIds) except: ftlog.error() return deltaChips
def _doJoinCreateTable(self, room, msg): ''' 加入牌桌 ''' assert room.roomId == msg.getParam("roomId") userId = msg.getParam("userId") gameId = msg.getParam("gameId") shadowRoomId = msg.getParam("shadowRoomId") tableId = msg.getParam("tableId") clientId = msg.getParam("clientId") tableIdNo = msg.getParam("createTableNo") playMode = room.roomConf.get("playMode") initParams = CreateTableData.getTableParamsByCreateTableNo(tableIdNo) ftlog.debug('RoomTcpHandler._doJoinCreateTable tableNo:', tableIdNo, ' initParams:', initParams) fangKaCount = self.getFangKaCountByTableNo(tableIdNo, initParams, userId, gameId, playMode) ftlog.info( "RoomTcpHandler._doJoinCreateTable >>> userId, clientId, roomId, shadowRoomId, tableId, fangKaCount:", userId, clientId, room.roomId, shadowRoomId, tableId, fangKaCount) if (fangKaCount > 0) and (not self.consumeFangKa( room, userId, gameId, initParams, playMode, fangKaCount)): return assert isinstance(shadowRoomId, int) and tyglobal.roomIdDefineMap( )[shadowRoomId].bigRoomId == room.roomDefine.bigRoomId extParams = msg.getKey('params') room.querySitReq(userId, shadowRoomId, tableId, clientId, extParams)
def checkUserOrderListLimit(self, userId): dataLen = DaoUserOrderList.HLEN(userId) if dataLen <= DaoUserOrderList.MAX_DATA_LENGTH: return # 超过最大数量限制时,删除历史数据 orderIds = DaoUserOrderList.HKEYS(userId) historys = [] for orderId in orderIds: datas = DaoUserOrderList.HGET(userId, orderId) datas.append(orderId) historys.append(datas) # 按时间排序, 7天以上的或已完结的记录优先删除 historys.sort(key=lambda x: x[0], reverse=True) ct = fttime.getCurrentTimestamp() - 7 * 24 * 60 * 60 # 7 天前的时间点 for x in xrange(DaoUserOrderList.MAX_DATA_LENGTH, len(historys)): isTimeOut = historys[x][0] <= ct isFinished = historys[x][5] not in (TYOrder.STATE_CREATE, TYOrder.STATE_DELIVERYING) if isTimeOut or isFinished: orderId = historys[x][-1] order = DaoGameOrder.HGETALL(0, orderId) ftlog.info('AUTO CLEANUP STORE ORDER->', userId, orderId, ftstr.dumps(order)) DaoUserOrderList.HDEL(userId, orderId) DaoGameOrder.DEL(0, orderId)
def doMatchDesc(self, userId): """ 比赛详情协议监听器. """ ftlog.info('StageMatchRoomMixin._do_match__desc roomId=', self.roomId, 'userId=', userId) self._sendDesc(userId)
def shuffle(self, goodPointCount, handTileCount): """ 洗牌器 子类里可添加特殊逻辑,比如确定宝牌 """ if self.tileTestMgr.initTiles(): # 检查手牌 handTiles = self.tileTestMgr.handTiles poolTiles = self.tileTestMgr.tiles ftlog.debug("self.tiles len1 = ", len(self.__tiles), "poolTiles = ", poolTiles, "handTiles = ", handTiles) if self.__dealer.initTiles(handTiles, poolTiles): ftlog.debug("self.tiles len2 = ", len(self.__tiles), "poolTiles = ", poolTiles, "handTiles = ", handTiles) self.__tiles = copy.deepcopy(self.__dealer.tiles) ftlog.debug("self.tiles len3 = ", len(self.__tiles), "poolTiles = ", poolTiles, "handTiles = ", handTiles) else: ftlog.debug("self.tiles len4 = ", len(self.__tiles)) self.__tiles = self.__dealer.shuffle(goodPointCount, handTileCount) ftlog.debug("self.tiles len5 = ", len(self.__tiles)) ftlog.info('MTableTile.shuffle tiles:', self.__tiles) if self.removeFeng: self.__tiles = filter(lambda x: not MTile.isFeng(x), self.__tiles) if self.removeArrow: self.__tiles = filter(lambda x: not MTile.isArrow(x), self.__tiles) if self.isRemoveWanTile: self.__tiles = filter( lambda x: MTile.getColor(x) == MTile.TILE_WAN, self.__tiles) return self.__tiles
def doConsumDeliveryHttp(self, request): """ 购买流程之二:购买成功,sdk调用游戏服, 游戏服发物品 成功返回: success """ ftlog.info('doConsumDeliveryHttp IN->', request.getDict()) mi = self.checkDelivery.check(request) if mi.error: ret = 'error,' + str(mi.error) elif mi.is_monthly: ret = 'error,we not support is_monthly' else: try: rfc = hallRpcOne.hallstore.doConsumDelivery( mi.userId, mi.appId, mi.realGameId, mi.clientId, mi.prodOrderId, mi.prodId, mi.prodCount, mi.chargeType, mi.chargeMap, mi.consumeMap, mi.platformOrder) if rfc.getException(): ret = 'error,' + str(rfc.getException()) else: result = rfc.getResult() if result.get('error'): ret = 'error,' + str(result.get('error').get('info')) else: ret = 'success' except Exception, e: ftlog.error() ret = 'error,' + str(e)
def getMatchGameQueueUsers(cls, gameId): if _DEBUG: ftlog.info("getMatchGameQueueUsers gameId:", gameId) user_a = 0 user_b = 0 if cls.getMatchGameQueueFemaleLength(gameId) >= 1: keyList = [cls._getMatchGameQueueFemaleKey(), gameId] user_a = cls.EVALSHA(0, cls._LUA_MATCH_GAME_USER_FEMALE, keyList) if cls.getMatchGameQueueMaleLength(gameId) >= 1: keyList = [cls._getMatchGameQueueMaleKey(), gameId] user_b = cls.EVALSHA(0, cls._LUA_MATCH_GAME_USER_MALE, keyList) else: keyList = [cls._getMatchGameQueueFemaleKey(), gameId] user_b = cls.EVALSHA(0, cls._LUA_MATCH_GAME_USER_FEMALE, keyList) else: keyList = [cls._getMatchGameQueueMaleKey(), gameId] user_a = cls.EVALSHA(0, cls._LUA_MATCH_GAME_USER_MALE, keyList) user_b = cls.EVALSHA(0, cls._LUA_MATCH_GAME_USER_MALE, keyList) if _DEBUG: ftlog.info("getMatchGameQueueUsers user_a:", user_a, " user_b:", user_b) return user_a, user_b
def removeAll(self, gameId, matchId, instId, roomId): """ 删除某个比赛某赛点的所有报名记录 """ ftlog.info('MatchSigninRecordDaoRedis.removeAll gameId=', gameId, 'matchId=', matchId, 'instId=', instId, 'roomId=', roomId) # datas = daobase.executeMixCmd('hgetall', self.buildKey(gameId, matchId, instId, roomId)) datas = daobase.loadMatchSigninRecord(gameId, matchId, instId, roomId) if datas: i = 0 while (i + 1 < len(datas)): try: userId = int(datas[i]) ftlog.info('MatchSigninRecordDaoRedis.removeAll gameId=', gameId, 'matchId=', matchId, 'userId=', userId, 'instId=', instId, 'roomId=', roomId) # 删除用户的比赛报名数据 daobase.removeUserSigninRecord(userId, "%s|%s" % (gameId, matchId)) except: ftlog.error('MatchSigninRecordDaoRedis.removeAll', 'gameId=', gameId, 'matchId=', matchId, 'instId=', instId, 'roomId=', roomId, 'userId=', datas[i], 'data=', datas[i + 1]) i += 2 # daobase.executeMixCmd('del', self.buildKey(gameId, matchId, instId, roomId)) daobase.removeMatchSigninRecord(gameId, matchId, instId, roomId)
def popBigGameMatchedPlayes(cls, user_a, user_a_group, user_b, user_b_group): if _DEBUG: ftlog.info("popBigGameMatchedPlayes @@@ user_a = ", user_a, " user_a_group =", user_a_group, " user_b = ", user_b, " user_b_group = ", user_b_group) if user_a_group == 1: keyList = [cls._getMatchQueueFemaleKeyHash(), user_a] cls.EVALSHA(0, cls._LUA_DEL_USER_TO_BIG_MATCH_FEMALE, keyList) else: keyList = [cls._getMatchQueueMaleKeyHash(), user_a] cls.EVALSHA(0, cls._LUA_DEL_USER_TO_BIG_MATCH_MALE, keyList) if user_b_group == 1: keyList = [cls._getMatchQueueFemaleKeyHash(), user_b] cls.EVALSHA(0, cls._LUA_DEL_USER_TO_BIG_MATCH_FEMALE, keyList) else: keyList = [cls._getMatchQueueMaleKeyHash(), user_b] cls.EVALSHA(0, cls._LUA_DEL_USER_TO_BIG_MATCH_MALE, keyList) split_userId_a = user_a.rsplit(':', 3) userId_a = int(split_userId_a[0]) split_userId_b = user_b.rsplit(':', 3) userId_b = int(split_userId_b[0]) sendBigMatchMsgToPlayers(userId_a, userId_b)
def getBigMatchQueueUsers(cls): if _DEBUG: ftlog.info("getBigMatchQueueUsers ") user_a = 0 user_b = 0 if cls.getBigMatchQueueFemaleLength() >= 1: keyList = [cls._getMatchQueueFemaleKey()] user_a = cls.EVALSHA(0, cls._LUA_BIG_MATCH_USER_FEMALE, keyList) if cls.getBigMatchQueueMaleLength() >= 1: keyList = [cls._getMatchQueueMaleKey()] user_b = cls.EVALSHA(0, cls._LUA_BIG_MATCH_USER_MALE, keyList) else: keyList = [cls._getMatchQueueFemaleKey()] user_b = cls.EVALSHA(0, cls._LUA_BIG_MATCH_USER_FEMALE, keyList) else: keyList = [cls._getMatchQueueMaleKey()] user_a = cls.EVALSHA(0, cls._LUA_BIG_MATCH_USER_MALE, keyList) user_b = cls.EVALSHA(0, cls._LUA_BIG_MATCH_USER_MALE, keyList) if _DEBUG: ftlog.info("getBigMatchQueueUsers user_a:", user_a, " user_b:", user_b) return user_a, user_b
def notifyStageStart(self, player): """ 通知用户进入下一阶段(晋级). """ ftlog.info('MatchPlayerNotifierTest.notifyStageStart', 'stageIndex=', player.group.stageIndex, 'startStageIndex=', player.group.startStageIndex)
def joinBigMatchQueueMale(cls, userId): if _DEBUG: ftlog.info("joinBigMatchQueueMale userId:", userId) keyList = [cls._getMatchQueueMaleKey(), userId] result = cls.EVALSHA(0, cls._LUA_ADD_USER_TO_BIG_MATCH_MALE, keyList) return result
def _notifyMatchWait(self, player, riseWait=0): msg = MsgPack() msg.setCmd('match') msg.setResult('action', 'wait') msg.setResult('gameId', self.room.gameId) msg.setResult('roomId', self.room.bigRoomId) msg.setResult('tableId', player.group.matchConf.tableId) msg.setResult('riseWait', riseWait) msg.setResult('cardCount', player.cardCount) msg.setResult( 'loseScore', player.group.matchRules.loseScore if player.group.stageConf.rulesConf.TYPE_ID == StageMatchRulesConfASS.TYPE_ID else 0) msg.setResult('mname', getMatchName(self.room, player)) steps = [] for i, stageConf in enumerate(player.group.matchConf.stages): isCurrent = True if i == player.group.stageIndex else False if stageConf.userCountPerGroup != 0: des = '每组%s人晋级' % (stageConf.riseUserCount) else: des = '%s人晋级' % (stageConf.riseUserCount) stepInfo = {'des': des} if isCurrent: stepInfo['isCurrent'] = 1 stepInfo['name'] = stageConf.name steps.append(stepInfo) msg.setResult('steps', steps) ftlog.info('PokerMatchPlayerNotifier._notifyMatchWait', 'msg=', msg.pack()) tyrpcconn.sendToUser(msg, player.userId)
def doConsumeTransactionHttp(self, request): """ 购买流程之一:client请求sdk,sdk调用游戏服,游戏服检查商品有效性并存储订单信息 成功返回:标准MsgPack,需要result中有相同的prodOrderId """ ftlog.info('doConsumeTransactionHttp IN->', request.getDict()) mo = MsgPack() mo.setCmd('buy_prod5') mi = self.checkTransactionStart.check(request) if mi.error: mo.setError(1, str(mi.error)) else: try: rfc = hallRpcOne.hallstore.doConsumeTransaction( mi.userId, mi.appId, mi.realGameId, mi.clientId, mi.prodOrderId, mi.prodId, mi.prodCount) if rfc.getException(): mo.setError(2, str(rfc.getException())) else: result = rfc.getResult() if result != 'ok': mo.setError(3, str(result)) else: mo.setResult('appId', mi.appId) mo.setResult('userId', mi.userId) mo.setResult('prodId', mi.prodId) mo.setResult('prodCount', mi.prodCount) mo.setResult('prodOrderId', mi.prodOrderId) except Exception, e: ftlog.error() mo.setError(4, str(e))
def startTable(self, table): """ 让player在具体的游戏中坐到seat上 """ try: ftlog.info('PokerMatchTableController.startTable', 'groupId=', table.group.groupId, 'tableId=', table.tableId, 'ccrc=', table.ccrc, 'roomId=', table.roomId, 'userIds=', table.getUserIdList()) # 统计阶段的局数 sequence = int(table.group.instId.split('.')[1]) groupNum = table.group.groupId.split('.')[-1] userIds = table.getUserIdList() PokerMatchReport.reportMatchEvent( "MATCH_START_TABLE", userIds[0] if userIds else 0, table.group.area.gameId, table.group.matchId, table.tableId, sequence, 0, [ table.group.stageIndex, groupNum, table.group.startPlayerCount, table.group.stageConf.cardCount ]) # 发送tableStart message = _buildTableStartMessage(table) tableInfo = message.getKey('params') stage_match_table_remote.doStartTable(table.roomId, table.tableId, tableInfo) except: ftlog.error('PokerMatchTableController.startTable', 'groupId=', table.group.groupId, 'tableId=', table.tableId, 'roomId=', table.roomId, 'userIds=', table.getUserIdList())
def notifyMatchCancelled(self, signer, reason): """ 通知用户比赛由于reason取消了 """ try: ftlog.info('PokerMatchPlayerNotifier.notifyMatchCancelled', 'userId=', signer.userId, 'reason=', reason) userId = signer.userId # TODO 确认用户已经上线 player = self.room.matchArea.findPlayer(userId) if player and player.isQuit: return self.notifyMatchSignsUpdate(userId) msg = MsgPack() msg.setCmd('match') msg.setResult('action', 'cancel') msg.setResult('gameId', self.room.gameId) msg.setResult('roomId', self.room.bigRoomId) msg.setResult('reason', reason) msg.setResult('info', MatchFinishReason.toString(reason)) tyrpcconn.sendToUser(msg, userId) except: ftlog.error('PokerMatchPlayerNotifier.notifyMatchCancelled', 'userId=', signer.userId, 'instId=', signer.instId, 'reason=', reason)
def getState(self): """获取本轮出牌状态 """ if self.maoState != MTableState.TABLE_STATE_NEXT: ftlog.info('MQiangExmaoPengProcessor.getState return:', self.maoState) return self.maoState
def _finishDelivery(self, order, errorCode): order.errorCode = errorCode order.state = TYOrder.STATE_DELIVERY order.updateTime = fttime.getCurrentTimestamp() error, oldState = self._orderDao.updateOrder(order, TYOrder.STATE_DELIVERYING) if error != 0: ftlog.info('HallStoreSystem._finishDelivery orderId=', order.orderId, 'platformOrderId=', order.platformOrderId, 'userId=', order.userId, 'gameId=', order.gameId, 'productId', order.productId, 'count=', order.count, 'chargeInfo=', order.chargeInfo, 'errorCode=', order.errorCode, 'oldState=', oldState) else: ftlog.info('HallStoreSystem._finishDelivery orderId=', order.orderId, 'platformOrderId=', order.platformOrderId, 'userId=', order.userId, 'gameId=', order.gameId, 'productId', order.productId, 'count=', order.count, 'chargeInfo=', order.chargeInfo, 'errorCode=', order.errorCode) return error, oldState
def buyProduct(self, gameId, realGameId, userId, clientId, orderId, productId, count): product = self.findProduct(productId) if not product: return None, '没有该商品' timestamp = fttime.getCurrentTimestamp() order = TYOrder(orderId, '', userId, gameId, realGameId, productId, count, clientId, timestamp, timestamp, TYOrder.STATE_CREATE, 0, None) order.product = product self._orderDao.addOrder(order) ftlog.info('HallStoreSystem.buyProduct gameId=', gameId, 'realGameId=', realGameId, 'userId=', userId, 'clientId=', clientId, 'orderId=', orderId, 'productId=', productId, 'count=', count) return order, 'ok'
def uploadVideo(uploadUrl, token, uploadPath, videoData): try: filename = os.path.basename(uploadPath) formItems = [] formItems.append(MultipartForm.FormItemData('token', token)) formItems.append(MultipartForm.FormItemData('key', uploadPath)) formItems.append( MultipartForm.FormItemFile('file', videoData, filename)) #formItems.append(FormItemFile('fileBinaryData', videoData, filename)) headers, uploadData = MultipartForm.encodeFormItems(formItems) retrydata = {'max': 3} code, res = fthttp.queryHttp(method='POST', url=uploadUrl, header=headers, body=uploadData, connect_timeout=5, retrydata=retrydata) if ftlog.is_debug(): ftlog.debug('uploader.uploadVideo uploadUrl=', uploadUrl, 'uploadPath=', uploadPath, 'token=', token, 'ret=', (code, res)) if code == 200 or code == 406: # 406 文件已经存在 return 0, '上传成功' ftlog.info('uploader.uploadVideo Res uploadUrl=', uploadUrl, 'uploadPath=', uploadPath, 'token=', token, 'ret=', code) return -1, '上传失败' except: return -2, '上传失败'
def joinMatchGameQueueMale(cls, userId, gameId): if _DEBUG: ftlog.info("joinMatchGameQueueMale userId:", userId) keyList = [cls._getMatchGameQueueMaleKey(), userId, gameId] result = cls.EVALSHA(0, cls._LUA_ADD_USER_TO_GAMEQUEUE_MALE, keyList) return result
def doAction(self, gameId, clientId, userAssets, item, timestamp, params): assert (isinstance(item, TYMemberCardItem)) if item.isExpires(timestamp): return items.TYItemActionResult(None, None, -30, '道具已经过期', None) if not item.canCheckin(timestamp): return items.TYItemActionResult(None, None, -31, '道具已经签到过', None) # 保存item item.checkinTime = timestamp userBag = userAssets.getUserBag() userBag.updateItem(item, timestamp) # 发放开出的奖品 # 检查是否是订阅会员 ct = datetime.fromtimestamp(timestamp) eventId = 'ITEM_USE' if pluginCross.hallsubmember.isSubExpires( userAssets.userId, ct) else 'ITEM_SUB_MEMBER_CHECKIN' assetItemList = userAssets.sendContentItemList(gameId, self.content.getItems(), 1, True, timestamp, eventId, item.kindId) gotContent = assetutils.buildContentsString(assetItemList) replaceParams = {'gotContent': gotContent} _mail, message, _changed = _action._handleMailAndMessageAndChanged( gameId, userAssets, self, assetItemList, replaceParams) ftlog.info('TYItemActionCheckin._doActionImpl gameId=', gameId, 'userId=', userAssets.userId, 'itemId=', item.itemId, 'itemKindId=', item.kindId, 'gotContent=', gotContent, 'mail=', _mail, 'message=', message, 'changed=', _changed) # TGHall.getEventBus().publishEvent(TYCheckinItemEvent(gameId, userBag.userId, item, assetItemList)) return TYItemActionCheckinResult(self, item, message, assetItemList)
def quitMatchGameQueueFemale(cls, userId, gameId): if _DEBUG: ftlog.info("quitMatchGameQueueFemale userId:", userId) keyList = [cls._getMatchGameQueueFemaleKey(), userId, gameId] result = cls.EVALSHA(0, cls._LUA_DEL_USER_TO_GAMEQUEUE_FEMALE, keyList) return result
def getBanker(self, playerCount, isFirst, winLoose, winSeatId, extendInfo={}): """子类必须实现 参数: 1)isFirst 是否第一句 2)winLoose 上局的结果 1分出了胜负 0流局 3)winSeatId 赢家的座位号,如果第二个参数为0,则本参数为上一局的庄家 4)四川无法根据winLoose来判断是否流局,可以胡多次,则从extenInfo中获取 """ if isFirst: # 初始化房主 self.banker = 0 self.no_result_count = 0 self.remain_count = 0 else: isGameFlow = extendInfo.get('isGameFlow', False) if isGameFlow: # 流局 if self.huaZhuDaJiaoId != -1: winSeatId = self.huaZhuDaJiaoId else: winSeatId = self.banker else: # 赢局 if self.multiPaoId != -1: winSeatId = self.multiPaoId elif extendInfo.get('firstHuId', -1) != -1: winSeatId = extendInfo.get('firstHuId', -1) else: winSeatId = self.banker ftlog.debug('MBankerSiChuan.getbankerId:', winSeatId, 'oldBankerId:', self.banker, 'extendInfo:', extendInfo, 'huaZhuDaJiaoId:', self.huaZhuDaJiaoId, 'MultiPaoId:', self.multiPaoId) if winSeatId == self.banker: # 第一次胡的玩家 是庄家 self.remain_count += 1 self.no_result_count = 0 else: # 赢得是闲家 self.banker = winSeatId self.remain_count = 0 self.no_result_count = 0 # 重置相关参数 self.__multiPaoId = -1 self.__huaZhuDaJiaoId = -1 ftlog.info('MBankerSiChuan.getBanker playerCount:', playerCount, ' isFirst:', isFirst, ' winLoose:', winLoose, ' winSeatId:', winSeatId, ' banker:', self.banker, ' remainCount:', self.remain_count, ' noResultCount:', self.no_result_count) return self.banker, self.remain_count, self.no_result_count
def doAction(self, gameId, clientId, userAssets, item, timestamp, params): assert (isinstance(item, TYExchangeItem)) if item.isDied(timestamp): if item.itemKind.units.isTiming(): return items.TYItemActionResult(None, None, -30, '道具已经过期', None) else: return items.TYItemActionResult(None, None, -31, '道具数量不足', None) if item.state != TYExchangeItem.STATE_NORMAL: return items.TYItemActionResult(None, None, -32, '道具审核中', None) wechat_red_pack = self.isWechatRedPack() # 微信红包,无需手机号、地址 msg = MsgPack() msg.setKey('apiVersion', 5.0) msg.setCmdAction('exchange5', 'exchange') msg.updateParam(self.auditParams) msg.setParam( 'phone', str( params.get('phoneNumber' ) if not wechat_red_pack else '11111111111')) msg.setParam('uName', params.get('uName', '')) msg.setParam('bindPhone', params.get('bindPhone', '')) msg.setParam('phoneNumber', params.get('phoneNumber', '')) msg.setParam('uAddres', params.get('uAddres', '')) msg.setParam('gameId', gameId) msg.setParam('itemId', item.itemId) msg.setParam('userId', userAssets.userId) msg.setParam('extabName', '_item_') msg.setParam('clientId', clientId) msg.setParam('wxappid', hallconf.getWeiXinAppId(userAssets.userId, clientId)) msg.setParam('proviceId', params.get('proviceId', '')) msg.setParam('cityId', params.get('cityId', '')) msg.setParam('countyId', params.get('countyId', '')) msg.setParam('townId', params.get('townId', '')) msg.setParam('proviceName', params.get('proviceName', '')) msg.setParam('cityName', params.get('cityName', '')) msg.setParam('countyName', params.get('countyName', '')) msg.setParam('townName', params.get('townName', '')) ftlog.info('TYItemActionExchange->doAction', msg) exchangeId, errMsg = pluginCross.hallexchange.doExchangeRequest( userAssets.userId, msg) if not exchangeId or errMsg: return items.TYItemActionResult(None, None, -33, errMsg, None) # 兑换开始,成功,转换道具状态 item.state = TYExchangeItem.STATE_AUDIT item.original = 0 userAssets.getUserBag().updateItem(item, timestamp) replaceParams = {'item': item.itemKind.displayName} _mail, message, _changed = _action._handleMailAndMessageAndChanged( gameId, userAssets, self, None, replaceParams) # TGHall.getEventBus().publishEventent(TYItemExchangeEvent(gameId, userAssets.userId, item)) return TYItemActionExchangeResult(self, item, message, exchangeId)