Esempio n. 1
0
    def onBootStart(self, bootstrapIdx):
        """
		virtual method.
		被引导时触发
		"""
        if bootstrapIdx == 1:
            # 创建spacemanager
            KBEngine.createBaseLocally("Spaces", {})
Esempio n. 2
0
	def onBootStart(self, bootstrapIdx):
		"""
		virtual method.
		被引导时触发
		"""
		if bootstrapIdx == 1:
			# 创建spacemanager
			KBEngine.createBaseLocally( "Spaces", {} )
Esempio n. 3
0
    def onTimer(self, tid, userArg):
        if ConstDefine.TIMER_TYPE_CREATE_HANDS == userArg:
            self.leftHand = KBEngine.createBaseLocally("Hand",{"isLeft":1, "avatarEntityID":self.id, "isDebug":self.isDebug})
            self.rightHand = KBEngine.createBaseLocally("Hand",{"isLeft":0, "avatarEntityID":self.id, "isDebug":self.isDebug})
            self.delTimer(tid)

            if self.WaitForHands != None:
                self.loginToSpace(self.WaitForHands)
                del self.WaitForHands
Esempio n. 4
0
def onBaseAppReady(bootstrapIdx):
	"""
	KBEngine method.
	baseapp已经准备好了
	@param isBootstrap: 是否是第一个baseapp启动
	@type isBootstrap: bool
	"""
	DEBUG_MSG('baseapp准备完毕! bootstrapIdx=%s' % bootstrapIdx)
	if bootstrapIdx == 1:
		# 创建spacemanager
		KBEngine.createBaseLocally( "Spaces", {} )
Esempio n. 5
0
def onBaseAppReady(isBootstrap):
    """
	KBEngine method.
	baseapp已经准备好了
	@param isBootstrap: 是否为第一个启动的baseapp
	@type isBootstrap: BOOL
	"""
    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")))
    if isBootstrap:
        KBEngine.createBaseLocally("Hall", {})
Esempio n. 6
0
def onBaseAppReady(bootstrapIdx):
    """
	KBEngine method.
	baseapp已经准备好了
	@param isBootstrap: 是否是第一个baseapp启动
	@type isBootstrap: bool
	"""
    INFO_MSG('onBaseAppReady: bootstrapIdx=%s' % bootstrapIdx)
    KBEngine.addWatcher("scripts/countPlayers", "UINT32", countPlayers)

    if bootstrapIdx == 1:
        # 创建spacemanager
        KBEngine.createBaseLocally("Spaces", {})
Esempio n. 7
0
def onBaseAppReady(bootstrapIdx):
	"""
	KBEngine method.
	baseapp已经准备好了
	@param bootstrapIdx: 当前baseapp的启动顺序
	@type bootstrapIdx: INT32
	"""
	INFO_MSG('onBaseAppReady: bootstrapIdx=%s' % bootstrapIdx)
	KBEngine.addWatcher("players", "UINT32", countPlayers)
	
	if bootstrapIdx == 1:
		# 创建spacemanager
		KBEngine.createBaseLocally( "Spaces", {} )
Esempio n. 8
0
def onBaseAppReady(bootstrapIdx):
    """
	KBEngine method.
	baseapp已经准备好了
	@param bootstrapIdx: 当前baseapp的启动顺序
	@type bootstrapIdx: INT32
	"""
    INFO_MSG('onBaseAppReady: bootstrapIdx=%s' % bootstrapIdx)
    KBEngine.addWatcher("players", "UINT32", countPlayers)

    if bootstrapIdx == 1:
        # 创建spacemanager
        KBEngine.createBaseLocally("Spaces", {})
Esempio n. 9
0
def onBaseAppReady(bootstrapIdx):
	"""
	KBEngine method.
	baseapp已经准备好了
	@param isBootstrap: 是否是第一个baseapp启动
	@type isBootstrap: bool
	"""
	INFO_MSG('onBaseAppReady: bootstrapIdx=%s' % bootstrapIdx)
	KBEngine.addWatcher("scripts/countPlayers", "UINT32", countPlayers)
	
	if bootstrapIdx == 1:
		# 创建spacemanager
		KBEngine.createBaseLocally( "Spaces", {} )
Esempio n. 10
0
def onBaseAppReady(isBootstrap):
    """
	KBEngine method.
	baseapp已经准备好了
	@param isBootstrap: 是否为第一个启动的baseapp
	@type isBootstrap: BOOL
	"""
    INFO_MSG('onBaseAppReady: isBootstrap=%s' % isBootstrap)

    # 安装监视器
    Watcher.setup()

    if isBootstrap:
        # 创建spacemanager
        KBEngine.createBaseLocally("Spaces", {})
Esempio n. 11
0
def onBaseAppReady(isBootstrap):
	"""
	KBEngine method.
	baseapp已经准备好了
	@param isBootstrap: 是否为第一个启动的baseapp
	@type isBootstrap: BOOL
	"""
	INFO_MSG('onBaseAppReady: isBootstrap=%s' % isBootstrap)
	
	# 安装监视器
	Watcher.setup()
	
	if isBootstrap:
		# 创建spacemanager
		KBEngine.createBaseLocally( "Spaces", {} )
