Exemplo n.º 1
0
	def createRoomCallback(self, room, err = None):
		DEBUG_MSG("createRoomCallback")
		if room:
			room.roomID = utility.gen_room_id(room.id)
			if room.is_agent == 1:
				def callback(content):
					try:
						content = content.decode()
						if content[0] != '{':
							DEBUG_MSG(content)
							return
						room.reqEnterRoom(self, True)
						self.room = room
						KBEngine.globalData["GameWorld"].addRoom(room)
						info = room.get_init_client_dict()
						if getattr(self, 'client', None):
							self.client.createRoomSucceed(info)
					except:
						DEBUG_MSG("agent consume callback error:{}".format(content))
				card_cost, diamond_cost = switch.calc_cost(room.game_round, room.player_num, room.pay_mode)
				if switch.DEBUG_BASE:
					callback('{"card":99, "diamond":999}'.encode())
				else:
					utility.update_card_diamond(self.accountName, -card_cost, -diamond_cost ,callback, "NingBoMJ RoomID:{}".format(self.roomID)) # reason 必须为英文
			else:
				room.reqEnterRoom(self, True)
				self.room = room
				KBEngine.globalData["GameWorld"].addRoom(room)
				info = room.get_init_client_dict()
				if getattr(self, 'client', None):
					self.client.createRoomSucceed(info)
		else:
			if getattr(self, 'client', None):
				self.client.createRoomFailed(const.CREATE_FAILED_OTHER)
Exemplo n.º 2
0
    def __init__(self):
        KBEngine.Entity.__init__(self)
        GameObject.__init__(self)

        self.roomID = utility.gen_room_id()
        self.cellData["roomIDC"] = self.roomID
        self.cellData["gameTypeC"] = self.gameType
        self.cellData["roomParamsC"] = self.roomParams
        self.init_from_dict(self.roomParams)
        # 请求在cellapp上创建cell空间'Room_GXMJ
        self.createCellEntityInNewSpace(None)
        self.request = []
        self.avatars = {}
        # 房间状态, 是否已经扣卡开始游戏
        self.state = const.ROOM_WAITING
        # 座位信息
        self.seatInfo = []
        # 亲友圈所属房间, 记录自己是哪一桌的
        self.club_table = None
        # 进行到的当前局数
        self.current_round = 0
        # 被解散原因
        self.destroyReason = None
Exemplo n.º 3
0
	def __init__(self):
		BaseEntity.__init__(self)
		GameObject.__init__(self)
		iRoomRules.__init__(self)

		self.agent = None
		self.roomID = utility.gen_room_id()

		# 状态0:未开始游戏, 1:某一局游戏中
		self.state = const.ROOM_WAITING

		# 存放该房间内的玩家mailbox
		self.players_dict = {}
		self.players_list = [None] * self.player_num
		self.origin_players_list = [None] * self.player_num

		# 打出财神的index
		self.discard_king_idx = -1

		# 庄家index
		self.dealer_idx = 0
		# 当前控牌的玩家index
		self.current_idx = 0
		# 对当前打出的牌可以进行操作的玩家的index, 服务端会限时等待他的操作
		# 房间基础轮询timer
		self._poll_timer = None
		# 玩家操作限时timer
		self._op_timer = None
		# 一局游戏结束后, 玩家准备界面等待玩家确认timer
		self._next_game_timer = None

		#财神(多个)
		self.kingTiles = []
		#圈风
		self.prevailing_wind = const.WIND_EAST
		#一圈中玩家坐庄次数
		self.dealerNumList = [0] * self.player_num

		self.current_round = 0
		self.all_discard_tiles = []
		# 最后一位出牌的玩家
		self.last_player_idx = -1
		# 房间开局所有操作的记录(aid, src, des, tile)
		self.op_record = []
		# 房间开局操作的记录对应的记录id
		self.record_id = -1
		# 确认继续的玩家
		self.confirm_next_idx = []
		# 解散房间操作的发起者
		self.dismiss_room_from = -1
		# 解散房间操作开始的时间戳
		self.dismiss_room_ts = 0
		# 解散房间操作投票状态
		self.dismiss_room_state_list = [0] * self.player_num
		self.dismiss_timer = None
		# 房间创建时间
		self.roomOpenTime = time.time()
		# 玩家操作列表
		self.wait_op_info_list = []
		# 杠后摸牌延时操作时的标志位,例如主要在延时中出现解散房间操作时需要拒绝操作,同上
		self.wait_force_delay_kong_draw = False

		# 牌局记录
		self.game_result = {}
		# 当前老庄数
		self.cur_dealer_mul = self.begin_dealer_mul

		# 房间所属的茶楼桌子, 仅茶楼中存在
		self.club_table = None
		# 增加房间销毁定时器
		self.timeout_timer = self.add_timer(const.ROOM_TTL, self.timeoutDestroy)

		# 本轮出牌分数
		self.curround_score = 0
		# 一轮刚开始的标志
		self.round_start = True
		# 玩家要不起的标志位
		self.op_pass_flag = 0
		# 玩家胜利个数,每当有玩家胜利,个数加一
		self.player_win_num = 0
		# 控牌玩家出牌列表
		self.controller_discard_list = []
		# 等待出牌的玩家
		self.waitIdx = -1
		# 玩家出牌列表
		self.deskPokerList = [[],[],[],[]]
		# 胜利玩家列表
		self.win_list = []
		# 玩家本局游戏彻底结束的列表
		self.round_end_list = []
		# 玩家本局得分(除了奖励分)
		self.curScoreList = [0] * self.player_num
		# 玩家本局最终得分(除了奖励分)
		self.lastScoreList = [0] * self.player_num
		# 玩家本局得奖
		self.curPrizeList = [0] * self.player_num
