Example #1
0
		def callback(content):
			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] != '{':
					if getattr(self, 'client', None):
						self.createRoomFailed(const.CREATE_FAILED_NET_SERVER_ERROR)
					return
				data = json.loads(content)
				card_cost, diamond_cost = switch.calc_cost(game_round, {"pay_mode":pay_mode})
				if not KBEngine.globalData["GameWorld"].free_play and card_cost > data["card"] and diamond_cost > data["diamond"]:
					if getattr(self, 'client', None):
						self.client.createRoomFailed(const.CREATE_FAILED_NO_ENOUGH_CARDS)
					return
				params ={
					# 基本必填信息
					'owner_uid'			: self.userId,
					'player_num'		: 4,
					# client 2 svr
					# 'game_mode'			: game_mode,
					'game_round'		: game_round,
					'hand_prepare'		: hand_prepare,

					'pay_mode'			: pay_mode,
					'room_type'			: room_type,
				}
				KBEngine.createBaseAnywhere("GameRoom", params, self.createRoomCallback)
			except:
				err, msg, stack = sys.exc_info()
				DEBUG_MSG("createRoom callback error:{} , exc_info: {} ,{}".format(content, err, msg))
				self.createRoomFailed(const.CREATE_FAILED_OTHER)
Example #2
0
    def onTimer(self, tid, userArg):
        """
		KBEngine method.
		引擎回调timer触发
		"""
        if len(self.player) > 0:
            KBEngine.createBaseAnywhere("ClientManager")
Example #3
0
		def callback(content):
			content = content.decode()
			try:
				DEBUG_MSG("cards response: {}".format(content))
				if content[0] != '{':
					if getattr(self, 'client', None):
						self.client.createRoomFailed(const.CREATE_FAILED_OTHER)
					return
				data = json.loads(content)
				card_cost, diamond_cost = switch.calc_cost(game_round, player_num, pay_mode)
				if not KBEngine.globalData["GameWorld"].free_play and card_cost > data["card"] and diamond_cost > data["diamond"]:
					if getattr(self, 'client', None):
						self.client.createRoomFailed(const.CREATE_FAILED_NO_ENOUGH_CARDS)
					return
				params = {
					'owner_uid': self.userId,
					'player_num': player_num,
					'pay_mode': pay_mode,
					'win_quantity': win_quantity,
					'game_round': game_round,
					'king_num' : king_num,
					'is_agent': is_agent,
				}
				KBEngine.createBaseAnywhere("GameRoom", params, self.createRoomCallback)
			except:
				DEBUG_MSG("createRoom callback error:{}".format(content))
				if getattr(self, 'self', None):
					self.client.createRoomFailed(const.CREATE_FAILED_OTHER)
Example #4
0
		def callback(content):
			content = content.decode()
			try:
				DEBUG_MSG("cards response: {}".format(content))
				if content[0] != '{':
					if getattr(self, 'client', None):
						self.client.createRoomFailed(const.CREATE_FAILED_OTHER)
					return
				data = json.loads(content)
				card_cost, diamond_cost = switch.calc_cost(maxOldDealNum, maxLoseScore)
				if not KBEngine.globalData["GameWorld"].free_play and card_cost > data["card"] and diamond_cost > data["diamond"]:
					if getattr(self, 'client', None):
						self.client.createRoomFailed(const.CREATE_FAILED_NO_ENOUGH_CARDS)
					return
				params = {
					'owner_uid': self.userId,
					'game_round': 999,
					'lucky_tile': 0,
					"maxOldDealNum" : maxOldDealNum,
					"startOldDealNum" : startOldDealNum,
					"diceAddNum" : diceAddNum,
					"isSameAdd"	: isSameAdd,
					"maxLoseScore" : maxLoseScore,
					'is_agent': is_agent,
					"createRoomInfoList" : createRoomInfoList
				}
				KBEngine.createBaseAnywhere("GameRoom", params, self.createRoomCallback)
			except:
				DEBUG_MSG("createRoom callback error:{}".format(content))
				if getattr(self, 'self', None):
					self.client.createRoomFailed(const.CREATE_FAILED_OTHER)