Esempio n. 12
0
def onBaseAppReady(isBootstrap):
    """
    KBEngine method.
    baseapp已经准备好了
    @param isBootstrap: 是否为第一个启动的baseapp
    @type isBootstrap: BOOL
    """
    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")))
    if isBootstrap:
        DEBUG_MSG("isBootstrap")
        if "WorldManager" not in KBEngine.globalData.keys():
            DEBUG_MSG("create WorldManager")
            KBEngine.createBaseLocally("WorldManager", {})
Esempio n. 13
0
    def reqCreateAvatar(self, globalBirthDict):
        """ 根据前端类别给出出生点
		UNKNOWN_CLIENT_COMPONENT_TYPE	= 0,
		CLIENT_TYPE_MOBILE				= 1,	// 手机类
		CLIENT_TYPE_PC					= 2,	// pc, 一般都是exe客户端
		CLIENT_TYPE_BROWSER				= 3,	// web应用, html5,flash
		CLIENT_TYPE_BOTS				= 4,	// bots
		CLIENT_TYPE_MINI				= 5,	// 微型客户端
		"""
        props = {
            "name": self.__ACCOUNT_NAME__,
            "uuid": KBEngine.genUUID64(),
            "gender": random.randint(0, 1),
            "lastLoginTime": time.time(),
            "accountName": self.__ACCOUNT_NAME__,
        }

        for key in globalBirthDict:
            if key not in props:
                props[key] = globalBirthDict[key]

        DEBUG_MSG('Account(%i) name[%s]::reqCreateAvatar: %d' %
                  (self.id, self.__ACCOUNT_NAME__, props.get("userId", 0)))
        avatar = KBEngine.createBaseLocally("Avatar", props)
        if avatar:
            avatar.writeToDB(self._onCharacterSaved)
Esempio n. 14
0
    def onCreateCallBack(baseRef, databaseID, wasActive):
        if baseRef:
            DEBUG_MSG(
                "createSingletonFromDB: %s create from DB success, databaseID:[%i]"
                % (entityName, databaseID))
            baseRef.writeToDB()
            # 向全局共享数据中注册这个管理器的mailbox以便在所有逻辑进程中可以方便的访问
            KBEngine.globalData[globalname] = baseRef
        else:
            WARNING_MSG("createSingletonFromDB: %s create from DB failed" %
                        entityName)
            singleton = KBEngine.createBaseLocally(entityName, props)

            def onWriteToDB(success, entity):
                if success:
                    DEBUG_MSG(
                        "createSingletonFromDB: %s writeToDB success, dbid:[%i]"
                        % (entityName, entity.databaseID))
                    entity.writeToDB(
                    )  # TODO, to delete if auto-writeToDB each 15 min
                    KBEngine.globalData[globalname] = entity
                else:
                    ERROR_MSG("createSingletonFromDB: %s writeToDB failed" %
                              entityName)

            singleton.writeToDB(onWriteToDB)
Esempio n. 15
0
    def createClub(self, avatar_mb, club_name, club_params_dict):
        if avatar_mb.isAgent != 1:
            avatar_mb.clubOperationFailed(const.CLUB_OP_ERR_PERMISSION_DENY)
            return

        club_name = utility.filter_emoji(club_name)
        club_name = club_name[:const.CLUB_NAME_LENGTH]
        self.clubCount += 1
        club_id = utility.gen_club_id(self.clubCount)
        owner_info = {
            'userId': avatar_mb.userId,
            'uuid': avatar_mb.uuid,
            'sex': avatar_mb.sex,
            'nickname': avatar_mb.name,
            'head_icon': avatar_mb.head_icon,
            'accountName': avatar_mb.accountName,
        }
        params = {
            'clubId': club_id,
            'name': club_name,
            'owner': owner_info,
            'roomType': club_params_dict,
        }
        INFO_MSG("ClubStub player{} createClub {}".format(
            avatar_mb.userId, params))
        club = KBEngine.createBaseLocally("Club", params)
        if club:
            club.writeToDB(Functor(self._onClubSaved, avatar_mb, owner_info))
Esempio n. 16
0
def _dbCmdSelectCB(resultCollect, num, errorInfo):
    DEBUG_MSG(resultCollect)
    DEBUG_MSG(num)
    # DEBUG_MSG(errorInfo)
    if errorInfo is not None:
        DEBUG_MSG("error")
        KBEngine.executeRawDatabaseCommand(
            "CREATE TABLE mini_Spaces (name VARCHAR(255) NOT NULL DEFAULT '' primary key, dbid BIGINT)",
            _dbCmdCreateTblCB)
    else:
        DEBUG_MSG("not error")
        if not resultCollect:
            DEBUG_MSG("resultCollect == []")
            bigWorld = KBEngine.createBaseLocally("BigWorld", {})
            if bigWorld:
                DEBUG_MSG("create bigWorld success")
                bigWorld.writeToDB(_bigWorldSavedCB)
                # KBEngine.executeRawDatabaseCommand("INSERT INTO mini_Spaces VALUES ('BigWorld', 0)",
                # _dbCmdInsertBigWorldCB)
            else:
                ERROR_MSG("create bigWorld failed")
        else:
            for value in resultCollect:
                if value[0] == b'BigWorld':
                    DEBUG_MSG("==b")
                    if value[1] != 0:
                        KBEngine.createBaseFromDBID(
                            "BigWorld", int(value[1].decode('ascii')),
                            _onBigWorldCreateCB)
                        DEBUG_MSG(int(value[1].decode('ascii')))
                        return
