Esempio n. 1
0
class GamerCharacter(Character):
	'''玩家角色类'''
	def __init__(self,cid,name=u'',dynamicId=-1,status=1):
		'''构造方法
		@dynamicId (int) 角色登录的动态ID socket连接产生的id
		'''
		Character.__init__(self,cid,name)
		self.setCharacterType(Character.GAMERTYPE)#设置角色类型为玩家角色
		self.dynamicId=dynamicId #角色登录服务器时的动态id
		#-----------角色的各个组件类----------------
		self.level=CharacterLevelComponent(self) #角色等级
		self.finance=CharacterFinanceComponent(self) #角色资产
		self.pack=CharacterPackageComponent(self) #角色包裹
		self.attribute=CharacterAttributeComponent(self) #角色属性
		self.mail=CharacterMailListComponent(self)#角色邮件列表
		self.playerInner=PlayerInner(self)#球员找寻
		self.player=PlayerComponent(self)#球队球员
		self.zen=CharacterZenComponent(self)#球队战术
		self.shop=CharacterShopComponent(self)#商店
		self.task=CharacterTaskComponent(self)#任务
		self.trainmatch=TrainMatchComponent(self)#训练赛
		self.challengematch=ChallengeMatchComponent(self)#挑战赛
		if status:
			self.initGamerInfo() #初始化角色

	def initGamerInfo(self):
		'''初始化角色信息'''
		cid=self.baseInfo.id
		charactermode=tb_character_admin.getObj(cid)
		data=charactermode.get("data")
		if not data:
			print "Inint_gamer _"+str(self.baseInfo.id)
		#---------初始化角色基础信息组件---------
		self.baseInfo.setType(data['viptype']) #角色VIP类型
		self.baseInfo.setnickName(data['nickname']) #角色昵称
		#---------初始化角色经验等级组件---------
		self.level.setLevel(data['level'])
		self.level.setExp(data['exp'])
		self.level.setVipExp(data['vipexp'])
		#---------初始化角色属性信息组件---------
		self.attribute.initEnergy(data['energy'])
		self.attribute.setPhoto(data['Photo'])
		self.attribute.setPower(data['power'])
		self.attribute.setMaxPower(data['maxpower'])
		self.attribute.setTrainPoint(data['trainpoint'])
		self.attribute.setTacticsPoint(data['tacticspoint'])
		self.attribute.setRepute(data['repute'])#角色声望
		#---------初始化角色资产信息组件---------
		self.finance.setGameCoin(data['gamecoin'])
		self.finance.setCoin(data['coin'])
		#---------初始化包裹---------------------
		self.pack.initPack(packageSize=data['packageSize'])
		#---------初始化角色球员信息-------------
		self.player.initPlayerInfo()
		#---------初始化角色任务-----------------
		self.task.initCharacterTask()

	def getDynamicId(self):
		'''获取角色的动态Id'''
		return self.dynamicId

	def formatInfo(self):
		'''格式化角色基本信息'''
		characterInfo={}
		characterInfo['id']=self.baseInfo.id #角色的ID
		characterInfo['nickname']=self.baseInfo.getNickName()#角色的昵称
		characterInfo['roletype']=self.baseInfo.getType()#角色V类型
		characterInfo['vipexp']=self.level.getVipExp()#VIP经验
		characterInfo['level']=self.level.getLevel()#等级
		characterInfo['energy']=self.attribute.getEnergy()#活力
		characterInfo['photo']=self.attribute.getPhoto()
		characterInfo['power']=self.attribute.getPower()
		characterInfo['maxpower']=self.attribute.getMaxPower()
		characterInfo['trainpoint']=self.attribute.getTrainPoint()
		characterInfo['repute']=self.attribute.getRepute()#声望
		characterInfo['exp']=int(self.level.getExp())#经验
		characterInfo['maxExp']=int(self.level.getMaxExp())#最大经验
		characterInfo['gamecoin']=self.finance.getGameCoin()#银币
		characterInfo['coin']=self.finance.getCoin()#金币
		characterInfo['zenid']=self.zen.getZenId()
		characterInfo['tacticspoint']=self.attribute.getTacticsPoint()
		return characterInfo

	def CheckClient(self,dynamicId):
		'''检查客户端id是否匹配'''
		if self.dynamicId==dynamicId:
			return True
		return False

	def updateGamerDBInfo(self):
		'''更新角色在数据库中的数据'''
		cid=self.baseInfo.id
		pmmode=tb_character_admin.getObj(cid)
		mapping={'level':self.level.getLevel(),'repute':self.attribute.getRepute(),'gamecoin':self.finance.getGameCoin(),'coin':self.finance.getCoin(),'exp':self.level.getExp(),'energy':self.attribute.getEnergy(),'trainpoint':self.attribute.getTrainPoint(),'power':self.attribute.getPower(),'maxpower':self.attribute.getMaxPower(),'tacticspoint':self.attribute.getTacticsPoint()}
		pmmode.update_multi(mapping)

	def CalPower(self):
		'''计算球队实力'''
		zen=self.zen.getZenInfo()
		zenid=zen.get('zenId')
		zenlv=0
		if zenid==1:
			zenlv=zen.get('lvzen1')
		elif zenid==2:
			zenlv=zen.get('lvzen2')
		elif zenid==3:
			zenlv=zen.get('lvzen3')
		elif zenid==4:
			zenlv=zen.get('lvzen4')
		elif zenid==5:
			zenlv=zen.get('lvzen5')
		elif zenid==6:
			zenlv=zen.get('lvzen6')
		power=self.attribute.calClubPower(zenid,zenlv)
		return power

	def getZenId(self):
		''''''
		return self.zen.getZenId()