Example #5
0
 def callback(content):
     content = content.decode()
     try:
         DEBUG_MSG("cards response: {}".format(content))
         if content[0] != '{':
             if getattr(self, 'client', None):
                 self.client.createRoomFailed(const.CREATE_FAILED_OTHER)
             return
         data = json.loads(content)
         card_cost, diamond_cost = switch.calc_cost(
             game_round, room_mode)
         if not KBEngine.globalData[
                 "GameWorld"].free_play and card_cost > data[
                     "card"] and diamond_cost > data["diamond"]:
             if getattr(self, 'client', None):
                 self.client.createRoomFailed(
                     const.CREATE_FAILED_NO_ENOUGH_CARDS)
             return
         params = {
             'owner_uid': self.userId,
             'room_mode': room_mode,
             'game_round': game_round,
             'insert_card': insert_card,
             'deal_mode': deal_mode,
             'score_mode': score_mode,
             'changeSeat': changeSeat,
             'best_phase': best_phase,
             'is_agent': is_agent,
         }
         KBEngine.createBaseAnywhere("GameRoom", params,
                                     self.createRoomCallback)
     except:
         DEBUG_MSG("createRoom callback error:{}".format(content))
         if getattr(self, 'self', None):
             self.client.createRoomFailed(const.CREATE_FAILED_OTHER)
Example #6
0
    def createRooms(self, player):
        """
		根据玩家人数,动态创建房间
		"""

        roomData = self.roomReqs.get(self.lastNewRoomID)

        if roomData is None or len(roomData["Reqs"]) >= 5:
            self.lastNewRoomID = len(self.rooms) + 1
            KBEngine.createBaseAnywhere(
                "ZjhRoom", {
                    "parent": self,
                    "roomID": self.lastNewRoomID,
                    "state": 0,
                    "dizhu": d_ZJH[self.hallID]["base"],
                    "limit": d_ZJH[self.hallID]["limit"],
                    "jzList": json.dumps(d_ZJH[self.hallID]["jzList"]),
                    "taxRate": d_ZJH["taxRate"]
                }, None)

            self.roomReqs[self.lastNewRoomID] = {"Reqs": [player.id]}

        else:
            if player.id not in roomData["Reqs"]:
                roomData["Reqs"].append(player)
Example #7
0
    def reqEnterClone(self, avatarMb, cloneID):

        # 加到等待创建队列
        self._pendingLogonEntities[avatarMb.id] = avatarMb
        # 创建副本
        param = {"cloneID": cloneID, "spaceKey": avatarMb.id}
        KBEngine.createBaseAnywhere("Clone", param, None)
Example #8
0
 def spawnSpaceObjects(self, tid):
     if len(self.tempObjsList) > 0:
         objData = self.tempObjsList.pop(0)
         objData['spaceToSpawn'] = self.cell
         KBEngine.createBaseAnywhere( "GeneralObj", objData )
     else:
         del self.tempObjsList
         self.delTimer(tid)
Example #9
0
	def spawnCreateMonster(self):
		center = Math.Vector3(101.4286, 0, 18.37545)

		KBEngine.createBaseAnywhere("SpawnPoint", 
					{"spawnEntityNO"	: 2001, 	\
					"position"			: center, 	\
					"direction"			: [0,0,0],		\
					"createToCell"		: self.cell})
    def createSpace(self, mapKey, spaceKey, context):
        if spaceKey <= 0:
            spaceKey = KBEngine.genUUID64()

        context = copy.copy(context)
        spaceData = d_Maps.Maps.get(mapKey)
        KBEngine.createBaseAnywhere( spaceData["entityType"], \
        {"mapKey":mapKey, "spaceKey":spaceKey, "context":context})
Example #11
0
 def createNewGroup(self, req_avatar, req_info, group_name):
     if not self.groupVisitReady:
         return
     # 公会重名检查 ..
     group_id = self.genGroupId()
     KBEngine.createBaseAnywhere("Group", {"owner_info": req_info, "group_id": group_id, "group_name": group_name},
                                 Functor.Functor(self.createNewGroupCbk, req_avatar, req_info["userId"], group_id,
                                                 group_name))
Example #12
0
	def __init__(self):
		KBEngine.Base.__init__(self)
		self.fieldPool=[]
		self.waiterList=[]
		for i in range(0,self.idleRoomNum):
			KBEngine.createBaseAnywhere("WarField",{},self.onCreateFieldOK)
		
		self.addTimer(0.5,0.5,0)
