示例#1
0
    def changeTableRoomParams(self, avatar_mb, t_idx, game_type, create_dict):
        table = self.tables.get(t_idx)
        if table is None:
            avatar_mb.showTip("桌子编号错误")
            return

        if table.roomAvailable():
            avatar_mb.showTip("正在游戏中, 不能修改")
            return

        create_dict['room_type'] = const.CLUB_ROOM
        if not roomParamsChecker(game_type, create_dict):
            avatar_mb.showTip("房间参数错误")
            return

        room_params = roomParamsGetter(game_type, create_dict)
        room_params['owner_uid'] = self.club.owner['userId']
        room_params['club_id'] = self.club.clubId
        table.setRoomParams(game_type, room_params)
        # 改完直接进入房间
        # table.takeASeat(avatar_mb)
        if not self.club.isOwner(avatar_mb.userId):
            table.takeASeat(avatar_mb)
        else:
            self.club.tableRoomParams[t_idx] = {
                'game_type': game_type,
                'params': dict(room_params)
            }
示例#2
0
		def callback(content):
			if self.isDestroyed:
				return
			if content is None:
				DEBUG_MSG("createRoom callback error: content is None, user id {}".format(self.userId))
				self.createRoomFailed(const.CREATE_FAILED_NET_SERVER_ERROR)
				return
			try:
				DEBUG_MSG("cards response: {}".format(content))
				if content[0] != '{':
					self.createRoomFailed(const.CREATE_FAILED_NET_SERVER_ERROR)
					return
				data = json.loads(content)
				card_cost, diamond_cost = utility.calc_cost(game_type, create_dict)
				DEBUG_MSG("card_cost={} diamond_cost={}".format(card_cost, diamond_cost))
				if card_cost > data["card"] and diamond_cost > data["diamond"]:
					self.createRoomFailed(const.CREATE_FAILED_NO_ENOUGH_CARDS)
					return

				params = {
					'owner_uid'		: self.userId,
					'club_id'		: 0,
				}
				params.update(roomParamsGetter(game_type, create_dict))
				room = x42.GW.createRoom(game_type, params)
				if room:
					self.createRoomSucceed(room)
				else:
					self.createRoomFailed(const.CREATE_FAILED_OTHER)
			except:
				import traceback
				ERROR_MSG("createRoom callback content = {} error:{}".format(content, traceback.format_exc()))
				self.createRoomFailed(const.CREATE_FAILED_OTHER)
示例#3
0
文件: Club.py 项目: shacleff/PaSan
    def setDefaultRoomParams(self, avatar_mb, game_type, create_dict):
        create_dict['room_type'] = const.CLUB_ROOM
        if not roomParamsChecker(game_type, create_dict):
            avatar_mb.showTip("房间参数错误")
            return

        room_params = roomParamsGetter(game_type, create_dict)
        room_params['owner_uid'] = self.owner['userId']
        room_params['club_id'] = self.clubId
        self.gameType = game_type
        self.roomParams = room_params
        self.table_mgr.changeDefaultRoomParams(game_type, room_params)
        self.tableRoomParams.clear()
        event_args = {
            'game_type': game_type,
            'room_params': json.dumps(room_params),
        }
        self.event_mgr.push_event(Events.EVENT_DEFAULT_ROOM_PARAMS_CHANGE,
                                  event_args)