Esempio n. 17
0
	def reqCreateAvatar(self, roleType, name):
		"""
		exposed.
		客户端请求创建一个角色
		"""
		avatarinfo = {"name": name, "dbid": 0, "roleType" : roleType, "level" : 0}
			
		"""
		if name in all_avatar_names:
			retcode = 2
			self.client.onCreateAvatarResult(retcode, avatarinfo)
			return
		"""
		
		if len(self.characters) >= 3:
			DEBUG_MSG("Account[%i].reqCreateAvatar:%s. character=%s.\n" % (self.id, name, self.characters))
			self.client.onCreateAvatarResult(3, avatarinfo)
			return
			
		props = {
			"name"				: name,
			"roleType"			: roleType,
			"level"				: 1,
			"spaceUType"		: d_avatar_inittab.datas[roleType]["spaceUType"],
			"direction"			: (0, 0, d_avatar_inittab.datas[roleType]["spawnYaw"]),
			"position"			: d_avatar_inittab.datas[roleType]["spawnPos"]
			}
			
		avatar = KBEngine.createBaseLocally('Avatar', props)
		if avatar:
			avatar.writeToDB(self._onCharacterSaved)
Esempio n. 18
0
def onBaseAppReady(isBootstrap):
    """
	KBEngine method.
	baseapp已经准备好了
	@param isBootstrap: 是否为第一个启动的baseapp
	@type isBootstrap: BOOL
	"""
    INFO_MSG('onBaseAppReady: isBootstrap=%s, bootstrapGroupIndex=%s, bootstrapGlobalIndex=%s' % \
     (isBootstrap, os.getenv("KBE_BOOTIDX_GROUP"), os.getenv("KBE_BOOTIDX_GLOBAL")))

    if isBootstrap:
        # 创建大厅
        KBEngine.createBaseLocally("Hall", {})
        KBEngine.createBaseLocally("CardList", {})
        INFO_MSG('onInit::onBaseAppReady engilsh英文')
        INFO_MSG('onInit::onBaseAppReady chinese中文')
Esempio n. 19
0
	def reqCreateAvatar(self, roleType, name):
		"""
		exposed.
		客户端请求创建一个角色
		"""
		avatarinfo = {"name": name, "dbid": 0, "roleType" : roleType, "level" : 0}
			
		"""
		if name in all_avatar_names:
			retcode = 2
			self.client.onCreateAvatarResult(retcode, avatarinfo)
			return
		"""
		
		if len(self.characters) >= 3:
			DEBUG_MSG("Account[%i].reqCreateAvatar:%s. character=%s.\n" % (self.id, name, self.characters))
			self.client.onCreateAvatarResult(3, avatarinfo)
			return
			
		props = {
			"name"				: name,
			"roleType"			: roleType,
			"level"				: 1,
			"spaceUType"		: d_avatar_inittab.datas[roleType]["spaceUType"],
			"direction"			: (0, 0, d_avatar_inittab.datas[roleType]["spawnYaw"]),
			"position"			: d_avatar_inittab.datas[roleType]["spawnPos"]
			}
			
		avatar = KBEngine.createBaseLocally('Avatar', props)
		if avatar:
			avatar.writeToDB(self._onCharacterSaved)