Example #13
0
    def createSpace(self, spaceKey, context):
        """
		"""
        context = copy.copy(context)
        spaceData = d_spaces.datas.get(self._utype)
        KBEngine.createBaseAnywhere(
            spaceData["entityType"],
            {"spaceUType": self._utype, "spaceKey": spaceKey, "context": context},
            Functor.Functor(self.onSpaceCreatedCB, spaceKey),
        )
Example #14
0
	def LoadAllSpace(self):
		INFO_MSG('Map::LoadAllSpace ')

		#默认创建5000个地图map_id为空的spaceloader
		for i in range(_INIT_MAP_COUNT):
			spaceKey = KBEngine.genUUID64()
			KBEngine.createBaseAnywhere("SpaceLoader", {'map_id':'',"spaceKey" : spaceKey,},
							   Functor.Functor(self.onMapLoaded, spaceKey))

		self.MapCount = _INIT_MAP_COUNT
Example #15
0
 def callback(content):
     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 = switch.calc_cost(
             game_round, {
                 "game_mode": game_mode,
                 "pay_mode": pay_mode,
                 "game_max_lose": game_max_lose
             })
         if not KBEngine.globalData[
                 "GameWorld"].free_play and card_cost > data[
                     "card"] and diamond_cost > data["diamond"]:
             self.createRoomFailed(const.CREATE_FAILED_NO_ENOUGH_CARDS)
             return
         params = {
             # 基本必填信息
             'owner_uid': self.userId,
             'king_num': 1,
             'player_num': 4,
             'lucky_num': 0,
             # client 2 svr
             'game_mode': game_mode,
             'base_score': base_score if game_mode == 0 else 1,
             'king_mode': play_list[0],
             'begin_dealer_mul': play_list[1],
             'win_mode': play_list[2],
             'three_job': play_list[3],
             'pong_useful': play_list[4],
             'bao_tou': play_list[5],
             'round_max_lose': round_max_lose if game_mode == 0 else 0,
             'game_max_lose':
             game_max_lose if game_mode == 1 else 999999,
             'game_round': game_round if game_mode == 0 else 999999,
             'hand_prepare': hand_prepare,
             'pay_mode': pay_mode,
             'room_type': room_type,
         }
         KBEngine.createBaseAnywhere("GameRoom", params,
                                     self.createRoomCallback)
     except:
         err, msg, stack = sys.exc_info()
         DEBUG_MSG(
             "createRoom callback error:{} , exc_info: {} ,{}".format(
                 content, err, msg))
         self.createRoomFailed(const.CREATE_FAILED_OTHER)
Example #16
0
    def onCreateRoom(self, args):

        roomID = args["roomID"]
        avatarMB = args["avatarMB"]
        actionType = args["actionType"]

        # 加到等待创建队列
        self._pendingLogonEntities[roomID] = args
        # 创建副本
        param = {"roomID": roomID, "actionType": actionType}
        KBEngine.createBaseAnywhere("Room", param, None)
Example #17
0
def onBaseAppReady(isBootstrap):#準備完成後創建第一個戰場,戰場用於生成空間
	"""
	KBEngine method.
	baseapp已经准备好了
	@param isBootstrap: 是否为第一个启动的baseapp
	@type isBootstrap: BOOL
	"""
	if isBootstrap:
		 KBEngine.createBaseAnywhere("Hall",{"idleRoomNum":5},addToOne)
	INFO_MSG('onBaseAppReady: isBootstrap=%s, appID=%s, bootstrapGroupIndex=%s, bootstrapGlobalIndex=%s' % \
	 (isBootstrap, os.getenv("KBE_COMPONENTID"), os.getenv("KBE_BOOTIDX_GROUP"), os.getenv("KBE_BOOTIDX_GLOBAL")))
Example #18
0
    def createSpace(self, spaceKey, context):
        """
		"""
        context = copy.copy(context)
        spaceData = d_spaces.datas.get(self._utype)
        KBEngine.createBaseAnywhere(spaceData["entityType"], \
                 {"spaceUType" : self._utype,	\
                 "spaceKey" : spaceKey,	\
                 "context" : context,	\
                 }, \
                 Functor.Functor(self.onSpaceCreatedCB, spaceKey))