Exemplo n.º 4
0
	def __init__(self):
		BaseEntity.__init__(self)
		GameObject.__init__(self)
		iRoomRules.__init__(self)

		self.agent = None
		self.roomID = utility.gen_room_id()

		# 状态0:未开始游戏, 1:某一局游戏中
		self.state = const.ROOM_WAITING

		# 存放该房间内的玩家mailbox
		self.players_dict = {}
		self.players_list = [None] * self.player_num
		self.origin_players_list = [None] * self.player_num

		# 打出财神的index
		self.discard_king_idx = -1

		# 庄家index
		self.dealer_idx = 0
		# 当前控牌的玩家index
		self.current_idx = 0
		# 对当前打出的牌可以进行操作的玩家的index, 服务端会限时等待他的操作
		# 房间基础轮询timer
		self._poll_timer = None
		# 玩家操作限时timer
		self._op_timer = None
		# 一局游戏结束后, 玩家准备界面等待玩家确认timer
		self._next_game_timer = None

		#财神(多个)
		self.kingTiles = []
		#圈风
		self.prevailing_wind = const.WIND_EAST
		#一圈中玩家坐庄次数
		self.dealerNumList = [0] * self.player_num

		self.current_round = 0
		self.all_discard_tiles = []
		# 最后一位出牌的玩家
		self.last_player_idx = -1
		# 房间开局所有操作的记录(aid, src, des, tile)
		self.op_record = []
		# 房间开局操作的记录对应的记录id
		self.record_id = -1
		# 确认继续的玩家
		self.confirm_next_idx = []
		# 解散房间操作的发起者
		self.dismiss_room_from = -1
		# 解散房间操作开始的时间戳
		self.dismiss_room_ts = 0
		# 解散房间操作投票状态
		self.dismiss_room_state_list = [0] * self.player_num
		self.dismiss_timer = None
		# 房间创建时间
		self.roomOpenTime = time.time()
		# 玩家操作列表
		self.wait_op_info_list = []
		# 杠后摸牌延时操作时的标志位,例如主要在延时中出现解散房间操作时需要拒绝操作,同上
		self.wait_force_delay_kong_draw = False

		# 过胡状态
		self.pass_win_list = [0] * self.player_num
		# 听牌所在位置
		self.tingTileList = [0] * self.player_num
		# 可胡牌列表,只记录能获胜的玩家的胡牌列表
		self.canWinTiles = []

		# 牌局记录
		self.game_result = {}

		# 房间所属的茶楼桌子, 仅茶楼中存在
		self.club_table = None
		# 增加房间销毁定时器
		self.timeout_timer = self.add_timer(const.ROOM_TTL, self.timeoutDestroy)
Exemplo n.º 5
0
	def __init__(self):
		BaseEntity.__init__(self)
		GameObject.__init__(self)
		iRoomRules.__init__(self)

		self.agent = None
		self.roomID = utility.gen_room_id()

		# 状态0:未开始游戏, 1:某一局游戏中
		self.state = const.ROOM_WAITING

		# 存放该房间内的玩家mailbox
		self.players_dict = {}
		self.players_list = [None] * self.player_num
		self.origin_players_list = [None] * self.player_num

		# 庄家index
		self.dealer_idx = -1
		# 当前控牌的玩家index
		self.current_idx = 0
		# 对当前打出的牌可以进行操作的玩家的index, 服务端会限时等待他的操作
		# 房间基础轮询timer
		self._poll_timer = None
		# 玩家操作限时timer
		self._op_timer = None
		# 玩家操作限时timer 启动时间
		self._op_timer_timestamp = 0
		# 一局游戏结束后, 玩家准备界面等待玩家确认timer
		self._next_game_timer = None

		self.current_round = 0
		self.last_player_idx = -1
		# 房间开局所有操作的记录(aid, src, des, [data])
		self.op_record = []
		# 房间开局操作的记录对应的记录id
		self.record_id = -1
		# 确认继续的玩家
		self.confirm_next_idx = []
		# 解散房间操作的发起者
		self.dismiss_room_from = -1
		# 解散房间操作开始的时间戳
		self.dismiss_room_ts = 0
		# 解散房间操作投票状态
		self.dismiss_room_state_list = [0] * self.player_num
		self.dismiss_timer = None
		# 房间创建时间
		self.roomOpenTime = time.time()
		# 玩家操作列表
		self.wait_op_info_list = []
		# 牌局记录
		self.game_result = {}
		# 房间所属的茶楼桌子, 仅茶楼中存在
		self.club_table = None
		# 增加房间销毁定时器
		self.timeout_timer = self.add_timer(const.ROOM_TTL, self.timeoutDestroy)
		# 抢庄倍数(0不抢, 1:一倍....)
		self.fight_dealer_mul_list = [-1] * self.player_num
		# 叫地主分数
		self.bet_score_list = [-1] * self.player_num
		self.cur_allow_op = const.OP_NONE
		# 续房的标记
		self._continue_room_flag = False
		# 地主的三张牌
		self.host_cards = []
		self.last_discard_idx = -1
		self.discard_record = LimitQueue(3)
		# 上一个win的玩家
		self.last_win_idx = 0
		self.boom_times = 0