Esempio n. 20
0
	def reqCreateAvatar(self, roleType, name):
		"""
		exposed.
		客户端请求创建一个角色
		"""
		avatarinfo = TAvatarInfos()
		avatarinfo.extend([0, "", 0, 0, TAvatarData().createFromDict({"param1" : 0, "param2" :b''})])
			
		"""
		if name in all_avatar_names:
			retcode = 2
			self.client.onCreateAvatarResult(retcode, avatarinfo)
			return
		"""
		
		if len(self.characters) >= 3:
			DEBUG_MSG("Account[%i].reqCreateAvatar:%s. character=%s.\n" % (self.id, name, self.characters))
			self.client.onCreateAvatarResult(3, avatarinfo)
			return
		
		""" 根据前端类别给出出生点
		Reference: http://www.kbengine.org/docs/programming/clientsdkprogramming.html, client types
		UNKNOWN_CLIENT_COMPONENT_TYPE	= 0,
		CLIENT_TYPE_MOBILE				= 1,	// 手机类
		CLIENT_TYPE_WIN					= 2,	// pc, 一般都是exe客户端
		CLIENT_TYPE_LINUX				= 3		// Linux Application program
		CLIENT_TYPE_MAC					= 4		// Mac Application program
		CLIENT_TYPE_BROWSER				= 5,	// web应用, html5,flash
		CLIENT_TYPE_BOTS				= 6,	// bots
		CLIENT_TYPE_MINI				= 7,	// 微型客户端
		"""
		spaceUType = 1
		
		# 如果是机器人登陆,随机扔进一个场景
		if self.getClientType() == 6:
			spaceUType = GlobalConst.g_demoMaps["cell_sene"]
		else:
			spaceUType = GlobalConst.g_demoMaps["center"]

		spaceData = d_spaces.datas.get(spaceUType)
		
		# 减一, 在登陆到具体场景时由spaces再均衡分布到N个具体场景中
		if spaceUType == GlobalConst.g_demoMaps["cell_sene"]:
			spaceUType -= 1 
		
		props = {
			"name"			: name,
			"roleType"			: roleType,
			"level"				: 1,
			"spaceUType"		: spaceUType,
			"direction"			: (0, 0, d_avatar_inittab.datas[roleType]["spawnYaw"]),
			"position"			: spaceData.get("spawnPos", (0,0,0))
			}
			
		avatar = KBEngine.createBaseLocally('Avatar', props)
		if avatar:
			avatar.writeToDB(self._onAvatarSaved)
		
		DEBUG_MSG("Account[%i].reqCreateAvatar:%s. spaceUType=%i, spawnPos=%s.\n" % (self.id, name, avatar.cellData["spaceUType"], spaceData.get("spawnPos", (0,0,0))))
Esempio n. 21
0
	def reqCreateAvatar(self, roleType, name):
		"""
		exposed.
		客户端请求创建一个角色
		"""
		avatarinfo = TAvatarInfos()
		avatarinfo.extend([0, "", 0, 0, TAvatarData().createFromDict({"param1" : 0, "param2" :b''})])
			
		"""
		if name in all_avatar_names:
			retcode = 2
			self.client.onCreateAvatarResult(retcode, avatarinfo)
			return
		"""
		
		if len(self.characters) >= 3:
			DEBUG_MSG("Account[%i].reqCreateAvatar:%s. character=%s.\n" % (self.id, name, self.characters))
			self.client.onCreateAvatarResult(3, avatarinfo)
			return
		
		""" 根据前端类别给出出生点
		Reference: http://www.kbengine.org/docs/programming/clientsdkprogramming.html, client types
		UNKNOWN_CLIENT_COMPONENT_TYPE	= 0,
		CLIENT_TYPE_MOBILE				= 1,	// 手机类
		CLIENT_TYPE_WIN					= 2,	// pc, 一般都是exe客户端
		CLIENT_TYPE_LINUX				= 3		// Linux Application program
		CLIENT_TYPE_MAC					= 4		// Mac Application program
		CLIENT_TYPE_BROWSER				= 5,	// web应用, html5,flash
		CLIENT_TYPE_BOTS				= 6,	// bots
		CLIENT_TYPE_MINI				= 7,	// 微型客户端
		"""
		spaceUType = GlobalConst.g_demoMaps.get(self.getClientDatas(), 1)
		
		# 如果是机器人登陆,随机扔进一个场景
		if self.getClientType() == 6:
			while True:
				spaceName = random.choice(list(GlobalConst.g_demoMaps.keys()))
				if len(spaceName) > 0:
					spaceUType = GlobalConst.g_demoMaps[spaceName]
					break

		spaceData = d_spaces.datas.get(spaceUType)
		
		props = {
			"name"				: name,
			"roleType"			: roleType,
			"level"				: 1,
			"spaceUType"		: spaceUType,
			"direction"			: (0, 0, d_avatar_inittab.datas[roleType]["spawnYaw"]),
			"position"			: spaceData.get("spawnPos", (0,0,0))
			}
			
		avatar = KBEngine.createBaseLocally('Avatar', props)
		if avatar:
			avatar.writeToDB(self._onAvatarSaved)
		
		DEBUG_MSG("Account[%i].reqCreateAvatar:%s. spaceUType=%i, spawnPos=%s.\n" % (self.id, name, avatar.cellData["spaceUType"], spaceData.get("spawnPos", (0,0,0))))