Example #19
0
File: Games.py Project: ajue/llgame
    def _createGames(self):
        """
		callback
		根据配置创建出所有游戏
		"""
        for infos in d_games.datas.values():
            KBEngine.createBaseAnywhere(
                "Halls", {
                    "hallsID": infos["id"],
                    "hallsName": infos["gameName"],
                    "open": infos["open"]
                })
Example #20
0
    def _createHalls(self):
        """
		根据配置创建出所有的大厅
		"""
        for i in range(d_games.datas[self.hallsID]["hallCount"]):
            hallID = i + 1
            if self.hallsID == GAME_TYPE_DDZ:
                KBEngine.createBaseAnywhere(
                    "DdzHall", {"hallID": hallID},
                    Functor(self.onCreateBaseCallback, hallID))
            elif self.hallsID == GAME_TYPE_ZJH:
                KBEngine.createBaseAnywhere(
                    "Hall", {"hallID": hallID},
                    Functor(self.onCreateBaseCallback, hallID))
Example #21
0
	def createSpace(self, spaceKey, context):
		"""
		"""
		if spaceKey <= 0:
			spaceKey = KBEngine.genUUID64()
			
		context = copy.copy(context)
		spaceData = d_spaces.datas.get(self._utype)
		KBEngine.createBaseAnywhere(spaceData["entityType"], \
											{"spaceUType" : self._utype,	\
											"spaceKey" : spaceKey,	\
											"context" : context,	\
											}, \
											Functor.Functor(self.onSpaceCreatedCB, spaceKey))
Example #22
0
        def callback(content):
            try:
                DEBUG_MSG("cards response: {}".format(content))
                if content[0] != '{':
                    self.createRoomFailed(const.CREATE_FAILED_OTHER)
                    return
                data = json.loads(content)
                card_cost, diamond_cost = switch.calc_cost(room_op["game_round"])
                can_do = False
                if x42.GW.free_play:
                    can_do = True
                if card_cost and card_cost <= data['card']:
                    can_do = True
                if diamond_cost and diamond_cost <= data['diamond']:
                    can_do = True

                if not can_do:
                    self.createRoomFailed(const.CREATE_FAILED_NO_ENOUGH_CARDS)
                    return

                detail_op = {}
                detail_op["game_mode"] = game_mode
                # FIXME 测试用, 正式时候记得改回来
                # detail_op["game_round"] = game_round
                detail_op["game_round"] = 2
                detail_op["player_num"] = player_num
                detail_op["game_function"] = game_function
                detail_op["game_start"] = game_start
                detail_op["game_hei3"] = game_hei3
                detail_op["game_deal"] = game_deal
                detail_op["game_force"] = game_force
                detail_op["game_cardnum"] = game_cardnum
                detail_op["game_plays"] = game_plays
                detail_op["game_end"] = game_end
                detail_op["anticheating"] = anticheating
                detail_op["is_competition"] = is_competition
                detail_op["is_agent"] = is_agent

                detail_op.setdefault("match_mode", belong_info["match_mode"])
                detail_op.setdefault("group_id", belong_info["group_id"])
                detail_op.setdefault("team_uuid", belong_info["team_uuid"])
                detail_op.setdefault("sportId", belong_info["sportId"])
                detail_op.setdefault("owner_uid", self.userId)
                detail_op.setdefault("create_time", time.time())

                DEBUG_MSG("reqCreate----GroupRoom", detail_op)
                KBEngine.createBaseAnywhere("GameRoom", detail_op, self.createRoomCallback)
            except:
                self.createRoomFailed(const.CREATE_FAILED_OTHER)
Example #23
0
 def callback(content):
     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 = switch.calc_cost(
             game_round, {
                 "round_mode": round_mode,
                 "pay_mode": pay_mode
             })
         if not KBEngine.globalData[
                 "GameWorld"].free_play and card_cost > data[
                     "card"] and diamond_cost > data["diamond"]:
             self.createRoomFailed(const.CREATE_FAILED_NO_ENOUGH_CARDS)
             return
         params = {
             'owner_uid': self.userId,
             'king_num': 1,
             'player_num': 4,
             'game_round': game_round,
             'round_mode': round_mode,
             'base_score_mode': base_score_mode,
             'pay_mode': pay_mode,
             'game_mode': game_mode,
             'king_mode': king_mode,
             'max_lose': max_lose,
             'score': score,
             'job': job,
             'discard_seconds': discard_seconds,
             'hand_prepare': hand_prepare,
             'room_type': room_type,
         }
         KBEngine.createBaseAnywhere("GameRoom", params,
                                     self.createRoomCallback)
     except:
         err, msg, stack = sys.exc_info()
         DEBUG_MSG(
             "createRoom callback error:{} , exc_info: {} ,{}".format(
                 content, err, msg))
         self.createRoomFailed(const.CREATE_FAILED_OTHER)
