def _onAvatarSaved(self, success, avatar):
		"""
		新建角色写入数据库回调
		"""
		INFO_MSG('Account::_onAvatarSaved:(%i) create avatar state: %i, %s, %i' % (self.id, success, avatar.cellData["name"], avatar.databaseID))
		
		# 如果此时账号已经销毁, 角色已经无法被记录则我们清除这个角色
		if self.isDestroyed:
			if avatar:
				avatar.destroy(True)
				
			return
			
		avatarinfo = TAvatarInfo()
		avatarinfo.extend([0, "", 0, 0])

		if success:
			avatarinfo[0] = avatar.databaseID
			avatarinfo[1] = avatar.cellData["name"]
			avatarinfo[2] = avatar.roleType
			avatarinfo[3] = 1
			self.characters[avatar.databaseID] = avatarinfo
			self.writeToDB()

			avatar.destroy()

		if self.client:
			self.client.onCreateAvatarResult(0, avatarinfo)
Exemple #2
0
    def _onAvatarSaved(self, success, avatar):
        """
		新建角色写入数据库回调
		"""
        INFO_MSG(
            'Account::_onAvatarSaved:(%i) create avatar state: %i, %s, %i' %
            (self.id, success, avatar.cellData["name"], avatar.databaseID))

        # 如果此时账号已经销毁, 角色已经无法被记录则我们清除这个角色
        if self.isDestroyed:
            if avatar:
                avatar.destroy(True)

            return

        avatarinfo = TAvatarInfo()
        avatarinfo.extend([0, "", 0, 0])

        if success:
            avatarinfo[0] = avatar.databaseID
            avatarinfo[1] = avatar.cellData["name"]
            avatarinfo[2] = avatar.roleType
            avatarinfo[3] = 1
            self.characters[avatar.databaseID] = avatarinfo
            self.writeToDB()

            avatar.destroy()

        if self.client:
            self.client.onCreateAvatarResult(0, avatarinfo)
Exemple #3
0
    def _onAcatarWrited(self, success, avatar):
        """
		新建角色写入数据库回调
		"""
        INFO_MSG(
            "Account::_onAvatarWrited:(%i) create avatr state:%i,%s,%i" %
            (self.id, success, avatar.cellData['name'], avatar.databaseID))
        #如果此时账号已经销毁, 角色已经无法被记录则我们清除这个角色
        if self.isDestroyed:
            if avatar:
                avatr.destroy(True)
                return
        #fixed_dict,先扩展,再修改
        avatarinfo = TAvatarInfo()
        avatarinfo.extend([0, "", 0, 0])

        if success:
            avatarinfo[0] = avatar.databaseID
            avartarinfo[1] = avatar.cellData['name']
            avatarinfo[2] = avatar.vocation
            avatarinfo[3] = 1

            self.cahracters[avatar.databaseID] = avatarinfo

            self.writeToDB()
        else:
            avatarinfo[1] = '创建失败'

        if self.client:
            self.client.OnCreateCharacterResp(0, avatar.databaseID)
	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))))
Exemple #5
0
    def _onAvatarSaved(self, success, avatar):
        """
		New role write database callback
		"""
        INFO_MSG(
            'Account::onAvatarSaved:(%i) Create Avatar Success: %i, Name: %s, DBID: %i'
            % (self.id, success, avatar.cellData["name"], avatar.databaseID))

        # If the account has been destroyed at this time, the role can no longer be recorded, then we clear the role.
        if self.isDestroyed:
            if avatar:
                avatar.destroy(True)

            return

        avatarData = TAvatarData().createFromDict({"param1": 0, "param2": b''})

        avatarinfo = TAvatarInfo()
        avatarinfo.extend([0, "", 0, 0, 0, 0, avatarData])

        INFO_MSG('success: %i, %s %i' %
                 (success, str(bool(success)), int(success)))
        if bool(success) is True or success == 1:
            info = TAvatarInfo()
            info.extend([
                avatar.databaseID, avatar.cellData["name"], avatar.roleType, 1,
                avatar.gender, avatar.hairStyle, avatarData
            ])
            self.avatars[avatar.databaseID] = info
            avatarinfo[0] = avatar.databaseID
            avatarinfo[1] = avatar.cellData["name"]
            avatarinfo[2] = avatar.roleType
            avatarinfo[3] = 1
            avatarinfo[4] = avatar.gender
            avatarinfo[5] = avatar.hairStyle
            avatarData[6] = avatarData

            self.writeToDB()
        else:
            avatarinfo[1] = "Creation Failed"

        avatar.destroy()

        if self.client:
            self.client.onCreateAvatarResult(success, avatarinfo)