Esempio n. 22
0
    def reqCreateAvatar(self, roleType, name):
        """
		exposed.
		客户端请求创建一个角色
		"""
        avatarinfo = {"name": name, "dbid": 0, "roleType": roleType, "level": 0}

        """
		if name in all_avatar_names:
			retcode = 2
			self.client.onCreateAvatarResult(retcode, avatarinfo)
			return
		"""

        if len(self.characters) >= 3:
            DEBUG_MSG("Account[%i].reqCreateAvatar:%s. character=%s.\n" % (self.id, name, self.characters))
            self.client.onCreateAvatarResult(3, avatarinfo)
            return

        """ 根据前端类别给出出生点
		UNKNOWN_CLIENT_COMPONENT_TYPE	= 0,
		CLIENT_TYPE_MOBILE				= 1,	// 手机类
		CLIENT_TYPE_PC					= 2,	// pc, 一般都是exe客户端
		CLIENT_TYPE_BROWSER				= 3,	// web应用, html5,flash
		CLIENT_TYPE_BOTS				= 4,	// bots
		CLIENT_TYPE_MINI				= 5,	// 微型客户端
		"""
        spawnPos = (0, 0, 0)
        spaceUType = 1

        if self.getClientType() == 2:
            spaceUType = 2
            spawnPos = (-97.9299, 0, -158.922)
        elif self.getClientType() == 5:
            spaceUType = 3
            spawnPos = (-97.9299, 1.5, -158.922)
        else:
            spaceUType = 1
            spawnPos = (771.5861, 211.0021, 776.5501)

        props = {
            "name": name,
            "roleType": roleType,
            "level": 1,
            "spaceUType": spaceUType,
            "direction": (0, 0, d_avatar_inittab.datas[roleType]["spawnYaw"]),
            "position": spawnPos,
        }

        avatar = KBEngine.createBaseLocally("Avatar", props)
        if avatar:
            avatar.writeToDB(self._onCharacterSaved)

        DEBUG_MSG(
            "Account[%i].reqCreateAvatar:%s. spaceUType=%i, spawnPos=%s.\n"
            % (self.id, name, avatar.cellData["spaceUType"], spawnPos)
        )
Esempio n. 23
0
    def reqCreateAvatar(self, name, roleType):
        if len(self.characters) >= 3:
            DEBUG_MSG("Account[%i].reqCreateAvatar:%s. character=%s.\n" %
                      (self.id, name, self.characters))

            avatarinfo = TAvatarInfo()
            avatarinfo.extend([0, "", 0, 0])
            self.client.onCreateAvatarResult(3, avatarinfo)
            return
        """ 根据前端类别给出出生点
		UNKNOWN_CLIENT_COMPONENT_TYPE	= 0,
		CLIENT_TYPE_MOBILE				= 1,	// 手机类
		CLIENT_TYPE_PC					= 2,	// pc, 一般都是exe客户端
		CLIENT_TYPE_BROWSER				= 3,	// web应用, html5,flash
		CLIENT_TYPE_BOTS				= 4,	// bots
		CLIENT_TYPE_MINI				= 5,	// 微型客户端
		"""
        spaceUType = GlobalConst.g_demoMaps.get(self.getClientDatas(), 1)
        spaceData = d_spaces.datas.get(spaceUType)

        props = {
            "name": name,
            "roleType": roleType,
            "level": 1,
            "spaceUType": spaceUType,
            "direction": (0, 0, d_avatar_inittab.datas[roleType]["spawnYaw"]),
            "position": spaceData.get("spawnPos", (0, 0, 0)),

            #----------cell---------
            "roleTypeCell": roleType,
            #---------propertys
            "level": d_avatar_inittab.datas[roleType]["level"],
            "exp": d_avatar_inittab.datas[roleType]["exp"],
            "money": d_avatar_inittab.datas[roleType]["money"],
            "strength": d_avatar_inittab.datas[roleType]["strength"],
            "dexterity": d_avatar_inittab.datas[roleType]["dexterity"],
            "stamina": d_avatar_inittab.datas[roleType]["stamina"],
            "attack_Max": d_avatar_inittab.datas[roleType]["strength"] * 2,
            "attack_Min": d_avatar_inittab.datas[roleType]["strength"] * 1,
            "defence": int(d_avatar_inittab.datas[roleType]["dexterity"] / 4),
            "rating":
            int(d_avatar_inittab.datas[roleType]["dexterity"] / 15 + 100),
            "dodge":
            int(d_avatar_inittab.datas[roleType]["dexterity"] / 15 + 100),
            "HP_Max": 10,
            #---------propertys
        }

        avatar = KBEngine.createBaseLocally("Avatar", props)
        if avatar:
            avatar.writeToDB(self._onAvatarSaved)

        DEBUG_MSG(
            "Account[%i].reqCreateAvatar:%s. spaceUType=%i, spawnPos=%s.\n" %
            (self.id, name, avatar.cellData["spaceUType"],
             spaceData.get("spawnPos", (0, 0, 0))))
Esempio n. 24
0
    def reqCreateAvatar(self, roleType, name):
        """
		exposed.
		客户端请求创建一个角色
		"""
        avatarinfo = {
            "name": name,
            "dbid": 0,
            "roleType": roleType,
            "level": 0
        }
        """
		if name in all_avatar_names:
			retcode = 2
			self.client.onCreateAvatarResult(retcode, avatarinfo)
			return
		"""

        if len(self.characters) >= 3:
            DEBUG_MSG("Account[%i].reqCreateAvatar:%s. character=%s.\n" %
                      (self.id, name, self.characters))
            self.client.onCreateAvatarResult(3, avatarinfo)
            return
        """ 根据前端类别给出出生点
		UNKNOWN_CLIENT_COMPONENT_TYPE	= 0,
		CLIENT_TYPE_MOBILE				= 1,	// 手机类
		CLIENT_TYPE_PC					= 2,	// pc, 一般都是exe客户端
		CLIENT_TYPE_BROWSER				= 3,	// web应用, html5,flash
		CLIENT_TYPE_BOTS				= 4,	// bots
		"""
        spawnPos = (0, 0, 0)
        spaceUType = 1

        if self.getClientType() == 2:
            spaceUType = 2
            spawnPos = (-97.9299, 0, -158.922)
        else:
            spaceUType = 1
            spawnPos = (771.5861, 211.0021, 776.5501)

        props = {
            "name": name,
            "roleType": roleType,
            "level": 1,
            "spaceUType": spaceUType,
            "direction": (0, 0, d_avatar_inittab.datas[roleType]["spawnYaw"]),
            "position": spawnPos
        }

        avatar = KBEngine.createBaseLocally('Avatar', props)
        if avatar:
            avatar.writeToDB(self._onCharacterSaved)

        DEBUG_MSG(
            "Account[%i].reqCreateAvatar:%s. spaceUType=%i, spawnPos=%s.\n" %
            (self.id, name, avatar.cellData["spaceUType"], spawnPos))