Example #24
0
 def startGame(self, name, auth, charType):
     if self.activeAvatar is None:
         avatarDic = {
             "name": name,
             "authority": auth,
             "characterType": charType,
             "isDebug": 0
         }
         KBEngine.createBaseAnywhere("Avatar", avatarDic,
                                     self.onGameStarted)
         ##############################
         #debugAvatarDic = { "name":"DebugAvatar", "authority":0, "characterType":0 , "isDebug":1}
         #self.debugAvatar = KBEngine.createBaseLocally("Avatar" , debugAvatarDic)
         ##############################
     else:
         self.client.onGameStarted(0)
	def createSpace(self, spaceKey, context):
		"""
		"""
		if spaceKey <= 0:
			spaceKey = KBEngine.genUUID64()
		
		context = copy.copy(context)
		spaceData = d_spaces.datas.get(self._utype)
		KBEngine.createBaseAnywhere(spaceData["entityType"], \
											{"spaceUType" : self._utype,	\
											"spaceKey" : spaceKey,	\
											"context" : context,	\
											}, \
											Functor.Functor(self.onSpaceCreatedCB, spaceKey))
		
		DEBUG_MSG("[BaseApp] SpaceAlloc::createSpace called, utype: %i, spaceKey: %s, entityType: %s" % (self._utype, spaceKey, spaceData["entityType"]))
Example #26
0
	def onTimer( self, timerHandle, userData ):
		if len(self.waiterList)<=0 or len(self.fieldPool)<=0:#如果没有人在等待或者没有空闲的房间
			return
		else:
			'''for i in range(0,int(len(self.waiterList)/2)):
				self.fieldPool[0].addPlayer(self.waiterList[2*i])
				self.fieldPool[0].addPlayer(self.waiterList[2*i+1])
				del self.fieldPool[0]'''
			while len(self.waiterList)>=2:#如果还有2个或以上的等待玩家的话
				self.fieldPool[0].addPlayer(self.waiterList[0])
				self.fieldPool[0].addPlayer(self.waiterList[1])
				self.waiterList=self.waiterList[2:]
				del self.fieldPool[0]
				if len(self.fieldPool)<=0:#如果已经没有空闲的房间
					return
		for i in range(0,self.idleRoomNum-len(self.fieldPool)):
			KBEngine.createBaseAnywhere("WarField",{},self.onCreateFieldOK)
Example #27
0
    def createSpace(self, spaceKey, context):
        """
		"""
        if spaceKey <= 0:
            spaceKey = KBEngine.genUUID64()

        context = copy.copy(context)
        spaceData = d_mapinfo.datas.get(self._utype)
        name = "Space"
        if spaceData["type"] == 1:
            name = "SpaceDuplicate"
        KBEngine.createBaseAnywhere(name, \
                 {"spaceUType" : self._utype,	\
                 "spaceKey" : spaceKey,	\
                 "context" : context,	\
                 }, \
                 Functor.Functor(self.onSpaceCreatedCB, spaceKey))
Example #28
0
    def spawnOnTimer(self, tid, tno):
        """
		出生怪物
		"""
        if len(self.tmpCreateEntityDatas) <= 0:
            self.delTimer(tid)
            return

        datas = self.tmpCreateEntityDatas.pop(0)

        if datas is None:
            ERROR_MSG("Space::onTimer: spawn %i is error!" % datas[0])

        KBEngine.createBaseAnywhere("SpawnPoint",
               {"spawnEntityNO" : datas[0], 	\
               "position"   : datas[1], 	\
               "direction"   : (0, 0, datas[2]),	\
               "createToCell"  : self.cell})
