def pushHonor(userId, honorId): """ 获得称号时推送 """ mo = MsgPack() mo.setCmd("honor_push") mo.setResult("gameId", FISH_GAMEID) mo.setResult("userId", userId) # mo.setResult("honors", getHonorList(userId)) router.sendToUser(mo, userId) isIn, roomId, tableId, seatId = util.isInFishTable(userId) if isIn: mo = MsgPack() mo.setCmd("table_call") mo.setParam("action", "honor_push") mo.setParam("gameId", FISH_GAMEID) mo.setParam("clientId", util.getClientId(userId)) mo.setParam("userId", userId) mo.setParam("roomId", roomId) mo.setParam("tableId", tableId) mo.setParam("seatId", seatId) router.sendTableServer(mo, roomId) from newfish.game import TGFish event = GetHonorEvent(userId, FISH_GAMEID, honorId) TGFish.getEventBus().publishEvent(event)
def refreshQuestState(userId, questType, totalValue): """ 刷新指定任务类型的任务状态 """ isComplete = False clientId = util.getClientId(userId) for taskConf in config.getMainQuestTaskConf(clientId).values(): if questType == taskConf["type"] and totalValue >= taskConf["num"]: state = getTask(userId, taskConf["taskId"])[QuestIndex.State] if state == QuestState.Default: setTask(userId, clientId, taskConf["taskId"], [QuestState.Completed, int(time.time())]) isComplete = True if isComplete: refreshQuestModuleTip(userId, clientId) isIn, roomId, tableId, seatId = util.isInFishTable(userId) if isIn: mo = MsgPack() mo.setCmd("table_call") mo.setParam("action", "task_update") mo.setParam("gameId", FISH_GAMEID) mo.setParam("clientId", util.getClientId(userId)) mo.setParam("userId", userId) mo.setParam("roomId", roomId) mo.setParam("tableId", tableId) mo.setParam("seatId", seatId) router.sendTableServer(mo, roomId)
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)
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)
def sendChangeBetsConfReq(cls, shadowRoomId, betsConf): mpReq = MsgPack() mpReq.setCmd("room") mpReq.setParam("action", "change_betsConf") mpReq.setParam("roomId", shadowRoomId) mpReq.setParam("betsConf", betsConf) if ftlog.is_debug(): ftlog.debug(str(mpReq), caller=cls) router.sendTableServer(mpReq, shadowRoomId)
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)
def updateTableInfo(self, table): ''' 桌子信息变化 ''' # 发送tableInfo try: tableInfoMessage = buildTableInfoMessage(table) router.sendTableServer(tableInfoMessage, table.roomId) except: ftlog.error()
def clearTable(self, table): ''' 清理桌子 ''' # 发送tableClear try: tableClearMessage = buildTableClearMessage(table) router.sendTableServer(tableClearMessage, table.roomId) except: ftlog.error()
def sendSitReq(cls, userId, shadowRoomId, tableId, clientId, extParams=None): mpSitReq = cls.makeSitReq(userId, shadowRoomId, tableId, clientId) if extParams: moParams = mpSitReq.getKey('params') for k, v in extParams.items(): if not k in moParams: moParams[k] = v if ftlog.is_debug(): ftlog.debug(str(mpSitReq), caller=cls) router.sendTableServer(mpSitReq, shadowRoomId)
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}
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}
def sendTableCallObserveReq(cls, userId, shadowRoomId, tableId, clientId): mpReq = MsgPack() mpReq.setCmd("table_call") mpReq.setParam("action", "observe") mpReq.setParam("userId", userId) mpReq.setParam("roomId", shadowRoomId) mpReq.setParam("tableId", tableId) mpReq.setParam("clientId", clientId) if ftlog.is_debug(): ftlog.debug(str(mpReq), caller=cls) router.sendTableServer(mpReq, shadowRoomId)
def clearTable(self, table): ''' 清理桌子 ''' # 发送tableClear try: tableClearMessage = buildTableClearMessage(table) router.sendTableServer(tableClearMessage, table.roomId) except: self._logger.error('TableControllerDizhu.clearTable', 'groupId=', table.group.groupId, 'tableId=', table.tableId, 'userIds=', table.getUserIdList())
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()
def updateTableInfo(self, table): ''' 桌子信息变化 ''' # 发送tableInfo try: tableInfoMessage = buildTableInfoMessage(table) router.sendTableServer(tableInfoMessage, table.roomId) except: self._logger.error('TableControllerDizhu.updateTableInfo', 'groupId=', table.group.groupId, 'tableId=', table.tableId, 'userIds=', table.getUserIdList())
def startTable(self, table): ''' 让player在具体的游戏中坐到seat上 ''' try: matchlog('PlayerControllerImpl.startTable groupId=', table.group.groupId, 'tableId=', table.tableId) # 发送tableStart message = buildTableStartMessage(table) router.sendTableServer(message, table.roomId) except: ftlog.error()
def sendTableManageGameStartReq(self, shadowRoomId, tableId, userIds, recyclePlayersN=0, params=None): '''recyclePlayersN表示需要从牌桌回收到队列的人数 ''' mpReq = self.makeTableManageReq(0, shadowRoomId, tableId, None, 'game_start', {'recyclePlayersN': recyclePlayersN}) mpReq.setParam("userIds", userIds) from poker.entity.game.rooms import tyRoomConst if self.roomConf['typeName'] == tyRoomConst.ROOM_TYPE_NAME_MTT and self.state == self.MTT_STATE_FINALS: mpReq.setParam("isFinalTable", True) if params: mpReq.updateParam(params) ftlog.hinfo(str(mpReq), caller=self) router.sendTableServer(mpReq, shadowRoomId)
def startTable(self, table): ''' 让player在具体的游戏中坐到seat上 ''' try: self._logger.info('TableControllerDizhu.startTable', 'groupId=', table.group.groupId, 'tableId=', table.tableId, 'userIds=', table.getUserIdList()) # 发送tableStart message = buildTableStartMessage(table) router.sendTableServer(message, table.roomId) except: self._logger.error('TableControllerDizhu.startTable', 'groupId=', table.group.groupId, 'tableId=', table.tableId, 'userIds=', table.getUserIdList())
def _triggerItemChangeEvent(event): # 只有通过渔场外增加的资产,且用户在渔场内时才需要刷新用户数据 if event.type == 0 and (event.changed.get("ud") or event.changed.get("items")): isIn, roomId, tableId, seatId = util.isInFishTable(event.userId) if isIn: mo = MsgPack() mo.setCmd("table_call") mo.setParam("action", "refresh_user_data") mo.setParam("gameId", FISH_GAMEID) mo.setParam("clientId", util.getClientId(event.userId)) mo.setParam("userId", event.userId) mo.setParam("roomId", roomId) mo.setParam("tableId", tableId) mo.setParam("seatId", seatId) router.sendTableServer(mo, roomId)
def userReconnect(self, table, seat): ''' 用户坐下 ''' try: msg = MsgPack() msg.setCmd('table_manage') msg.setParam('action', 'm_user_reconn') msg.setParam('gameId', table.gameId) msg.setParam('matchId', table.group.match.matchId) msg.setParam('roomId', table.roomId) msg.setParam('tableId', table.tableId) msg.setParam('userId', seat.player.userId) msg.setParam('seatId', seat.seatId) msg.setParam('ccrc', table.ccrc) router.sendTableServer(msg, table.roomId) except: ftlog.error()
def sendTableManageGameStartReq(self, shadowRoomId, tableId, userIds, recyclePlayersN=0, params=None): '''recyclePlayersN表示需要从牌桌回收到队列的人数 ''' mpReq = self.makeTableManageReq(0, shadowRoomId, tableId, None, 'game_start', {'recyclePlayersN': recyclePlayersN}) mpReq.setParam("userIds", userIds) from poker.entity.game.rooms import tyRoomConst if self.roomConf[ 'typeName'] == tyRoomConst.ROOM_TYPE_NAME_MTT and self.state == self.MTT_STATE_FINALS: mpReq.setParam("isFinalTable", True) if params: mpReq.updateParam(params) ftlog.hinfo(str(mpReq), caller=self) router.sendTableServer(mpReq, shadowRoomId)
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
def clearTable(self, table): ''' 清理桌子 ''' try: msg = MsgPack() msg.setCmd('table_manage') msg.setParam('action', 'm_table_clear') msg.setParam('gameId', table.gameId) msg.setParam('matchId', table.matchInst.matchId) msg.setParam('roomId', table.roomId) msg.setParam('tableId', table.tableId) msg.setParam('ccrc', table.ccrc) if ftlog.is_debug(): ftlog.debug('MatchTableControllerDizhu.clearTable matchId=', table.matchInst.matchId, 'instId=', table.matchInst.instId, 'roomId=', table.roomId, 'tableId=', table.tableId, 'mo=', msg) router.sendTableServer(msg, table.roomId) except: ftlog.error()
def chargeNotify(chargeNotifyEvent): userId = chargeNotifyEvent.userId rmbs = chargeNotifyEvent.rmbs from poker.entity.dao import onlinedata locList = onlinedata.getOnlineLocList(userId) for loc in locList: roomId = loc[0] tableId = loc[1] seatId = loc[2] gameId = roomId / 10000000 if gameId == FISH_GAMEID and tableId > 0 and seatId > 0: message = MsgPack() message.setCmd("table_call") message.setParam("action", "charge_notify") message.setParam("gameId", FISH_GAMEID) message.setParam("userId", userId) message.setParam("clientId", chargeNotifyEvent.clientId) message.setParam("roomId", roomId) message.setParam("tableId", tableId) message.setParam("seatId", seatId) router.sendTableServer(message, roomId)
def userReconnect(self, table, seat): ''' 用户坐下 ''' try: msg = MsgPack() msg.setCmd('table_manage') msg.setParam('action', 'm_user_reconn') msg.setParam('gameId', table.gameId) msg.setParam('matchId', table.group.area.matchId) msg.setParam('roomId', table.roomId) msg.setParam('tableId', table.tableId) msg.setParam('userId', seat.player.userId) msg.setParam('seatId', seat.seatId) msg.setParam('ccrc', table.ccrc) router.sendTableServer(msg, table.roomId) except: self._logger.error('TableControllerDizhu.userReconnect', 'groupId=', table.group.groupId, 'tableId=', table.tableId, 'userId=', seat.player.userId if seat.player else 0, 'userIds=', table.getUserIdList())
def takeNewbie7DaysGift(userId, clientId, idx): """ 领取7日礼包奖励 """ isIn, roomId, tableId, seatId = util.isInFishTable(userId) if isIn: mo = MsgPack() mo.setCmd("table_call") mo.setParam("action", "newbie_7_gift_take") mo.setParam("gameId", FISH_GAMEID) mo.setParam("clientId", clientId) mo.setParam("userId", userId) mo.setParam("idx", idx) mo.setParam("roomId", roomId) mo.setParam("tableId", tableId) mo.setParam("seatId", seatId) router.sendTableServer(mo, roomId) return level = util.getActivityCheckLevel(userId) fireCount = gamedata.getGameAttrJson(userId, FISH_GAMEID, GameData.fireCount) takeGiftRewards(userId, clientId, idx, fireCount, level)
def dealTreasureReward(userId, clientId, dayFirst): """ 处理宝藏奖励发放 """ if ftlog.is_debug(): ftlog.debug("dealTreasureReward", userId, clientId, dayFirst) for kindId, _ in config.getTreasureConf().iteritems(): refreshTreasureState(userId, kindId) if dayFirst: isIn, roomId, tableId, seatId = util.isInFishTable(userId) if isIn and util.getRoomTypeName(roomId) in config.NORMAL_ROOM_TYPE: mo = MsgPack() mo.setCmd("table_call") mo.setParam("action", "treasure_rewards") mo.setParam("gameId", FISH_GAMEID) mo.setParam("clientId", clientId) mo.setParam("userId", userId) mo.setParam("roomId", roomId) mo.setParam("tableId", tableId) mo.setParam("seatId", seatId) router.sendTableServer(mo, roomId) else: getTreasureRewards(userId)
def _triggerNewSkillEvent(event): if event.eventId != "BI_NFISH_GET_LEVEL_REWARDS": return userId = event.userId skillId = event.skillId clientId = util.getClientId(userId) isIn, roomId, tableId, seatId = util.isInFishTable(userId) if not isIn: return mo = MsgPack() mo.setCmd("table_call") mo.setParam("action", "skill_install") mo.setParam("gameId", config.FISH_GAMEID) mo.setParam("clientId", clientId) mo.setParam("userId", userId) mo.setParam("roomId", roomId) mo.setParam("tableId", tableId) mo.setParam("seatId", seatId) mo.setParam("skillId", skillId) mo.setParam("install", 1) mo.setParam("ignoreFailMsg", True) router.sendTableServer(mo, roomId) ftlog.debug("level_rewards, userId =", userId, "skillId =", skillId)
def changeGun(userId, gunId, mode): """ 切换火炮 """ isIn, roomId, tableId, seatId = util.isInFishTable(userId) if isIn: mo = MsgPack() mo.setCmd("fish_table_call") mo.setParam("action", "chg_gun") mo.setParam("gameId", FISH_GAMEID) mo.setParam("clientId", util.getClientId(userId)) mo.setParam("userId", userId) mo.setParam("roomId", roomId) mo.setParam("tableId", tableId) mo.setParam("seatId", seatId) mo.setParam("gunId", gunId) mo.setParam("gameMode", mode) router.sendTableServer(mo, roomId) else: userGunIds = getGunIds(userId, mode) mo = MsgPack() mo.setCmd("chg_gun") mo.setResult("gameId", FISH_GAMEID) mo.setResult("userId", userId) mo.setResult("gameMode", mode) if gunId not in userGunIds: mo.setResult("reason", 1) elif not isCanEquip(userId, gunId, mode): mo.setResult("reason", 2) else: gunSkinIdKey = GameData.gunSkinId if mode == CLASSIC_MODE else GameData.gunSkinId_m gamedata.setGameAttr(userId, FISH_GAMEID, gunSkinIdKey, gunId) mo.setResult("gunId", gunId) mo.setResult("reason", 0) sendGunListMsg(userId, mode) router.sendToUser(mo, userId)
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)
def doGetFishGiftReward(userId, clientId, giftId): """ 领取礼包 """ giftConf = getGiftConf(clientId, giftId) if not giftConf: return code = 1 chestId = 0 commonRewards = [] chestRewards = [] availableGift = gamedata.getGameAttrJson(userId, FISH_GAMEID, GameData.availableGift, []) canGetRewards = False if giftConf["giftType"] == GiftType.MONTHCARD: userBag = hallitem.itemSystem.loadUserAssets(userId).getUserBag() itemId = giftConf["monthCard"]["name"] item = userBag.getItemByKindId(itemId) if item and not item.isDied(int(time.time())): if itemId == config.MONTH_CARD_KINDID: canGetRewards = weakdata.getDayFishData( userId, WeakData.getMonthCardGift, 0) == 0 else: canGetRewards = weakdata.getDayFishData( userId, WeakData.getPermanentMonthCardGift, 0) == 0 else: canGetRewards = giftId in availableGift if not canGetRewards: return eventId = "BI_NFISH_BUY_ITEM_GAIN" for item in giftConf.get("items", []): if item["type"] == 1: # 宝箱 chestId = item["itemId"] rewards = chest_system.getChestRewards(userId, chestId) code = chest_system.deliveryChestRewards(userId, chestId, rewards, eventId) chestRewards.extend(rewards) elif item["type"] == 2: # 等级 _makeUserLevelUp(userId, item["count"]) code = 0 elif item["type"] == 3: # 资产/道具 rewards = [{"name": item["itemId"], "count": item["count"]}] code = util.addRewards(userId, rewards, eventId, int(giftId), param01=int(giftId)) commonRewards.extend(rewards) elif item["type"] == 5: # 皮肤炮皮肤 skinId = item["itemId"] ret = gun_system.addEquipGunSkinSkin(userId, skinId, clientId) if ret: code = 0 rewards = [{ "name": item["itemId"], "count": item["count"], "type": item["type"] }] commonRewards.extend(rewards) elif item["type"] == 6: # 直升炮台 upToLevel = item["count"] success = gun_system.upgradeGun(userId, False, MULTIPLE_MODE, byGift=True, upToLevel=upToLevel) if success: code = 0 message = MsgPack() if giftConf["giftType"] == GiftType.MONTHCARD: message.setCmd("monthGiftGet") else: message.setCmd("fishGiftReward") message.setResult("gameId", FISH_GAMEID) message.setResult("userId", userId) message.setResult("giftId", giftId) message.setResult("chestId", chestId) if code == 0 and (commonRewards or chestRewards): if giftConf["giftType"] == GiftType.MONTHCARD: itemId = giftConf["monthCard"]["name"] if itemId == config.MONTH_CARD_KINDID: weakdata.incrDayFishData(userId, WeakData.getMonthCardGift, 1) else: weakdata.incrDayFishData(userId, WeakData.getPermanentMonthCardGift, 1) else: availableGift.remove(giftId) gamedata.setGameAttr(userId, FISH_GAMEID, GameData.availableGift, json.dumps(availableGift)) message.setResult("commonRewards", commonRewards) message.setResult("chestRewards", chestRewards) message.setResult("code", code) router.sendToUser(message, userId) productId = giftConf.get("productId", "") isIn, roomId, tableId, seatId = util.isInFishTable(userId) if isIn: mo = MsgPack() mo.setCmd("table_call") mo.setParam("action", "take_gift_reward") mo.setParam("gameId", FISH_GAMEID) mo.setParam("clientId", util.getClientId(userId)) mo.setParam("userId", userId) mo.setParam("roomId", roomId) mo.setParam("tableId", tableId) mo.setParam("seatId", seatId) mo.setParam("productId", productId) router.sendTableServer(mo, roomId)