Esempio n. 25
0
 def onEntitiesEnabled(self):
     """
     KBEngine method.
     该entity被正式激活为可使用, 此时entity已经建立了client对应实体, 可以在此创建它的
     cell部分。
     """
     INFO_MSG("account[%i] entities enable. mailbox:%s" %
              (self.id, self.client))
     ClientManager = KBEngine.createBaseLocally("ClientManager")
     self.giveClientTo(ClientManager)
Esempio n. 26
0
    def __init__(self):
        BaseEntity.__init__(self)
        self.sportDict = {}
        table_daily_sports = h1global.rc.sportDict[const.SPORT_DAILY]
        for k in table_daily_sports:
            DEBUG_MSG(table_daily_sports[k])
            sportId = table_daily_sports[k]['id']
            self.sportDict[sportId] = KBEngine.createBaseLocally(
                "SportDaily", {'sportId': sportId})

        x42.SportDailyStub = self
Esempio n. 27
0
	def requestCreateAvatar(self, name):
		"""
		Define method.
		"""
		DEBUG_MSG("Account(id=%i dbid=%i)::requestCreateAvatar name=%s" % (self.id, self.databaseID, name))
		avatar = KBEngine.createBaseLocally("Avatar", {"name":name})
		if(avatar):
			avatar.writeToDB(self._onAvatarWriteToDB)
		else:
			ERROR_MSG("Account(id=%i dbid=%i)::requestCreateAvatar name=%s create avatar failed" % (self.id, self.databaseID, name))
			self.client.responseCreateAvatarFailed(CreateAvatarFailed)
Esempio n. 28
0
	def reqCreateAvatar(self, roleType, name):
		"""
		exposed.
		客户端请求创建一个角色
		"""
		avatarinfo = TAvatarInfos()
		avatarinfo.extend([0, "", 0, 0, TAvatarData().createFromDict({"param1" : 0, "param2" :b''})])
			
		"""
		if name in all_avatar_names:
			retcode = 2
			self.client.onCreateAvatarResult(retcode, avatarinfo)
			return
		"""
		
		if len(self.characters) >= 3:
			DEBUG_MSG("Account[%i].reqCreateAvatar:%s. character=%s.\n" % (self.id, name, self.characters))
			self.client.onCreateAvatarResult(3, avatarinfo)
			return
		
		""" 根据前端类别给出出生点
		UNKNOWN_CLIENT_COMPONENT_TYPE	= 0,
		CLIENT_TYPE_MOBILE				= 1,	// 手机类
		CLIENT_TYPE_PC					= 2,	// pc, 一般都是exe客户端
		CLIENT_TYPE_BROWSER				= 3,	// web应用, html5,flash
		CLIENT_TYPE_BOTS				= 4,	// bots
		CLIENT_TYPE_MINI				= 5,	// 微型客户端
		"""
		spaceUType = 1
		
		if self.getClientType() == 2:
			spaceUType = 2
		elif self.getClientType() == 5:
			spaceUType = 3
		else:
			spaceUType = 1
		
		spaceData = d_spaces.datas.get(spaceUType)
		
		props = {
			"name"				: name,
			"roleType"			: roleType,
			"level"				: 1,
			"spaceUType"		: spaceUType,
			"direction"			: (0, 0, d_avatar_inittab.datas[roleType]["spawnYaw"]),
			"position"			: spaceData.get("spawnPos", (0,0,0))
			}
			
		avatar = KBEngine.createBaseLocally('Avatar', props)
		if avatar:
			avatar.writeToDB(self._onCharacterSaved)
		
		DEBUG_MSG("Account[%i].reqCreateAvatar:%s. spaceUType=%i, spawnPos=%s.\n" % (self.id, name, avatar.cellData["spaceUType"], spaceData.get("spawnPos", (0,0,0))))