Example #29
0
    def spawnOnTimer(self, tid, tno):
        """
		出生怪物
		"""
        if len(self.tmpCreateEntityDatas) <= 0:
            self.delTimer(tid)
            return

        entityNO = self.tmpCreateEntityDatas.pop(0)
        datas = d_entities.datas.get(entityNO)

        if datas is None:
            ERROR_MSG("Space::onTimer: spawn %i is error!" % entityNO)

        KBEngine.createBaseAnywhere("SpawnPoint",
               {"spawnEntityNO" : entityNO, 	\
               "position"   : tuple(datas.get('spawnPos', (0,0,0))), 	\
               "direction"   : (0, 0, datas.get("spawnYaw", 0)),	\
               "createToCell"  : self.cell})
Example #30
0
	def spawnOnTimer(self, tid, tno):
		"""
		出生怪物
		"""
		if len(self.tmpCreateEntityDatas) <= 0:
			self.delTimer(tid)
			return
			
		datas = self.tmpCreateEntityDatas.pop(0)
		
		if datas is None:
			ERROR_MSG("Space::onTimer: spawn %i is error!" % datas[0])

		KBEngine.createBaseAnywhere("SpawnPoint", 
									{"spawnEntityNO"	: datas[0], 	\
									"position"			: datas[1], 	\
									"direction"			: datas[2],		\
									"modelScale"		: datas[3],		\
									"createToCell"		: self.cell})
Example #31
0
	def spawnOnTimer(self, tid, tno):
		"""
		出生怪物
		"""
		if len(self.tmpCreateEntityDatas) <= 0:
			self.delTimer(tid)
			return
			
		entityNO = self.tmpCreateEntityDatas.pop(0)
		datas = d_entities.datas.get(entityNO)
		
		if datas is None:
			ERROR_MSG("Space::onTimer: spawn %i is error!" % entityNO)

		KBEngine.createBaseAnywhere("SpawnPoint", 
									{"spawnEntityNO"	: entityNO, 	\
									"position"			: tuple(datas.get('spawnPos', (0,0,0))), 	\
									"direction"			: (0, 0, datas.get("spawnYaw", 0)),	\
									"createToCell"		: self.cell})
Example #32
0
    def findRoom(self, roomID, notFoundCreate=False):
        """
        查找一个指定房间,如果找不到允许创建一个新的
        """
        DEBUG_MSG("DdzHall::findRoom self.rooms[%r]" % (self.rooms.keys()))
        roomDatas = self.rooms.get(roomID)

        # 如果房间没有创建,则将其创建
        if not roomDatas:
            if not notFoundCreate:
                return FIND_ROOM_NOT_FOUND

            # 如果最后创建的房间没有满员,则使用最后创建的房间key,否则产生一个新的房间唯一Key
            roomDatas = self.rooms.get(self.lastNewRoomKey)
            if roomDatas is not None and len(roomDatas["players"]) < 3:
                if roomDatas["roomMailbox"] is not None and roomDatas[
                        "roomMailbox"].state != ROOM_STATE_READY:
                    pass
                else:
                    return roomDatas

            self.lastNewRoomKey = KBEngine.genUUID64()

            KBEngine.createBaseAnywhere(
                "DdzRoom", {
                    "parent": self,
                    "state": 0,
                    "roomID": self.lastNewRoomKey,
                    "difen": d_DDZ[self.hallID]["base"],
                    "taxRate": d_DDZ["taxRate"]
                }, None)

            roomDatas = {
                "roomMailbox": None,
                "players": {},
                "roomID": self.lastNewRoomKey
            }
            self.rooms[self.lastNewRoomKey] = roomDatas

            return roomDatas

        return roomDatas
Example #33
0
	def ExtendIdleMap(self):
		if self.State==_STATE_MAP_LOADING:
			return

		IdleMapCount=self.GetIdleMapCount()

		if IdleMapCount<=_INIT_MAP_COUNT*0.2:
			#当当前空闲分线的数量小于等于原空闲分线副本数量的80%时,开始新创建分线
			for i in range(_EXTEND_MAP_COUNT):

				spaceKey = KBEngine.genUUID64()

			KBEngine.createBaseAnywhere("SpaceLoader", {'map_id':'',"spaceKey" : spaceKey,},
							   Functor.Functor(self.onMapLoaded, spaceKey))

			self.State=_STATE_MAP_LOADING

			self.MapCount=self.MapCount+_EXTEND_MAP_COUNT

			DEBUG_MSG("MapMgr:ExtendIdleMap:self.MapCount=%i"% self.MapCount)
