def updateLevel(self,level): '''更新角色当前等级 @param level: int 等级 ''' from app.scense.core.PlayersManager import PlayersManager self._level = level dbCharacterPet.updatePetInfo(self._owner.baseInfo.getId(), {'level':self._level}) player = PlayersManager().getPlayerByID(self._owner._owner) player.daily.noticeDaily(3,0,self._level)#通知有宠物升级
def updateLevel(self, level): '''更新角色当前等级 @param level: int 等级 ''' from app.scense.core.PlayersManager import PlayersManager self._level = level dbCharacterPet.updatePetInfo(self._owner.baseInfo.getId(), {'level': self._level}) player = PlayersManager().getPlayerByID(self._owner._owner) player.daily.noticeDaily(3, 0, self._level) #通知有宠物升级
def updateExp(self, exp): '''更新当前血量''' state = 0 while exp >= self.getMaxExp(): print self.getMaxExp() exp = exp - self.getMaxExp() self.level += 1 state = 1 self.exp = exp if state: self.updateLevel(self.level) dbCharacterPet.updatePetInfo(self.baseInfo.id, {'exp': self.exp})
def updateExp(self,exp): '''更新当前血量''' state = 0 while exp>=self.getMaxExp(): print self.getMaxExp() exp = exp - self.getMaxExp() self.level += 1 state = 1 self.exp = exp if state: self.updateLevel(self.level) dbCharacterPet.updatePetInfo(self.baseInfo.id, {'exp':self.exp})
def updateName(self,petName): '''更新宠物名称''' prop = {'name':petName} result = dbCharacterPet.updatePetInfo(self.baseInfo.id, prop) if result: self.baseInfo.setName(petName) return 1 return 0
def updateName(self, petName): '''更新宠物名称''' prop = {'name': petName} result = dbCharacterPet.updatePetInfo(self.baseInfo.id, prop) if result: self.baseInfo.setName(petName) return 1 return 0
def updateExp(self,exp): '''更新角色经验值 @param exp: int 经验值 @param status: int 表示是否及时推送升级消息 ''' if exp ==self._exp: return if self._level>=self.MAXLEVEL: return status = 0 self._exp = exp while self._exp >= self.getMaxExp(): self._exp -= self.getMaxExp() self._level += 1 status = 1 if status: self.updateLevel(self._level) dbCharacterPet.updatePetInfo(self._owner.baseInfo.getId(), {'exp':self._exp})
def Training(self, trainingLevel): '''培养 @param trainingLevel: int 培养的级别 ''' prop = PetTrain(trainingLevel + 1) result = dbCharacterPet.updatePetInfo(self.baseInfo.id, prop) if result: for item in prop.items(): self._extAttribute[item[0]] = item[1] return 1
def Training(self,trainingLevel): '''培养 @param trainingLevel: int 培养的级别 ''' prop = PetTrain(trainingLevel+1) result = dbCharacterPet.updatePetInfo(self.baseInfo.id, prop) if result: for item in prop.items(): self._extAttribute[item[0]] = item[1] return 1
def modifySlogan(self,slogan): '''更新战斗宣言 @param slogan: string 战斗宣言 ''' prop = {'slogan':str(slogan)} result = dbCharacterPet.updatePetInfo(self.baseInfo.id, prop) if result: self._extAttribute['slogan'] = slogan return 1 return 0
def updateExp(self, exp): '''更新角色经验值 @param exp: int 经验值 @param status: int 表示是否及时推送升级消息 ''' if exp == self._exp: return if self._level >= self.MAXLEVEL: return status = 0 self._exp = exp while self._exp >= self.getMaxExp(): self._exp -= self.getMaxExp() self._level += 1 status = 1 if status: self.updateLevel(self._level) dbCharacterPet.updatePetInfo(self._owner.baseInfo.getId(), {'exp': self._exp})
def modifySlogan(self, slogan): '''更新战斗宣言 @param slogan: string 战斗宣言 ''' prop = {'slogan': str(slogan)} result = dbCharacterPet.updatePetInfo(self.baseInfo.id, prop) if result: self._extAttribute['slogan'] = slogan return 1 return 0
def learnSkill(self): '''宠物学习(激活)技能''' skillSpace = self.foundSkillSpace() if not skillSpace: return -1 #技能槽已满 newskill = getRandomPetSkill() self._skillInfo.append(newskill) prop = {skillSpace: newskill} result = dbCharacterPet.updatePetInfo(self.baseInfo.id, prop) if result: return 1, newskill return 0, newskill
def learnSkill(self): '''宠物学习(激活)技能''' skillSpace = self.foundSkillSpace() if not skillSpace: return -1#技能槽已满 newskill = getRandomPetSkill() self._skillInfo.append(newskill) prop = {skillSpace:newskill} result = dbCharacterPet.updatePetInfo(self.baseInfo.id, prop) if result: return 1,newskill return 0,newskill
def Tihuan(self): '''宠物属性替换''' self.StrGrowth += self.StrGrowthAdd self.WisGrowth += self.WisGrowthAdd self.DexGrowth += self.DexGrowthAdd self.VitGrowth += self.VitGrowthAdd props = {} if self.StrGrowthAdd: props['StrGrowth'] = self.StrGrowth if self.StrGrowthAdd: props['WisGrowth'] = self.WisGrowth if self.StrGrowthAdd: props['DexGrowth'] = self.DexGrowth if self.StrGrowthAdd: props['VitGrowth'] = self.VitGrowth if props: dbCharacterPet.updatePetInfo(self._owner.baseInfo.id, props) self.StrGrowthAdd = 0 self.WisGrowthAdd = 0 self.DexGrowthAdd = 0 self.VitGrowthAdd = 0 return {'result':True,'message':Lg().g(269)}
def Tihuan(self): '''宠物属性替换''' self.StrGrowth += self.StrGrowthAdd self.WisGrowth += self.WisGrowthAdd self.DexGrowth += self.DexGrowthAdd self.VitGrowth += self.VitGrowthAdd props = {} if self.StrGrowthAdd: props['StrGrowth'] = self.StrGrowth if self.StrGrowthAdd: props['WisGrowth'] = self.WisGrowth if self.StrGrowthAdd: props['DexGrowth'] = self.DexGrowth if self.StrGrowthAdd: props['VitGrowth'] = self.VitGrowth if props: dbCharacterPet.updatePetInfo(self._owner.baseInfo.id, props) self.StrGrowthAdd = 0 self.WisGrowthAdd = 0 self.DexGrowthAdd = 0 self.VitGrowthAdd = 0 return {'result': True, 'message': Lg().g(269)}
def levelUpSkill(self, skillSpace): '''升级宠物技能 @param skillSpace: int 技能的位置 ''' if 0 > skillSpace or len(self._skillInfo) <= skillSpace: return -2 #超过位置范围 skillId = self._skillInfo[skillSpace] skillInfo = dbCharacterPet.PET_SKILL_POOL.get(skillId) if not skillInfo: return -1 #技能信息不存在 groupId = skillInfo.get('skillGroup') #技能组ID level = skillInfo.get('level') #技能等级 newskillInfo = dbCharacterPet.PET_SKILLGROUP[groupId].get(level + 1) if newskillInfo: propname = 'skill_%d' % (skillSpace + 1) newSkillId = newskillInfo.get('skillID') prop = {propname: newSkillId} result = dbCharacterPet.updatePetInfo(self.baseInfo.id, prop) if result: self._skillInfo[skillSpace] = newSkillId return 1 #成功 else: return -3 #数据库写入出错 return 0 #技能达到最高等级
def levelUpSkill(self,skillSpace): '''升级宠物技能 @param skillSpace: int 技能的位置 ''' if 0 > skillSpace or len(self._skillInfo) <= skillSpace: return -2#超过位置范围 skillId = self._skillInfo[skillSpace] skillInfo = dbCharacterPet.PET_SKILL_POOL.get(skillId) if not skillInfo: return -1#技能信息不存在 groupId = skillInfo.get('skillGroup')#技能组ID level = skillInfo.get('level')#技能等级 newskillInfo = dbCharacterPet.PET_SKILLGROUP[groupId].get(level+1) if newskillInfo: propname = 'skill_%d'%(skillSpace+1) newSkillId = newskillInfo.get('skillID') prop = {propname:newSkillId} result = dbCharacterPet.updatePetInfo(self.baseInfo.id, prop) if result: self._skillInfo[skillSpace] = newSkillId return 1#成功 else: return -3#数据库写入出错 return 0#技能达到最高等级
def update_ChuanCheng(self): '''更新该宠物已经被传承 ''' self._chuancheng = True prop = {'_chuancheng': 1} dbCharacterPet.updatePetInfo(self.baseInfo.id, prop)
def update_ChuanCheng(self): '''更新该宠物已经被传承 ''' self._chuancheng = True prop = {'_chuancheng':1} dbCharacterPet.updatePetInfo(self.baseInfo.id, prop)
def updateFlowFlag(self, flowFlag): '''更新跟随状态''' self.flowFlag = flowFlag dbCharacterPet.updatePetInfo(self.baseInfo.id, {'showed': flowFlag})
def updateHp(self, hp): '''更新当前血量''' self.setHp(hp) dbCharacterPet.updatePetInfo(self.baseInfo.id, {'hp': self.hp})
def updateLifeState(self, lifestate): '''设置生存状态''' self.lifestate = lifestate dbCharacterPet.updatePetInfo(self.baseInfo.id, {'lifestate': lifestate})
def updateLevel(self, level): '''更新宠物的等级''' self.level = level dbCharacterPet.updatePetInfo(self.baseInfo.id, {'level': level})
def updateLevel(self,level): '''更新宠物的等级''' self.level = level dbCharacterPet.updatePetInfo(self.baseInfo.id, {'level':level})
def updateLifeState(self,lifestate): '''设置生存状态''' self.lifestate = lifestate dbCharacterPet.updatePetInfo(self.baseInfo.id, {'lifestate':lifestate})
def updateFlowFlag(self,flowFlag): '''更新跟随状态''' self.flowFlag = flowFlag dbCharacterPet.updatePetInfo(self.baseInfo.id, {'showed':flowFlag})
def updateHp(self,hp): '''更新当前血量''' self.setHp(hp) dbCharacterPet.updatePetInfo(self.baseInfo.id, {'hp':self.hp})