Esempio n. 29
0
	def reqCreateAvatar(self, name, roleType):
		if len(self.characters) >= 3:
			DEBUG_MSG("Account[%i].reqCreateAvatar:%s. character=%s.\n" % (self.id, name, self.characters))

			avatarinfo = TAvatarInfo()
			avatarinfo.extend([0, "", 0, 0])
			self.client.onCreateAvatarResult(3, avatarinfo)
			return
		
		""" 根据前端类别给出出生点
		UNKNOWN_CLIENT_COMPONENT_TYPE	= 0,
		CLIENT_TYPE_MOBILE				= 1,	// 手机类
		CLIENT_TYPE_PC					= 2,	// pc, 一般都是exe客户端
		CLIENT_TYPE_BROWSER				= 3,	// web应用, html5,flash
		CLIENT_TYPE_BOTS				= 4,	// bots
		CLIENT_TYPE_MINI				= 5,	// 微型客户端
		"""
		spaceUType = GlobalConst.g_demoMaps.get(self.getClientDatas(), 1)
		spaceData = d_spaces.datas.get(spaceUType)
		
		props = {
			"name"				: name,
			"roleType"			: roleType,
			"level"				: 1,
			"spaceUType"		: spaceUType,
			"direction"			: (0, 0, d_avatar_inittab.datas[roleType]["spawnYaw"]),
			"position"			: spaceData.get("spawnPos", (0,0,0)),
			
			#----------cell---------
			"roleTypeCell"      : roleType,
			#---------propertys
			"level"				: d_avatar_inittab.datas[roleType]["level"],
			"exp"				: d_avatar_inittab.datas[roleType]["exp"],
			"money"				: d_avatar_inittab.datas[roleType]["money"],
			"strength"			: d_avatar_inittab.datas[roleType]["strength"],
			"dexterity"			: d_avatar_inittab.datas[roleType]["dexterity"],
			"stamina"			: d_avatar_inittab.datas[roleType]["stamina"],

			"attack_Max"		: d_avatar_inittab.datas[roleType]["strength"]*2,
			"attack_Min"		: d_avatar_inittab.datas[roleType]["strength"]*1,
			"defence"			: int(d_avatar_inittab.datas[roleType]["dexterity"]/4),
			"rating"			: int(d_avatar_inittab.datas[roleType]["dexterity"]/15+100),
			"dodge"				: int(d_avatar_inittab.datas[roleType]["dexterity"]/15+100),
			"HP_Max"            : 10,
			#---------propertys
			}

		avatar = KBEngine.createBaseLocally("Avatar",props)
		if avatar:
			avatar.writeToDB(self._onAvatarSaved)
		
		DEBUG_MSG("Account[%i].reqCreateAvatar:%s. spaceUType=%i, spawnPos=%s.\n" % (self.id, name, avatar.cellData["spaceUType"], spaceData.get("spawnPos", (0,0,0))))
Esempio n. 30
0
 def __init__(self):
     DEBUG_MSG("SpacesManager:__init__")
     KBEngine.Base.__init__(self)
     KBEngine.globalData["spacesManager"] = self
     # 根据场景配置表(space_data)来创建场景
     for (cityName, spaceData) in space_data.data.items():
         DEBUG_MSG("spaceName:" + spaceData["场景名称"])
         space = KBEngine.createBaseLocally(
             "Space", {
                 'name': cityName,
                 "cityName": cityName,
                 "spaceName": spaceData["场景名称"]
             })
Esempio n. 31
0
def _dbCmdCreateTblCB(resultCollect, num, errorInfo):
    DEBUG_MSG(errorInfo)
    if errorInfo is None:
        bigWorld = KBEngine.createBaseLocally("BigWorld", {})
        if bigWorld:
            DEBUG_MSG("create bigWorld success")
            bigWorld.writeToDB(_bigWorldSavedCB)
            # KBEngine.executeRawDatabaseCommand("INSERT INTO mini_Spaces VALUES ('BigWorld', 0)",
            # _dbCmdInsertBigWorldCB)
        else:
            ERROR_MSG("create bigWorld failed")
    else:
        ERROR_MSG("create tbl failed")
Esempio n. 32
0
	def marchSuccess(self,battlefieldCell,playerID):
		DEBUG_MSG("Account[%i].battleFieldBase[%s]" % (self.id,battlefieldCell.id))

		dic={
			'roleType':self.AvatarList[self.chooseAvatarStore]['roleType'],
			'battlefield':battlefieldCell,
			'cardList':self.AvatarList[self.chooseAvatarStore]['cardList'],
			'account':self,
			'nameA':self.Name,
			'playerIDB':playerID
		}
		self.client.enterBattlefield()
		self.Avatar=KBEngine.createBaseLocally("Avatar",dic)
Esempio n. 33
0
 def sqlcallback(self, result, rows, insertid, error):
     #success
     if len(result) == 0:
         role = KBEngine.createBaseLocally("Role", self.params)
         role.cellData["position"] = MathEx.calcRandomPos(
             Relive_Center, Relive_Radius)
         if role:
             role.writeToDB(self._onDatabaseSaved)
     #fail
     else:
         self.params["dbid"] = 0
         info = TRoleInfos().createFromDict(self.params)
         if self.client:
             self.client.recCreateRole(1, info)