Esempio n. 2
0
class GamerCharacter(Character):
    '''玩家角色类'''
    def __init__(self, cid, name=u'', dynamicId=-1, status=1):
        '''构造方法
		@dynamicId (int) 角色登录的动态ID socket连接产生的id
		'''
        Character.__init__(self, cid, name)
        self.setCharacterType(Character.GAMERTYPE)  #设置角色类型为玩家角色
        self.dynamicId = dynamicId  #角色登录服务器时的动态id
        #-----------角色的各个组件类----------------
        self.level = CharacterLevelComponent(self)  #角色等级
        self.finance = CharacterFinanceComponent(self)  #角色资产
        self.pack = CharacterPackageComponent(self)  #角色包裹
        self.attribute = CharacterAttributeComponent(self)  #角色属性
        self.mail = CharacterMailListComponent(self)  #角色邮件列表
        self.playerInner = PlayerInner(self)  #球员找寻
        self.player = PlayerComponent(self)  #球队球员
        self.zen = CharacterZenComponent(self)  #球队战术
        self.shop = CharacterShopComponent(self)  #商店
        self.task = CharacterTaskComponent(self)  #任务
        self.trainmatch = TrainMatchComponent(self)  #训练赛
        self.challengematch = ChallengeMatchComponent(self)  #挑战赛
        if status:
            self.initGamerInfo()  #初始化角色

    def initGamerInfo(self):
        '''初始化角色信息'''
        cid = self.baseInfo.id
        charactermode = tb_character_admin.getObj(cid)
        data = charactermode.get("data")
        if not data:
            print "Inint_gamer _" + str(self.baseInfo.id)
        #---------初始化角色基础信息组件---------
        self.baseInfo.setType(data['viptype'])  #角色VIP类型
        self.baseInfo.setnickName(data['nickname'])  #角色昵称
        #---------初始化角色经验等级组件---------
        self.level.setLevel(data['level'])
        self.level.setExp(data['exp'])
        self.level.setVipExp(data['vipexp'])
        #---------初始化角色属性信息组件---------
        self.attribute.initEnergy(data['energy'])
        self.attribute.setPhoto(data['Photo'])
        self.attribute.setPower(data['power'])
        self.attribute.setMaxPower(data['maxpower'])
        self.attribute.setTrainPoint(data['trainpoint'])
        self.attribute.setTacticsPoint(data['tacticspoint'])
        self.attribute.setRepute(data['repute'])  #角色声望
        #---------初始化角色资产信息组件---------
        self.finance.setGameCoin(data['gamecoin'])
        self.finance.setCoin(data['coin'])
        #---------初始化包裹---------------------
        self.pack.initPack(packageSize=data['packageSize'])
        #---------初始化角色球员信息-------------
        self.player.initPlayerInfo()
        #---------初始化角色任务-----------------
        self.task.initCharacterTask()

    def getDynamicId(self):
        '''获取角色的动态Id'''
        return self.dynamicId

    def formatInfo(self):
        '''格式化角色基本信息'''
        characterInfo = {}
        characterInfo['id'] = self.baseInfo.id  #角色的ID
        characterInfo['nickname'] = self.baseInfo.getNickName()  #角色的昵称
        characterInfo['roletype'] = self.baseInfo.getType()  #角色V类型
        characterInfo['vipexp'] = self.level.getVipExp()  #VIP经验
        characterInfo['level'] = self.level.getLevel()  #等级
        characterInfo['energy'] = self.attribute.getEnergy()  #活力
        characterInfo['photo'] = self.attribute.getPhoto()
        characterInfo['power'] = self.attribute.getPower()
        characterInfo['maxpower'] = self.attribute.getMaxPower()
        characterInfo['trainpoint'] = self.attribute.getTrainPoint()
        characterInfo['repute'] = self.attribute.getRepute()  #声望
        characterInfo['exp'] = int(self.level.getExp())  #经验
        characterInfo['maxExp'] = int(self.level.getMaxExp())  #最大经验
        characterInfo['gamecoin'] = self.finance.getGameCoin()  #银币
        characterInfo['coin'] = self.finance.getCoin()  #金币
        characterInfo['zenid'] = self.zen.getZenId()
        characterInfo['tacticspoint'] = self.attribute.getTacticsPoint()
        return characterInfo

    def CheckClient(self, dynamicId):
        '''检查客户端id是否匹配'''
        if self.dynamicId == dynamicId:
            return True
        return False

    def updateGamerDBInfo(self):
        '''更新角色在数据库中的数据'''
        cid = self.baseInfo.id
        pmmode = tb_character_admin.getObj(cid)
        mapping = {
            'level': self.level.getLevel(),
            'repute': self.attribute.getRepute(),
            'gamecoin': self.finance.getGameCoin(),
            'coin': self.finance.getCoin(),
            'exp': self.level.getExp(),
            'energy': self.attribute.getEnergy(),
            'trainpoint': self.attribute.getTrainPoint(),
            'power': self.attribute.getPower(),
            'maxpower': self.attribute.getMaxPower(),
            'tacticspoint': self.attribute.getTacticsPoint()
        }
        pmmode.update_multi(mapping)

    def CalPower(self):
        '''计算球队实力'''
        zen = self.zen.getZenInfo()
        zenid = zen.get('zenId')
        zenlv = 0
        if zenid == 1:
            zenlv = zen.get('lvzen1')
        elif zenid == 2:
            zenlv = zen.get('lvzen2')
        elif zenid == 3:
            zenlv = zen.get('lvzen3')
        elif zenid == 4:
            zenlv = zen.get('lvzen4')
        elif zenid == 5:
            zenlv = zen.get('lvzen5')
        elif zenid == 6:
            zenlv = zen.get('lvzen6')
        power = self.attribute.calClubPower(zenid, zenlv)
        return power

    def getZenId(self):
        ''''''
        return self.zen.getZenId()