Example #34
0
    def onTimer(self, id, userArg):
        """
		KBEngine method.
		使用addTimer后, 当时间到达则该接口被调用
		@param id		: addTimer 的返回值ID
		@param userArg	: addTimer 最后一个参数所给入的数据
		"""
        if userArg == 1:
            if len(self.tmpCreateEntityDatas) <= 0:
                self.delTimer(id)
                return

            entityNO = self.tmpCreateEntityDatas.pop(0)
            KBEngine.createBaseAnywhere(
                "SpawnPoint",
                {
                    "spawnEntityNO": entityNO,
                    "position": (random.randint(-512, 512), 250, random.randint(-512, 512)),
                    "direction": (0, 0, 0),
                    "createToCell": self.cell,
                },
            )
Example #35
0
	def onTimer(self, id, userArg):
		"""
		KBEngine method.
		使用addTimer后, 当时间到达则该接口被调用
		@param id		: addTimer 的返回值ID
		@param userArg	: addTimer 最后一个参数所给入的数据
		"""
		if userArg == 1:
			if len(self.tmpCreateEntityDatas) <= 0:
				self.delTimer(id)
				return
				
			entityNO = self.tmpCreateEntityDatas.pop(0)
			datas = d_entities.datas.get(entityNO)
			
			if datas is None:
				ERROR_MSG("Space::onTimer: spawn %i is error!" % entityNO)
	
			KBEngine.createBaseAnywhere("SpawnPoint", 
										{"spawnEntityNO"	: entityNO, 	\
										"position"			: tuple(datas.get('spawnPos', (0,0,0))), 	\
										"direction"			: (0, 0, datas.get("spawnYaw", 0)),	\
										"createToCell"		: self.cell})
Example #36
0
    def findRoom(self, roomKey, notFoundCreate=False):
        """
		查找一个指定房间,如果找不到允许创建一个新的
		"""
        roomDatas = self.rooms.get(roomKey)

        # 如果房间没有创建,则将其创建
        if not roomDatas:
            if not notFoundCreate:
                return FIND_ROOM_NOT_FOUND

            # 如果最后创建的房间没有满员,则使用最后创建的房间key,否则产生一个新的房间唯一Key
            roomDatas = self.rooms.get(self.lastNewRoomKey)
            if roomDatas is not None and roomDatas[
                    "PlayerCount"] < GameConfigs.ROOM_MAX_PLAYER:
                return roomDatas

            self.lastNewRoomKey = KBEngine.genUUID64()

            # 将房间base实体创建在任意baseapp上
            # 此处的字典参数中可以对实体进行提前def属性赋值
            KBEngine.createBaseAnywhere("Room", \
                  {
                  "roomKey" : self.lastNewRoomKey,	\
                  }, \
                  Functor.Functor(self.onRoomCreatedCB, self.lastNewRoomKey))

            roomDatas = {
                "roomMailbox": None,
                "PlayerCount": 0,
                "enterRoomReqs": [],
                "roomKey": self.lastNewRoomKey
            }
            self.rooms[self.lastNewRoomKey] = roomDatas
            return roomDatas

        return roomDatas
Example #37
0
    def CreatBattleField(self, player1, player2):
        #成功匹配完成后再调用一次匹配 增加匹配的效率
        DEBUG_MSG("Start a battle player1:%i player2:%i" %
                  (player1.id, player2.id))
        if player1.isDestroyed or player2.isDestroyed:
            if player1.isDestroyed:
                self.OnMarchingPlayer.remove(player1)
            if player2.isDestroyed:
                self.OnMarchingPlayer.remove(player2)
            DEBUG_MSG("March Fail because One is destroyed")
            return
        DEBUG_MSG("Battle March Successed player1:%i player2:%i" %
                  (player1.id, player2.id))

        prarm = {"player0": player1, "player1": player2}

        BattleField = KBEngine.createBaseAnywhere("BattleField", prarm)
        if player1 in self.OnMarchingPlayer:
            self.OnMarchingPlayer.remove(player1)
        if player2 in self.OnMarchingPlayer:
            self.OnMarchingPlayer.remove(player2)
        self.March()