Exemple #6
0
    def reqCreateAvatar(self, name, roleType, gender, hairStyle):
        """
		exposed.
		The client requests to create a role
		"""

        avatarData = TAvatarData().createFromDict({"param1": 0, "param2": b''})
        avatarinfo = TAvatarInfo()
        avatarinfo.extend([0, "", 0, 0, 0, 0, avatarData])
        """
		if name in all_avatar_names:
			retcode = 2
			self.client.onCreateAvatarResult(retcode, avatarinfo)
			return
		"""

        if len(self.avatars) >= 3:
            DEBUG_MSG("Account[%i].reqCreateAvatar:%s. avatars=%s.\n" %
                      (self.id, name, self.avatars))
            self.client.onCreateAvatarResult(3, avatarinfo)
            return
        """ Give a birth point based on the front end category
		UNKNOWN_CLIENT_COMPONENT_TYPE	= 0,
		CLIENT_TYPE_MOBILE				= 1,	// Mobile phone
		CLIENT_TYPE_PC					= 2,	// pc, Generally exe client
		CLIENT_TYPE_BROWSER				= 3,	// Web application, html5,flash
		CLIENT_TYPE_BOTS				= 4,	// bots
		CLIENT_TYPE_MINI				= 5,	// Micro client
		"""
        """
		# If the robot is logged in, randomly throw in a scene
		if self.getClientType() == 6:
			while True:
				spaceName = random.choice(list(GlobalConst.idmo_maps.keys()))
				if len(spaceName) > 0:
					spaceUType = GlobalConst.idmo_maps[spaceName]
					break
		"""

        spaceUType = GlobalConst.idmo_maps.get(self.getClientDatas()[0], 1)
        spaceData = data_spaces.data.get(spaceUType)
        #spaceData.get("spawnPos")

        #"direction"		: (0, 0, data_avatar_initial.data[roleType]["spawnYaw"])

        props = {
            "name":
            name,
            "roleType":
            roleType,
            "gender":
            gender,
            "spaceUType":
            spaceUType,
            "hairStyle":
            hairStyle,
            "direction":
            data_avatar_initial.data[roleType]["spawnDir"],
            "position":
            data_avatar_initial.data[roleType]["spawnPos"],

            # ----------cell---------
            "roleTypeCell":
            roleType,
            # ---------properties
            "level":
            data_avatar_initial.data[roleType]["level"],
            "experience":
            data_avatar_initial.data[roleType]["experience"],
            "currency":
            data_avatar_initial.data[roleType]["currency"],
            "strength":
            data_avatar_initial.data[roleType]["strength"],
            "endurance":
            data_avatar_initial.data[roleType]["endurance"],
            "will":
            data_avatar_initial.data[roleType]["will"],
            "attack_Max":
            data_avatar_initial.data[roleType]["strength"] * 2,
            "attack_Min":
            data_avatar_initial.data[roleType]["strength"] * 1,
            "defence":
            int(data_avatar_initial.data[roleType]["endurance"] / 4),
            "rating":
            int(data_avatar_initial.data[roleType]["endurance"] / 15 + 100),
            "dodge":
            int(data_avatar_initial.data[roleType]["endurance"] / 15 + 100),
            "HP":
            int(data_avatar_initial.data[roleType]["hp"]),
            "HP_Max":
            int(data_avatar_initial.data[roleType]["hpMax"]),
            "EG":
            int(data_avatar_initial.data[roleType]["eg"]),
            "EG_Max":
            int(data_avatar_initial.data[roleType]["egMax"]),
            "abilityPoints":
            data_avatar_initial.data[roleType]["abilityPoints"],
            "abilities":
            data_avatar_initial.data[roleType]["abilities"],
            # ---------properties
        }
        DEBUG_MSG('PROPS', props['HP'], props['HP_Max'], props['EG'],
                  props['EG_Max'])

        avatar = Ouroboros.createEntityLocally('Avatar', props)
        if avatar:
            avatar.writeToDB(self._onAvatarSaved)

        DEBUG_MSG(
            "Account[%i].reqCreateAvatar:%s, spaceUType=%i, spawnPos=%s.\n spawnDir=%s."
            % (self.id, name, avatar.cellData["spaceUType"],
               data_avatar_initial.data[roleType]["spawnPos"],
               data_avatar_initial.data[roleType]["spawnDir"]))