Esempio n. 3
0
class PlayerCharacter(Character):
    '''玩家角色类'''
    def __init__(self, cid, name=u'城管', dynamicId=-1, status=1):
        '''构造方法
        @dynamicId (int) 角色登陆的动态ID socket连接产生的id
        '''
        Character.__init__(self, cid, name)
        self.setCharacterType(Character.PLAYERTYPE)  #设置角色类型为玩家角色
        self.dynamicId = dynamicId  #角色登陆服务器时的动态id
        #--------角色的各个组件类------------
        self.level = CharacterLevelComponent(self)  #角色等级
        self.finance = CharacterFinanceComponent(self)  #角色资产
        self.profession = CharacterProfessionComponent(self)  #角色职业
        self.pack = CharacterPackageComponent(self)  #角色包裹
        self.friend = CharacterFriendComponent(self)  #角色好友
        self.attribute = CharacterAttributeComponent(self)  #角色属性
        self.pet = CharacterPetComponent(self)  #角色的宠物
        self.matrix = CharacterMatrixComponent(self)  #阵法摆放信息
        self.zhanyi = CharacterZhanYiComponent(self)  #角色的战役信息
        self.arena = CharacterAreanaComponent(self)  #角色竞技场
        self.mail = CharacterMailListComponent(self)  #角色邮件列表
        if status:
            self.initPlayerInfo()  #初始化角色

    def initPlayerInfo(self):
        '''初始化角色信息'''
        pid = self.baseInfo.id
        pmmode = tb_character_admin.getObj(pid)
        data = pmmode.get("data")
        if not data:
            print "Inint_player _" + str(self.baseInfo.id)
        #------------初始化角色基础信息组件---------
        self.baseInfo.setType(data['viptype'])  #角色VIP类型
        self.baseInfo.setnickName(data['nickname'])  #角色昵称
        self.profession.setProfession(data['profession'])
        self.profession.setFigure(data['figure'])
        #------------初始化角色经验等级组件-----------
        self.level.setLevel(data['level'])
        self.level.setExp(data['exp'])
        self.level.setVipExp(data['vipexp'])
        #------------初始化角色属性信息组件-----------
        self.attribute.initEnergy(data['energy'])

        #------------初始化角色资产信息组件-------------
        self.finance.setCoin(data['coin'])
        self.finance.setGold(data['gold'])
        #------------初始化角色武将信息组件-------------
        self.pet.initCharacterPetInfo()
        #---------------初始化包裹---------------
        self.pack.initPack(packageSize=data['packageSize'])
        #-----------初始化角色好友数量------------------
        self.attribute.setHp(data['hp'])

    def getDynamicId(self):
        '''获取角色的动态Id'''
        return self.dynamicId

    def formatInfo(self):
        '''格式化角色基本信息'''
        attrinfo = self.attribute.getCharacterAttr()
        characterInfo = {}
        characterInfo['id'] = self.baseInfo.id  #角色的ID
        characterInfo['nickname'] = self.baseInfo.getNickName()  #角色的昵称
        characterInfo['roletype'] = self.baseInfo.getType()
        characterInfo['vipexp'] = self.level.getVipExp()
        characterInfo['level'] = self.level.getLevel()
        characterInfo['profession'] = self.profession.getFigure()
        characterInfo['energy'] = self.attribute.getEnergy()
        characterInfo['rank'] = ''  #self.rank.getRankName()
        characterInfo[
            'guildname'] = u''  #self.guild.getGuildInfo().get('name','')

        characterInfo['manualStr'] = attrinfo.get('Str', 0)
        characterInfo['manualDex'] = attrinfo.get('Dex', 0)
        characterInfo['manualVit'] = attrinfo.get('Vit', 0)
        characterInfo['manualWis'] = attrinfo.get('Wis', 0)
        characterInfo['maxHp'] = int(self.attribute.getMaxHp())
        characterInfo['hp'] = int(self.attribute.getHp())
        characterInfo['exp'] = int(self.level.getExp())
        characterInfo['maxExp'] = int(self.level.getMaxExp())

        characterInfo['physicalAttack'] = attrinfo.get('PhyAtt', 0)
        characterInfo['magicAttack'] = attrinfo.get('MigAtt', 0)
        characterInfo['physicalDefense'] = attrinfo.get('PhyDef', 0)
        characterInfo['magicDefense'] = attrinfo.get('MigDef', 0)
        characterInfo['speed'] = attrinfo.get('Speed', 0)
        characterInfo['dodgeRate'] = attrinfo.get('Dodge', 0)
        characterInfo['critRate'] = attrinfo.get('CriRate', 0)
        characterInfo['block'] = attrinfo.get('Block', 0)
        characterInfo['hitRate'] = attrinfo.get('HitRate', 0)

        characterInfo['coin'] = self.finance.getCoin()
        characterInfo['gold'] = self.finance.getGold()
        return characterInfo

    def CheckClient(self, dynamicId):
        '''检测客户端id是否匹配'''
        if self.dynamicId == dynamicId:
            return True
        return False

    def updatePlayerDBInfo(self):
        '''更新角色在数据库中的数据'''
        pid = self.baseInfo.id
        pmmode = tb_character_admin.getObj(pid)
        mapping = {
            'level': self.level.getLevel(),
            'coin': self.finance.getCoin(),
            'gold': self.finance.getGold(),
            'exp': self.level.getExp(),
            'energy': self.attribute.getEnergy()
        }
        pmmode.update_multi(mapping)

        self.pack._equipmentSlot.updateEquipments(self.baseInfo.id)

    def getFightData(
        self,
        preDict={
            'extVitper': 0,
            'extStrper': 0,
            'extDexper': 0,
            'extWisper': 0,
            'extSpiper': 0
        }):
        '''获取战斗数据'''
        attrinfo = self.attribute.getCharacterAttr()
        fightdata = {}
        fightdata['chaId'] = self.baseInfo.id  #角色的ID
        fightdata['chaName'] = self.baseInfo.getNickName()  #角色的昵称
        fightdata['chaLevel'] = self.level.getLevel()  #角色的等级
        fightdata[
            'characterType'] = self.CharacterType  #角色的类型  1:玩家角色 2:怪物 3:宠物
        fightdata['figureType'] = self.profession.getFightFigure()  #角色形象类型
        fightdata['chaBattleId'] = 0  #角色在战场中的id
        fightdata['difficulty'] = 0  #怪物难度
        fightdata['chaProfessionType'] = self.profession.getFightFigure(
        )  #角色的角色形象ID
        fightdata['chaIcon'] = self.profession.getProfession()
        fightdata['chatype'] = 0
        fightdata[
            'chaDirection'] = 1  #(角色在战斗中的归属阵营)1--(主动方)玩家朝向右,朝向右。2(被动方)--玩家朝向左
        fightdata['chaCurrentHp'] = self.attribute.getMaxHp()  #角色当前血量
        fightdata['chaCurrentPower'] = attrinfo.get('power',
                                                    0)  #角色的当前能量#角色的当前能量
        fightdata['chaTotalHp'] = self.attribute.getMaxHp()  #角色的最大血量
        fightdata['chaTotalPower'] = Character.MAXPOWER  #角色的最大能量
        fightdata['chaPos'] = (0, 0)  #角色的坐标
        fightdata['physicalAttack'] = attrinfo.get('PhyAtt', 0)
        fightdata['magicAttack'] = attrinfo.get('MigAtt', 0)  #角色的魔法攻击
        fightdata['physicalDefense'] = attrinfo.get('PhyDef', 0)  #角色的物理防御
        fightdata['magicDefense'] = attrinfo.get('MigDef', 0)  #角色的魔法防御
        fightdata['speed'] = attrinfo.get('Speed', 0)  #角色的攻速
        fightdata['hitRate'] = attrinfo.get('HitRate', 0)  #角色的命中
        fightdata['critRate'] = attrinfo.get('CriRate', 0)  #角色的当前暴击率
        fightdata['block'] = attrinfo.get('Block', 0)  #角色的抗暴率
        fightdata['dodgeRate'] = attrinfo.get('Dodge', 0)  #角色的闪避几率
        fightdata['ActiveSkillList'] = attrinfo.get(
            'Skill', [])  #self.skill.getActiveSkillList()#角色的主动攻击技能
        fightdata['ordSkill'] = self.profession.getOrdinarySkill()  #角色的普通攻击技能
        fightdata['canDoMagicSkill'] = 1  #可否释放魔法技能
        fightdata['canDoPhysicalSkill'] = 1  #可否释放物理技能
        fightdata['canDoOrdSkill'] = 1  #可否进行普通攻击
        fightdata['canBeTreat'] = 1  #可否被治疗
        fightdata['canBeAttacked'] = 1  #可否被攻击
        fightdata['canDied'] = 1  #是否可死亡
        fightdata['skillIDByAttack'] = 0  #被攻击的技能的ID 普通攻击为 0
        fightdata['expbound'] = 0  #经验奖励
        fightdata['chaPz'] = 0
        fightdata['equip'] = {}  #self.pack.getAllEquipttributes()
        return fightdata

    def formatInfoForWeiXin(self):
        '''格式化角色信息
        '''
        attrinfo = self.attribute.getCharacterAttr()
        info = {}
        info['chaid'] = self.baseInfo.id
        info['rolename'] = self.baseInfo.getNickName()
        info['icon'] = self.profession.getProfession()
        info['level'] = self.level.getLevel()
        guanqiainfo = {}
        info['guanqia'] = u'无' if not guanqiainfo else guanqiainfo['name']
        skill = attrinfo.get('Skill', [])
        if skill:
            skillinfo = dbSkill.ALL_SKILL_INFO.get(skill[0])
        else:
            skillinfo = None
        info['skill'] = u'无' if not skillinfo else skillinfo['skillName']
        info['attack'] = attrinfo.get('PhyAtt', 0)
        info['fangyu'] = attrinfo.get('PhyDef', 0)
        info['tili'] = self.attribute.getMaxHp()
        info['minjie'] = attrinfo.get('Speed', 0)
        info['price'] = self.level.getLevel() * 1000
        return info