Esempio n. 34
0
    def CreateCharacterReq(self, name, gender, vocation):

        #正在创建角色中
        if self.avatarState == public_config.CHARACTER_CREATING:
            return
        #如果刚刚创建了,但是又创建

        #检查是否超过角色可创建数量

        #角色名字检查
        #长度
        if len(name) < 2:
            self.client.OnCreateCharacterResp(
                error_code.ERR_CREATE_AVATAR_NAME_TOO_SHORT, 0)
        elif len(name) > 20:
            self.client.OnCreateCharacterResp(
                error_code.ERR_CREATE_AVATAR_NAME_TOO_LONG, 0)

        #检查特护字符,客户端进行了基本的检查

        #检查敏感字

        #检查职业和性别
        if gender != public_config.GENDER_MALE and gender != public_config.GENDER_FEMALE:
            self.client.OnCreateCharacterResp(
                error_code.ERR_CREATE_AVATAR_GENDER, 0)
            return
        if vocation < public_config.VOC_MIN or vocation > public_config.VOC_MAX:
            self.client.OnCreateCharacterResp(
                error_code.ERR_CREATE_AVATAR_VOCATION, 0)
            return
        #设置帐号在创建角色中
        self.avatarState = public_config.CHARACTER_CREATING
        #名字检查,考虑使用userMgr回调检查姓名的合法性
        props = {
            "name": name,
            "vocation": vocation,
            "level": 1,
            #----------cell---------
            "roleTypeCell": vocation,
            "sex": gender
        }
        avatar = KBEngine.createBaseLocally("Avatar", props)
        self.state = ACCOUNT_STATE_CREATING

        if avatar:
            avatar.writeToDB(self._onAvatarWrited)
        DEBUG_MSG("Account[%i].reqCreateAvatar:%s. spawnPos=%s.\n" %
                  (self.id, name))
Esempio n. 35
0
    def creatAvatar(self, battleFiled):
        '''
		'''
        DEBUG_MSG("Account[%i].creatAvatar" % (self.id))
        prarm = {
            "battlefiled": battleFiled,
            'nameA': self.Name,
            'roleType': self.Avatar_List[self.willUseKz]['roleType'],
            'cardList': self.Avatar_List[self.willUseKz]['cardList'],
            'playerIDB': self.playerID,
            'account': self
        }
        self.Avatar0 = KBEngine.createBaseLocally("Avatar", prarm)
        self.client.onInitBattleField()
        self.onPlayingBattlefiled = battleFiled
Esempio n. 36
0
File: Hall.py Progetto: ajue/llgame
    def _createRooms(self):
        """
		根据玩家人数,动态创建房间
		根据游戏类型进行不同房间的使用创建
		"""
        roomID = len(self.rooms.values()) + 1

        self.rooms[roomID] = KBEngine.createBaseLocally(
            "Room", {
                "hallID": self.hallID,
                "roomID": roomID
            })

        self.roomIDList.append(roomID)
        return self.rooms[roomID]
Esempio n. 37
0
 def onGetCell(self):
     DEBUG_MSG("BigWorld:onGetCell")
     self.npcList = {}
     if self.xinShouYinDaoDBID == 0 or self.xinShouYinDaoDBID is None:
         self.npcList["新手引导"] = KBEngine.createBaseLocally("Npc", {})
         if self.npcList["新手引导"]:
             self.npcList["新手引导"].cellData["entityName"] = "新手引导"
             self.npcList["新手引导"].cellData["modelName"] = "XinShouYinDaoNpc"
             self.npcList["新手引导"].cellData["position"] = (202.0, 0.0, 253.0)
             self.npcList["新手引导"].cellData["direction"] = (0.0, 0.0, 0.0)
             self.npcList["新手引导"].setAttr("spaceCell", self.cell)
             self.npcList["新手引导"].setAttr("entityName", "新手引导")
             self.npcList["新手引导"].writeToDB(self._onNpcSaved)
     else:
         KBEngine.createBaseFromDBID("Npc", self.xinShouYinDaoDBID, self.__onNpcCreateCB)
 def onAllSpacesGetCell(self):
     DEBUG_MSG("SectsManager:onAllSpacesGetCell")
     for (sectID, sectData) in sect_config_Table.datas.items():
         if sectID in self.sectDBIDList.keys():
             KBEngine.createBaseFromDBID("Sect",
                                         self.sectDBIDList[sectID]["dbid"],
                                         self.__sectCreateCallback)
         else:
             sect = KBEngine.createBaseLocally(
                 "Sect", {
                     "entityName": sectData["sectName"],
                     "sectID": sectID,
                     "position": sectData["pos"]
                 })
             sect.writeToDB(self.__onSectSaved)
             self.sectList[sect.sectID] = sect
Esempio n. 39
0
			def check_cb(result, msg=None):
				if not result:
					msg and avatar.showTip(msg)
					return
				if self.roomAvailable():
					avatar.enterRoom(self.room.roomID)
					return
				params = dict(self.club.roomType)
				self.room = KBEngine.createBaseLocally("GameRoom", params)
				if self.room:
					self.room.club_table = weakref.proxy(self)
					x42.GW.addRoom(self.room)
					avatar.enterRoom(self.room.roomID)
					msg and avatar.showTip(msg)
				else:
					ERROR_MSG("ClubTable takeASeat createRoom failed")