class PlayerCharacter(Character):
    '''玩家角色类'''
    def __init__(self , cid , name = u'城管', dynamicId = -1,status = 1):
        '''构造方法
        @dynamicId (int) 角色登陆的动态ID socket连接产生的id
        '''
        Character.__init__(self, cid, name)
        self.setCharacterType(Character.PLAYERTYPE)#设置角色类型为玩家角色
        self.dynamicId = dynamicId    #角色登陆服务器时的动态id
        #--------角色的各个组件类------------
        self.level = CharacterLevelComponent(self)    #角色等级
        self.finance = CharacterFinanceComponent(self)    #角色资产
        self.profession = CharacterProfessionComponent(self) #角色职业
        self.pack = CharacterPackageComponent(self)    #角色包裹
        self.attribute = CharacterAttributeComponent(self)  #角色属性
        self.matrix = CharacterMatrixComponent(self) #阵法摆放信息
        self.zhanyi = CharacterZhanYiComponent(self)#角色的战役信息
        if status:
            self.initPlayerInfo() #初始化角色
        
    def initPlayerInfo(self):
        '''初始化角色信息'''
        pid = self.baseInfo.id
        pmmode = tb_character_admin.getObj(pid)
        data = pmmode.get("data")
        if not data:
            print "Inint_player _"+str(self.baseInfo.id)
        #------------初始化角色基础信息组件---------
        self.baseInfo.setType(data['viptype'])  #角色VIP类型
        self.baseInfo.setnickName(data['nickname']) #角色昵称
        self.profession.setProfession(data['profession'])
        self.profession.setFigure(data['figure'])
        #------------初始化角色经验等级组件-----------
        self.level.setLevel(data['level'])
        self.level.setExp(data['exp'])
        self.level.setVipExp(data['vipexp'])
        #------------初始化角色属性信息组件-----------
        self.attribute.initEnergy(data['energy'])
        
        #------------初始化角色资产信息组件-------------
        self.finance.setCoin(data['coin'])
        self.finance.setGold(data['gold'])
        #---------------初始化包裹---------------
        self.pack.initPack(packageSize=data['packageSize'])
        #-----------初始化角色好友数量------------------
        self.attribute.setHp(data['hp'])
            
    def getDynamicId(self):
        '''获取角色的动态Id'''
        return self.dynamicId
    
    def formatInfo(self):
        '''格式化角色基本信息'''
        attrinfo = self.attribute.getCharacterAttr()
        characterInfo = {}
        characterInfo['id'] = self.baseInfo.id#角色的ID
        characterInfo['nickname'] = self.baseInfo.getNickName()#角色的昵称
        characterInfo['roletype'] = self.baseInfo.getType()
        characterInfo['vipexp'] = self.level.getVipExp()
        characterInfo['level'] = self.level.getLevel()
        characterInfo['profession'] = self.profession.getFigure()
        characterInfo['energy'] = self.attribute.getEnergy()
        characterInfo['rank'] = ''#self.rank.getRankName()
        characterInfo['guildname'] = u''#self.guild.getGuildInfo().get('name','')
        
        characterInfo['manualStr'] = attrinfo.get('Str',0)
        characterInfo['manualDex'] = attrinfo.get('Dex',0)
        characterInfo['manualVit'] = attrinfo.get('Vit',0)
        characterInfo['manualWis'] = attrinfo.get('Wis',0)
        characterInfo['maxHp'] = int(self.attribute.getMaxHp())
        characterInfo['hp'] = int(self.attribute.getHp())
        characterInfo['exp'] = int(self.level.getExp())
        characterInfo['maxExp'] = int(self.level.getMaxExp())
        
        characterInfo['physicalAttack'] = attrinfo.get('PhyAtt',0)
        characterInfo['magicAttack'] = attrinfo.get('MigAtt',0)
        characterInfo['physicalDefense'] = attrinfo.get('PhyDef',0)
        characterInfo['magicDefense'] = attrinfo.get('MigDef',0)
        characterInfo['speed'] = attrinfo.get('Speed',0)
        characterInfo['dodgeRate'] = attrinfo.get('Dodge',0)
        characterInfo['critRate'] = attrinfo.get('CriRate',0)
        characterInfo['block'] = attrinfo.get('Block',0)
        characterInfo['hitRate'] = attrinfo.get('HitRate',0)

        characterInfo['coin'] = self.finance.getCoin()
        characterInfo['gold'] = self.finance.getGold()
        return characterInfo
         
    def CheckClient(self,dynamicId):
        '''检测客户端id是否匹配'''
        if self.dynamicId ==dynamicId:
            return True
        return False
        
    def updatePlayerDBInfo(self):
        '''更新角色在数据库中的数据'''
        pid = self.baseInfo.id
        pmmode = tb_character_admin.getObj(pid)
        mapping = {'level':self.level.getLevel(),'coin':self.finance.getCoin(),
                   'gold':self.finance.getGold(),'exp':self.level.getExp(),
                   'energy':self.attribute.getEnergy()}
        pmmode.update_multi(mapping)
        self.pack._equipmentSlot.updateEquipments(self.baseInfo.id)

    def getFightData(self,preDict = {'extVitper':0,'extStrper':0,
                                 'extDexper':0,'extWisper':0,'extSpiper':0}):
        '''获取战斗数据'''
        attrinfo = self.attribute.getCharacterAttr()
        fightdata = {}
        fightdata['chaId'] = self.baseInfo.id               #角色的ID
        fightdata['chaName'] = self.baseInfo.getNickName()  #角色的昵称
        fightdata['chaLevel'] = self.level.getLevel()#角色的等级
        fightdata['characterType'] = self.CharacterType#角色的类型  1:玩家角色 2:怪物 3:宠物
        fightdata['figureType'] = self.profession.getFightFigure()#角色形象类型
        fightdata['chaBattleId'] = 0                        #角色在战场中的id
        fightdata['difficulty'] = 0#怪物难度
        fightdata['chaProfessionType'] = self.profession.getFightFigure()#角色的角色形象ID
        fightdata['chaIcon'] = self.profession.getProfession()
        fightdata['chatype'] = 0
        fightdata['chaDirection'] = 1#(角色在战斗中的归属阵营)1--(主动方)玩家朝向右,朝向右。2(被动方)--玩家朝向左
        fightdata['chaCurrentHp'] = self.attribute.getMaxHp()#角色当前血量
        fightdata['chaCurrentPower'] = attrinfo.get('power',0)#角色的当前能量#角色的当前能量
        fightdata['chaTotalHp'] = self.attribute.getMaxHp()#角色的最大血量
        fightdata['chaTotalPower'] = Character.MAXPOWER#角色的最大能量
        fightdata['chaPos'] = (0,0)#角色的坐标
        fightdata['physicalAttack'] = attrinfo.get('PhyAtt',0)
        fightdata['magicAttack'] = attrinfo.get('MigAtt',0)#角色的魔法攻击
        fightdata['physicalDefense'] = attrinfo.get('PhyDef',0)#角色的物理防御
        fightdata['magicDefense'] = attrinfo.get('MigDef',0)#角色的魔法防御
        fightdata['speed'] = attrinfo.get('Speed',0)#角色的攻速
        fightdata['hitRate'] = attrinfo.get('HitRate',0)#角色的命中
        fightdata['critRate'] = attrinfo.get('CriRate',0)#角色的当前暴击率
        fightdata['block'] = attrinfo.get('Block',0)#角色的抗暴率
        fightdata['dodgeRate'] = attrinfo.get('Dodge',0)#角色的闪避几率
        fightdata['ActiveSkillList'] = attrinfo.get('Skill',[])#self.skill.getActiveSkillList()#角色的主动攻击技能
        fightdata['ordSkill'] = self.profession.getOrdinarySkill()#角色的普通攻击技能
        fightdata['canDoMagicSkill'] = 1#可否释放魔法技能
        fightdata['canDoPhysicalSkill'] = 1#可否释放物理技能
        fightdata['canDoOrdSkill'] = 1#可否进行普通攻击
        fightdata['canBeTreat'] = 1#可否被治疗
        fightdata['canBeAttacked'] = 1#可否被攻击
        fightdata['canDied'] = 1#是否可死亡
        fightdata['skillIDByAttack'] = 0#被攻击的技能的ID 普通攻击为 0
        fightdata['expbound'] = 0#经验奖励
        fightdata['chaPz'] = 0
        fightdata['equip'] = {}#self.pack.getAllEquipttributes()
        return fightdata
        
    def formatInfoForWeiXin(self):
        '''格式化角色信息
        '''
        attrinfo = self.attribute.getCharacterAttr()
        info = {}
        info['chaid'] = self.baseInfo.id
        info['rolename'] = self.baseInfo.getNickName()
        info['icon'] = self.profession.getProfession()
        info['level'] = self.level.getLevel()
        guanqiainfo = {}
        info['guanqia'] = u'无' if not guanqiainfo else guanqiainfo['name']
        skill = attrinfo.get('Skill',[])
        if skill:
            skillinfo = dbSkill.ALL_SKILL_INFO.get(skill[0])
        else:
            skillinfo = None
        info['skill'] = u'无' if not skillinfo else skillinfo['skillName']
        info['attack'] = attrinfo.get('PhyAtt',0)
        info['fangyu'] = attrinfo.get('PhyDef',0)
        info['tili'] = self.attribute.getMaxHp()
        info['minjie'] = attrinfo.get('Speed',0)
        info['price'] = self.level.getLevel()*1000
        return info