def wrapBriefQuestRecordObject(self, record, questInfo): '''封装简要任务记录信息''' questTemplateInfo = loader.getById('quest_template', record[1], ['name', 'type', 'category', 'accepter']) questInfo['name'] = questTemplateInfo['name'] questInfo['type'] = questTemplateInfo['type'] questInfo['category'] = questTemplateInfo['category'] questInfo['id'] = record[0] questInfo['questTemplateId'] = record[1] accepterId = questTemplateInfo['accepter'] accepterInfo = loader.getById('npc', accepterId, ['id', 'name']) if accepterInfo: questInfo['accepterInfo'] = accepterInfo self._getQuestNpcInfo(accepterId, accepterInfo) questInfo['accepterInfo']['parentPlaceList'] = self.getFullPlaceList(accepterInfo) else: questInfo['accepterInfo'] = None progresses = dbaccess.getQuestGoalProgressesForQuest(record[0]) detailList = [] for progress in progresses: goal = loader.getById('questgoal', progress[2], ['id', 'itemId', 'itemCount', 'killCount', 'npc', 'npcDialog', 'questId']) details = self.getQuestgoalDetails(progress, goal) detailList.append(details) questInfo['progressesDetails'] = detailList return questInfo
def getQuestgoalDetails(self, progress, goal): '''获取任务目标进度详细信息''' details = {} details['currentKillCount'] = progress[3] tempCount = dbaccess.getCollectionQuestItemCount(goal['itemId'], self._owner.baseInfo.id) if tempCount > goal['itemCount']: details['currentCollectCount'] = goal['itemCount'] else: details['currentCollectCount'] = tempCount details['hasTalkedToNpc'] = progress[5] details['killCount'] = goal['killCount'] details['itemCount'] = goal['itemCount'] details['questgoalId'] = goal['id'] itemName = loader.getById('item_template', goal['itemId'], ['name']) if itemName: details['itemName'] = itemName['name'] else: details['itemName'] = u'无物品名称' if goal['npc'] == -1: details['npcInfo'] = None else: npcName = loader.getById('npc', goal['npc'], ['name'])['name'] npcInfo = {'id':goal['npc'], 'name':npcName} npcInfo = self._getQuestNpcInfo(goal['npc'], npcInfo) details['npcInfo'] = npcInfo #要得到地点完整路径 result = self.getFullPlaceList(npcInfo) details['parentPlaceList'] = result return details
def getLearnedSkills(self): '''获取玩家已修炼的技能信息''' self.learned_skillpool = {} #所学技能分组 learnedSkillsInfo = [] learnedSkills = dbaccess.getLearnedSkills(self._owner.baseInfo.id) num = 0 if learnedSkills is None: return learnedSkillsInfo for elm in learnedSkills: skillId = elm[2] skillLevel = elm[3] skillInfo = loader.getById('skill', skillId, '*') skillInfo['addEffectNames'] = [] effects = [] for effect in skillInfo['addEffect'].split(';'): if int(effect) <> -1: effectInfo = loader.getById('effect', int(effect), ['name', 'description']) effects.append(effectInfo['description']) skillInfo['addEffectNames'].append(effectInfo['name']) learnedSkillsInfo.append({ 'skillInfo': skillInfo, 'skillLevel': skillLevel, 'effects': effects }) num += 1 self.learned_skillpool[learnedSkillsInfo[-1]['skillInfo'] ["groupType"]] = learnedSkillsInfo[-1] return learnedSkillsInfo
def wrapQuestRecordObject(self, record): '''封装任务详细记录对象''' questRecord = {} questRecord['id'] = record[0] questRecord['questTemplageId'] = record[1] questRecord['applyTime'] = record[3] questRecord['finishTime'] = record[4] questRecord['status'] = record[5] #任务奖励信息 questTemplateBonus = loader.getById('quest_template', record[1], ['coinBonus', 'expBonus']) questRecord['coinBonus'] = questTemplateBonus['coinBonus'] questRecord['expBonus'] = questTemplateBonus['expBonus'] itemId = record[6] if itemId == -1: questRecord['itemBonus'] = None else: questRecord['itemBonus'] = self.getQuestItemBouns(itemId) questRecord = self.wrapBriefQuestRecordObject(record, questRecord) templateInfo = loader.getById('quest_template', record[1], '*') questRecord['questTemplateInfo'] = templateInfo #目标provider的信息放在templateInfo中 providerInfo = loader.getById('npc', templateInfo['provider'], ['image', 'name']) providerInfo = self._getQuestNpcInfo(templateInfo['provider'], providerInfo) accepterInfo = loader.getById('npc', templateInfo['accepter'], ['image', 'name']) accepterInfo = self._getQuestNpcInfo(templateInfo['provider'], accepterInfo) questRecord['providerInfo'] = providerInfo questRecord['accepterInfo'] = accepterInfo return questRecord
def getExtraAttributeList(self): '''获取物品的附加属性列表''' selfExtraAttribute = self._selfExtrAttributes dropExtraAttribue = self._dropExtraAttributes extraAttributeList = [] if selfExtraAttribute <> "-1": list = eval('[' + selfExtraAttribute + ']') for i in range(0, len(list)): attributeInfo = loader.getById('extra_attributes', int(list[i]), '*') attributeInfo['attributeEffects'] = [] if attributeInfo['effects'] <> '-1' or attributeInfo[ 'effects'] <> u'-1': effects = attributeInfo['effects'].split(';') for effect in effects: effect = int(effect) description = loader.getById( 'effect', effect, ['description'])['description'] attributeInfo['attributeEffects'].append(description) else: script = attributeInfo['script'] script = util.parseScript(script) attributeInfo['attributeEffects'].append(script) extraAttributeList.append(attributeInfo) # attributeInfo = loader.getById('extra_attributes', int(selfExtraAttribute), '*') # attributeInfo['attributeEffects'] = [] # if attributeInfo['effects']<>'-1' or attributeInfo['effects']<>u'-1': # effects = attributeInfo['effects'].split(';') # for effect in effects: # effect = int(effect) # description = loader.getById('effect', effect, ['description'])['description'] # attributeInfo['attributeEffects'].append(description) # else: # script = attributeInfo['script'] # script = util.parseScript(script) # attributeInfo['attributeEffects'].append(script) # extraAttributeList.append(attributeInfo) elif dropExtraAttribue <> "-1": list = eval('[' + dropExtraAttribue + ']') for i in range(0, len(list)): attributeInfo = loader.getById('extra_attributes', int(list[i]), '*') attributeInfo['attributeEffects'] = [] if attributeInfo['effects'] <> '-1' or attributeInfo[ 'effects'] <> u'-1': effects = attributeInfo['effects'].split(';') for effect in effects: effect = int(effect) description = loader.getById( 'effect', effect, ['description'])['description'] attributeInfo['attributeEffects'].append(description) else: script = attributeInfo['script'] script = util.parseScript(script) attributeInfo['attributeEffects'].append(script) extraAttributeList.append(attributeInfo) return extraAttributeList
def wrapRecievableQuestObject(self, questInfo): '''封装可接任务对象''' providerInfo = loader.getById('npc', questInfo['provider'], ['image', 'name']) providerInfo = self._getQuestNpcInfo(questInfo['provider'], providerInfo) accepterInfo = loader.getById('npc', questInfo['accepter'], ['image', 'name']) accepterInfo = self._getQuestNpcInfo(questInfo['accepter'], accepterInfo) questInfo['providerInfo'] = providerInfo questInfo['accepterInfo'] = accepterInfo return questInfo
def getPassiveSkillsEffects(self, characterId, keyName, type): '''得到玩家被动技能效果''' effects = [] learnedSkills = dbaccess.getLearnedSkills(characterId) if not learnedSkills or len(learnedSkills) == 0: return effects for skill in learnedSkills: skillId = skill[2] skillInfo = loader.getById('skill', skillId, '*') if skillInfo['type'] != 3: continue for effect in skillInfo['addEffect'].split(';'): if int(effect) != -1: effectInfo = loader.getById('effect', int(effect), '*') script = effectInfo['script'].split(";") for list in script: if list.find('owner') <> -1: if list.find(keyName) <> -1: if list.find(type) <> -1: elments = list.split('=') if elments[1].find('owner') <> -1: if elments[1].find('extraStr') <> -1: effectStr = elments[1].split(']') if effectStr[1].find('*') <> -1: extraStr = effectStr[1].split('*') if extraStr[1].find('+') <> -1: extraStr = effectStr[1].split('+') valuePercent = str(extraStr[0]).strip() value = str(extraStr[1]).strip() valuePercent = self._extraStr * valuePercent valuePercent = valuePercent + value effects.append(float(valuePercent)) else: valuePercent = str(extraStr[1]).strip() valuePercent = self._extraStr * valuePercent effects.append(float(valuePercent)) elif elments[1].find('extraDex') <> -1: effectDex = elments[1].split(']') if effectDex[1].find('*') <> -1: extraDex = effectDex[1].split('*') if effectDex[1].find('+') <> -1: extraDex = effectDex[1].split('+') valuePercent = str(extraStr[0]).strip() value = str(extraDex[1]).strip() valuePercent = self._extraStr * valuePercent valuePercent = valuePercent + value effects.append(float(valuePercent)) else: valuePercent = str(extraDex[1]).strip() valuePercent = self._extraDex * valuePercent effects.append(float(valuePercent)) else: value = str(elments[1]).strip() effects.append(float(value)) return effects
def queryTaskNPCInfo(taskID): allnpc = loader.getById('quest_template', taskID, ['generalsID']) if allnpc: allnpc = [allnpc] data = [] for i in allnpc: info = loader.getById('generals', i['generalsID'], '*') if info: data.append(info) return data return None
def enterInstance(self, placeId): '''进入副本''' id = self._owner.baseInfo.id energy = self._owner.attribute.getEnergy() location = placeId instanceId = self._instanceId instanceLayerId = self._instancePlaceId result = False status = self._owner.baseInfo.getStatus() if status != u'正常': return False, u"您已经处于" + status + u"状态" placeInfo = loader.getById('place', placeId, '*') if placeInfo['levelRequire'] > self._owner.level.getLevel(): return False, u'您的级别不够,需要达到 %d 级才能进入' % placeInfo['levelRequire'] if instanceId <> -1: if location <> instanceId: energy -= 10 if energy < 0: return False, u'活力不足' if self._enterInstanceCount >= self.MAXENTERCOUNT: return False, u'今日进入副本次数已经达到两次,不可重新进入新副本' instanceLayers = loader.get('instance', 'entryPlace', location, ['layers'])[0]['layers'] layers = loader.getById('instance_layer', instanceLayers, ['place'])['place'] instanceLayerId = int(layers.split(';')[0]) attrs = {'instanceId':location, 'instanceLayerId':instanceLayerId} result = dbaccess.updatePlayerInstanceProgressRecord(attrs, id) if result: dbaccess.updatePlayerInfo(id, {'energy':energy, 'enterInstanceCount':self._enterInstanceCount + 1}) self.init() else: result = True else: layers = loader.get('instance', 'entryPlace', location, ['layers']) if len(layers) < 0: return False, u'没有相应的副本层' layers = layers[0]['layers'] if layers: energy -= 10 if energy < 0: return False, u'活力不足' places = loader.getById('instance_layer', layers, ['place'])['place'].split(';') instanceLayerId = int(places[0]) props = [0, id, location, instanceLayerId, 0] result = dbaccess.insertPlayerInstanceProgressRecord(props) if result: dbaccess.updatePlayerInfo(id, {'energy':energy, 'enterInstanceCount':1}) self._enterInstanceCount = 1 self.init() else: return False, u'没有相应的副本层' self._owner.attribute.setEnergy(energy) self._owner.baseInfo.setLocation(instanceLayerId) return result, ''
def getExtraAttributeList(self): '''获取物品的附加属性列表''' selfExtraAttribute = self._selfExtrAttributes dropExtraAttribue= self._dropExtraAttributes extraAttributeList = [] if selfExtraAttribute <>"-1": list = eval('['+selfExtraAttribute+']') for i in range( 0, len(list)): attributeInfo = loader.getById('extra_attributes', int(list[i]), '*') attributeInfo['attributeEffects'] = [] if attributeInfo['effects']<>'-1' or attributeInfo['effects']<>u'-1': effects = attributeInfo['effects'].split(';') for effect in effects: effect = int(effect) description = loader.getById('effect', effect, ['description'])['description'] attributeInfo['attributeEffects'].append(description) else: script = attributeInfo['script'] script = util.parseScript(script) attributeInfo['attributeEffects'].append(script) extraAttributeList.append(attributeInfo) # attributeInfo = loader.getById('extra_attributes', int(selfExtraAttribute), '*') # attributeInfo['attributeEffects'] = [] # if attributeInfo['effects']<>'-1' or attributeInfo['effects']<>u'-1': # effects = attributeInfo['effects'].split(';') # for effect in effects: # effect = int(effect) # description = loader.getById('effect', effect, ['description'])['description'] # attributeInfo['attributeEffects'].append(description) # else: # script = attributeInfo['script'] # script = util.parseScript(script) # attributeInfo['attributeEffects'].append(script) # extraAttributeList.append(attributeInfo) elif dropExtraAttribue<>"-1": list = eval('['+dropExtraAttribue+']') for i in range( 0, len(list)): attributeInfo = loader.getById('extra_attributes', int(list[i]), '*') attributeInfo['attributeEffects'] = [] if attributeInfo['effects']<>'-1' or attributeInfo['effects']<>u'-1': effects = attributeInfo['effects'].split(';') for effect in effects: effect = int(effect) description = loader.getById('effect', effect, ['description'])['description'] attributeInfo['attributeEffects'].append(description) else: script = attributeInfo['script'] script = util.parseScript(script) attributeInfo['attributeEffects'].append(script) extraAttributeList.append(attributeInfo) return extraAttributeList
def getCharacterExtraAttributes(characterId, keyName): '''得到玩家装备栏中物品附加属性列表''' extraAttributeList = [] items = [] item = None equipmentIds = dbaccess.getDetailsInEquipmentSlot(characterId) for idx in range(0, len(equipmentIds)): if idx == 0 or idx == 1: continue if equipmentIds[idx] <> -1: item = dbaccess.getSelfAndDropExtraAttr(equipmentIds[idx]) items.append(item) if (len(items) > 0): for elm in items: if (elm[0] == '-1' and elm[1] == '-1'): #no extraAttribute continue if (elm[0] != u'-1'): #only one extraAttribute extraAtrributes = elm[0].split(",") for exAttributeId in extraAtrributes: if (exAttributeId == ""): continue extraAtrribute = loader.getById('extra_attributes', exAttributeId, '*') if (extraAtrribute): extraList = extraAtrribute['script'].split(";") for list in extraList: if list.find(keyName) <> -1: elments = list.split('=') index = elments[1].find(';') value = str(elments[1]).strip() extraAttributeList.append(float(value)) if (elm[1] != u'-1'): #several extraAttributes extraAtrributes = elm[1].split(",") for exAttributeId in extraAtrributes: if (exAttributeId == ""): continue extraAtrribute = loader.getById('extra_attributes', exAttributeId, '*') if (extraAtrribute): extraList = extraAtrribute['script'].split(";") for list in extraList: if list.find(keyName) <> -1: elments = list.split('=') index = elments[1].find(';') value = str(elments[1]).strip() extraAttributeList.append(float(value)) return extraAttributeList
def learnSkill(self, skillId): '''学习技能''' id = self._owner.baseInfo.id skill = loader.getById('skill', skillId, '*') canLearn, reason = self.checkLearnSkillRequire(skill, True) if not canLearn: return False, reason skill = loader.getById('skill', skillId, '*') skills = dbaccess.getLearnedSkills(id) flag = False targetId = 0 for elm in skills: info = loader.getById('skill', elm[2], ['groupType']) if info['groupType'] == skill['groupType']: flag = True targetId = elm[0] break if flag: dbaccess.updateSkillLevelForLearnSkill(targetId, { 'skillId': skillId, 'skillLevel': skill['level'] }) else: dbaccess.insertForLearnSkill([0, id, skillId, skill['level']]) if skill['type'] == 3: #被动技能习得即装备,就直接获得隐式效果 string = '' for i in range(0, len(self._passiveSkills)): if i == 0: string += str(self._passiveSkills[i]) else: string += ';' + str(self._passiveSkills[i]) dbaccess.updatePlayerInfo(id, {'passiveSkills': string}) addEffectIds = skill['addEffect'].split(';') addEffectRates = skill['addEffectRate'].split(';') for i in range(0, len(addEffectIds)): if i == 0: if int(addEffectIds[i]) == -1: return effect = loader.getById('effect', int(addEffectIds[i]), '*') if effect: r = random.randint(0, 100000) if 0 <= r < int(addEffectRates[i]): self._owner.effect.triggerEffect(effect, 2) self.getLearnedSkills() self._owner.refreshInfectionOfSkill() return True, ''
def doWhenPracticeFinsihed(self, attrs): '''当修炼结束时''' id = self._owner.baseInfo.id practiceRecord = dbaccess.getPlayerPracticeRecord(id) monsterId = practiceRecord[2] countHit = practiceRecord[3] finishTime = practiceRecord[5] now = datetime.datetime.now() if not finishTime or (finishTime - now).seconds < 0: return self._owner.level.setExp(attrs['exp']) if not self._owner.level.updateLevel(): dbaccess.updatePlayerInfo(id, attrs) self._owner.baseInfo.setStatus(1) npc = loader.getById('npc', monsterId, '*') if npc: # item = None for i in range(0, countHit): self._owner.quest.onSuccessKillOneMonster(monsterId) self.placePracticeItems(countHit, npc) pushMessage(str(id), 'finish')
def getProfessionAllSkills(self): '''获取玩家当前职业的所有技能''' allSkills = [] profession = self._owner.profession.getProfession() skills = loader.get('skill', 'skillProfession', profession, '*') for skill in skills: skill['addEffectNames'] = [] group = skill["groupType"] learened = group in self.learned_skillpool display = (not learened and skill["level"] == 1) or \ (learened and skill["level"] == self.learned_skillpool[group]["skillLevel"] + 1) or \ (learened and skill["maxLevel"] == skill["level"] and skill["maxLevel"] == \ self.learned_skillpool[group]["skillLevel"]) if display: effects = [] splitEffects = skill["addEffect"].split(';') if (len(splitEffects) > 0 and int(splitEffects[0]) != -1): for i in range(0, len(splitEffects)): effectInfo = loader.getById('effect', int(splitEffects[i]), ['name', 'description']) effects.append(effectInfo['description']) skill['addEffectNames'].append(effectInfo['name']) allSkills.append({ 'skillInfo': skill, 'skillLevel': skill['level'], 'effects': effects }) return allSkills
def canEquipItem(self, itemId, toPosition): '''能否装备物品''' level = self._owner.level.getLevel() templateId = dbaccess.getItemTemplate(itemId) info = loader.getById('item_template', templateId, ['bodyType', 'levelRequire', 'strRequire', 'dexRequire', 'vitRequire']) bodyType = info['bodyType'] levelRequire = info['levelRequire'] strRequire = info['strRequire'] dexRequire = info['dexRequire'] vitRequire = info['vitRequire'] str = self._owner.attribute.getBaseStr() + self._owner.attribute.getManualStr() dex = self._owner.attribute.getBaseDex() + self._owner.attribute.getManualDex() vit = self._owner.attribute.getBaseVit() + self._owner.attribute.getManualVit() if bodyType == -1: return False, u'该物品不能装备' elif bodyType <> toPosition + 1: if toPosition == -1: pass else: return False, u'该位置不能装备' if level < levelRequire: return False, u'您当前的级别不够' if str < strRequire: return False, u'您当前的武勇不够' if vit < vitRequire: return False, u'您当前的体魄不够' if dex < dexRequire: return False, u'您当前的机警不够' return True, bodyType
def wrapSingleItemInfo(self, itemComponent, info): ''' 封装单个物品的详细信息 @param itemComponent: 物品组件对象 ''' if not itemComponent: return None itemTemplateInfo = itemComponent.baseInfo.getItemTemplate() info['itemLevel'] = itemComponent.baseInfo.getItemLevel() info['itemId'] = itemComponent.baseInfo.id info['bindType'] = itemComponent.binding.getBindTypeName() info['isBound'] = itemComponent.binding.getBound() info['isBoundDesc'] = itemComponent.binding.getCurrentBoundStatus() info['sellPrice'] = itemComponent.finance.getPrice() # info['extraAttributeList'] = []#{'name':'','value':''} info['extraAttributeList'] = itemComponent.attribute.getExtraAttributeList() # info['effect'] = itemComponent.effect.getItemEffect() info['name'] = itemComponent.baseInfo.getName() info['from'] = "Character" info['itemTemplateInfo'] = itemTemplateInfo professionRequire = info['itemTemplateInfo']['professionRequire'] if info['itemTemplateInfo']['type'] < 1000000: if info['itemTemplateInfo']['type'] < 10: maxDamage = info['itemTemplateInfo']['maxDamage'] * 0.03 * (itemComponent.baseInfo.getItemLevel() - 1) minDamage = info['itemTemplateInfo']['minDamage'] * 0.03 * (itemComponent.baseInfo.getItemLevel() - 1) info['itemTemplateInfo']['maxDamage'] += int(maxDamage) info['itemTemplateInfo']['minDamage'] += int(minDamage) if professionRequire > 0: info['professionRequireName'] = loader.getById('profession', professionRequire, ['name'])['name'] else: info['professionRequireName'] = u'无职业需求' return info
def isSatifyProgressingQuestGoals(self, questTemplateId): ''' 是否满足任务达成条件 ''' characterId = self._owner.baseInfo.id questId = dbaccess.getQuestByTemplateId(characterId, questTemplateId)[0] questGoalProgresses = dbaccess.getQuestGoalProgressesForQuest(questId) for progress in questGoalProgresses: goal = loader.getById('questgoal', progress[2], '*') #'''杀怪''' if goal['killCount'] > 0: if goal["killCount"] > progress[3]: return False if goal['itemCount'] > 0: count = dbaccess.getCollectionQuestItemCount(goal['itemId'], characterId) if goal["itemCount"] > count: return False # if goal["itemCount"] > progress[4]: # return False #'''收集''' if goal['killCount'] == 0 and goal['itemCount'] == 0: #'''对话''' if progress[5] == 0: return False return True
def checkTypeOfItemToEquip(self, itemId, equipPosition): '''检查要装备物品的类型,是否在该部位能装备''' templateId = dbaccess.getItemTemplate(itemId) bodyType = loader.getById('item_template', templateId, ['bodyType'])['bodyType'] type = 0 if equipPosition == u'header': type = self.HEADER elif equipPosition == u'body': type = self.BODY elif equipPosition == u'belt': type = self.BELT elif equipPosition == u'trousers': type = self.TROUSERS elif equipPosition == u'shoes': type = self.SHOES elif equipPosition == u'bracer': type = self.BRACER elif equipPosition == u'cloak': type = self.CLOAK elif equipPosition == u'necklace': type = self.NECKLACE elif equipPosition == u'waist': type = self.WAIST elif equipPosition == u'weapon': type = self.WEAPON if type == bodyType: return True else: return False
def getSingleMonsterPracticeExp(self, monsterId): id = self._owner.baseInfo.id monsterInfo = loader.getById('npc', monsterId, ['monsterGroupId', 'levelGroup']) if not monsterInfo: return False, u'没有找到怪物' levelList = list(monsterInfo['levelGroup'].split(';')) groupId = monsterInfo['monsterGroupId'] import random tempList = [] for level in levelList: level = int(level) tempList.append(level) #r = random.randint(0, len(tempList) - 1) caughtLevel = tempList[0] cursor = connection.cursor() cursor.execute( "select expBonus from `monster_instance` where level=%d and groupId=%d" % (caughtLevel, groupId)) monsterInstance = cursor.fetchone() cursor.close() if not monsterInstance: return False, u'没有找到怪物' expBonus = monsterInstance['expBonus'] return True, expBonus, caughtLevel
def putOneItemIntoTempPackage(self, item, stack = 1): ''' 放置一个物品到临时包裹栏中 @param item: 物品 ''' self.setTempPackage() self.setPackage() if item: ret = self._tempPackage.isTempPackageFull() if not ret[0]: position = ret[1] position = str(position[0]) + "," + str(position[1]) dbaccess.insertRecordInTempPackage([0, self._owner.baseInfo.id, item[0], position, stack]) self.setTempPackage() else:#如果临时包裹栏已满,算成铜币,加到玩家身上 itemTemplateId = item[2] itemTemplateInfo = loader.getById('item_template', itemTemplateId, '*') if not itemTemplateInfo: return itemName = itemTemplateInfo['name'] itemComponent = Item(item[0], itemName) itemComponent.baseInfo.setItemTemplate(itemTemplateInfo) price = itemComponent.finance.getPrice() dbaccess.deleteItem(item[0], int(self._owner.baseInfo.id)) dbaccess.updatePlayerInfo(self._owner.baseInfo.id, {'coin':self._owner.finance.getCoin() + price}) self._owner.finance.setCoin(self._owner.finance.getCoin() + price)
def getLearnableSkills(self): '''获取玩家可学技能信息''' learnableSkillsInfo = [] profession = self._owner.profession.getProfession() skills = loader.get('skill', 'skillProfession', profession, '*') for skill in skills: skill['addEffectNames'] = [] effects = [] canLearn = self.checkLearnSkillRequire(skill, False)[0] if canLearn: group = skill["groupType"] learened = group in self.learned_skillpool canLearn = (not learened and skill["level"] == 1) or \ (learened and skill["level"] == self.learned_skillpool[group]["skillLevel"] + 1) if canLearn: for effectId in skill['addEffect'].split(';'): if int(effectId) <> -1: effectInfo = loader.getById( 'effect', int(effectId), ['name', 'description']) effects.append(effectInfo['description']) skill['addEffectNames'].append(effectInfo['name']) learnableSkillsInfo.append({ 'skillInfo': skill, 'skillLevel': skill['level'], 'effects': effects }) return learnableSkillsInfo
def sellPackageItem(self, itemId, packageType, count): '''卖出包裹蓝中的物品''' id = self._owner.baseInfo.id itemRecord = dbaccess.getItemInfo(itemId) if not itemRecord: return {'result':False, 'reason':u'此物品不存在'} itemTemplateInfo = loader.getById('item_template', itemRecord[2], '*') item = Item(itemId, itemTemplateInfo['name']) item.baseInfo.setItemTemplate(itemTemplateInfo) item.attribute.setSelfExtraAttribute(itemRecord[3]) item.attribute.setDropExtraAttributes(itemRecord[4]) trade = itemTemplateInfo['trade'] bodyType = self.traverseBodyType(itemTemplateInfo['bodyType'] - 1) idInPackage = dbaccess.getIdFromPackagesByItemId(id, itemId, itemRecord[2], bodyType, packageType) if trade >= 4: return {'result':False, 'reason':u'物品不能出售'} else: price = item.finance.getPrice() price *= count coin = self._owner.finance.getCoin() + price self._owner.finance.setCoin(coin) dbaccess.deletePackageItem(idInPackage, itemId, packageType, bodyType, id) dbaccess.updatePlayerInfo(id, {'coin':coin}) self.refreshPackageByType(packageType) result = {'result':True, 'data':{'idInPackage':idInPackage, 'coin':coin}} if packageType == 'equipment_slot': result['data']['isEquipmentSlot'] = True else: result['data']['isEquipmentSlot'] = False return result
def getProfessionAllSkills(self): '''获取玩家当前职业的所有技能''' allSkills = [] profession = self._owner.profession.getProfession() skills = loader.get('skill', 'skillProfession', profession, '*') for skill in skills: skill['addEffectNames'] = [] group = skill["groupType"] learened = group in self.learned_skillpool; display = (not learened and skill["level"] == 1) or \ (learened and skill["level"] == self.learned_skillpool[group]["skillLevel"] + 1) or \ (learened and skill["maxLevel"] == skill["level"] and skill["maxLevel"] == \ self.learned_skillpool[group]["skillLevel"]) if display: effects = [] splitEffects = skill["addEffect"].split(';') if (len(splitEffects) > 0 and int(splitEffects[0]) != -1): for i in range(0, len(splitEffects)): effectInfo = loader.getById('effect', int(splitEffects[i]), ['name', 'description']) effects.append(effectInfo['description']) skill['addEffectNames'].append(effectInfo['name']) allSkills.append({'skillInfo':skill, 'skillLevel':skill['level'], 'effects':effects}) return allSkills
def _finishActiveRewardQuest(self, templateId): '''在赏金组织内提交完成赏金任务''' id = self._owner.baseInfo.id questRecord = dbaccess.getQuestByTemplateId(id, templateId) if not questRecord: return questId = questRecord[0] dbaccess.operateForCommitQuest(questId,id) dbaccess.updateTempActiveRewardQuestByQuestTemplateId(templateId, id, {'isFinish':1, 'isLock':0}) pushMessage(str(self._owner.baseInfo.id), 'questFinish'); questBonus = loader.getById('quest_template', templateId, ['coinBonus', 'expBonus']) coin = self._owner.finance.getCoin() + questBonus['coinBonus'] self._owner.finance.setCoin(coin) exp = self._owner.level.getExp() + questBonus['expBonus'] self._owner.level.setExp(exp) self._owner.level.updateLevel() record = dbaccess.getQuestRecordById(questId) if record[6] <> -1: item = dbaccess.getItemInfo(record[6]) self._owner.pack.putOneItemIntoTempPackage(item) pushMessage(str(self._owner.baseInfo.id), 'newTempPackage') self._owner.pack.setTempPackage() self._owner.pack.setPackage() self.setProgressingQuests()
def getCharacterExtraAttributes(characterId, keyName): '''得到玩家装备栏中物品附加属性列表''' extraAttributeList = [] items = [] item = None equipmentIds = dbaccess.getDetailsInEquipmentSlot(characterId) for idx in range(0, len(equipmentIds)): if idx == 0 or idx == 1: continue if equipmentIds[idx] <> -1: item = dbaccess.getSelfAndDropExtraAttr(equipmentIds[idx]) items.append(item) if(len(items) > 0): for elm in items: if(elm[0] == '-1' and elm[1] == '-1'): #no extraAttribute continue if(elm[0] != u'-1'): #only one extraAttribute extraAtrributes = elm[0].split(",") for exAttributeId in extraAtrributes: if(exAttributeId == ""): continue extraAtrribute = loader.getById('extra_attributes', exAttributeId, '*') if(extraAtrribute): extraList = extraAtrribute['script'].split(";") for list in extraList: if list.find(keyName) <> -1: elments = list.split('=') index = elments[1].find(';') value = str(elments[1]).strip() extraAttributeList.append(float(value)) if(elm[1] != u'-1'): #several extraAttributes extraAtrributes = elm[1].split(",") for exAttributeId in extraAtrributes: if(exAttributeId == ""): continue extraAtrribute = loader.getById('extra_attributes', exAttributeId, '*') if(extraAtrribute): extraList = extraAtrribute['script'].split(";") for list in extraList: if list.find(keyName) <> -1: elments = list.split('=') index = elments[1].find(';') value = str(elments[1]).strip() extraAttributeList.append(float(value)) return extraAttributeList
def useItem(self, itemId): '''使用物品''' id = self._owner.baseInfo.id level = self._owner.level.getLevel() itemRecord = dbaccess.getItemInfo(itemId) if not itemRecord: return {'result':False, 'reason':u'此物品不存在'} itemTemplateInfo = loader.getById('item_template', itemRecord[2], '*') item = Item(itemId, itemTemplateInfo['name']) item.baseInfo.setItemTemplate(itemTemplateInfo) if level < itemTemplateInfo['levelRequire']: return {'result':False, 'reason':u'您的等级不够,无法使用'} effects = itemTemplateInfo['addEffect'].split(';') if effects[0] == u'-1': return {'result':False, 'reason':u'物品没有任何效果'} for effectId in effects: effectId = int(effectId) effect = loader.getById('effect', effectId, '*') if not effect: return {'result':False, 'reason':u'无效果'} if effect['type'] == 1:#即时效果,立即使用,立即变更数值 hp, mp = self._owner.effect.calcImmeEffectForPlayer(effect) result = {'result':True, 'data':[u'瞬时效果', hp, mp]} elif effect['type'] == 2:#持续效果,写入状态表 ret, reason = self._owner.effect.triggerEffect(effect, 1) if not ret : result = {'result':ret, 'reason':reason} result = {'result':ret, 'data':[u'持久效果', self._owner.effect.getItemEffectsInfo()]} elif effect['type'] == 3: pass #删除物品记录/修改物品记录 packageRecord = dbaccess.getItemInPackageByItemId(id, itemId) if packageRecord[4] > 1: stack = packageRecord[4] - 1 dbaccess.updateRecordInPackage(packageRecord[0], {'stack':stack}) result['count'] = stack else: dbaccess.deleteRecordInPackage(packageRecord[0], itemId) result['count'] = 0 result['idInPackage'] = packageRecord[0] self.refreshPackageByType('package') return result
def getMaxHp(self, professionId, characterId, characterLevel): ''' 计算当前最大HP 体力=(基础体力+(等级)*每级成长值)*(1+附加体力%)*(1+体质*0.01)+附加体力值)*(1+装备升级时附加体力%) ''' percentMaxHp = 0.0 skillMaxHp = 0.0 self._professionId = professionId self._characterLevel = characterLevel valuse = self._owner.pack.getEquipmentSlot() data = loader.getById('profession', self._professionId, '*') basehp = data["baseHp"] perlevelhp = data["perLevelHp"] basevit = data["baseVit"] perlevelvit = data["perLevelVit"] extraVit = self.getExtraVit() level = self._characterLevel maxHp = (basehp + (level) * perlevelhp) * (1 + self.getCurrentVit( self._manualVit, level, basevit, perlevelvit, extraVit) * 0.01) maxHpList = getCharacterExtraAttributes(self._owner.baseInfo.id, "maxHp") maxHpPercentList = getCharacterExtraAttributes(self._owner.baseInfo.id, "maxHPercent") listLen = len(maxHpPercentList) #加体力% for i in range(0, listLen): percentMaxHp += maxHpPercentList[i] - 1 percentMaxHp += 1 maxHp *= percentMaxHp listLen = len(maxHpList) #加体力值 for i in range(0, listLen): offsetMaxHp = maxHpList[i] maxHp += offsetMaxHp maxHp = int(maxHp * valuse) + int(maxHp) skillMaxHpList = self.getPassiveSkillsEffects(self._owner.baseInfo.id, 'maxHp', '+') listLen = len(skillMaxHpList) #技能加体力 for i in range(0, listLen): offsetMaxHp = skillMaxHpList[i] maxHp += offsetMaxHp skillMaxHpList = self.getPassiveSkillsEffects(self._owner.baseInfo.id, 'maxHp', '*') listLen = len(skillMaxHpList) #技能加体力% for i in range(0, listLen): skillMaxHp += skillMaxHpList[i] - 1 skillMaxHp += 1 maxHp = int(maxHp * skillMaxHp) if self._hp > int(maxHp): dbaccess.updatePlayerInfo(characterId, {'hp': self._hp}) self._hp = int(maxHp) return int(maxHp)
def getMapPlaceInfo(placeId): '''获取区域地图详细信息;list中第一项为区域信息,后面的均为其子地点''' placeInfo = loader.getById('place', placeId, '*') if not placeInfo: return regionsList = [] regionId = placeInfo['regionId'] if regionId <> -1: regionInfo = loader.getById('place', regionId, '*') regionsList.append(regionInfo) else: regionId = placeInfo['id'] places = loader.get('place', 'regionId', regionId, '*') for place in places: if place['type'] == u'地点': regionsList.append(place) return regionsList
def learnSkill(self, skillId): '''学习技能''' id = self._owner.baseInfo.id skill = loader.getById('skill', skillId, '*') canLearn, reason = self.checkLearnSkillRequire(skill, True) if not canLearn: return False, reason skill = loader.getById('skill', skillId, '*') skills = dbaccess.getLearnedSkills(id) flag = False targetId = 0 for elm in skills: info = loader.getById('skill', elm[2], ['groupType']) if info['groupType'] == skill['groupType']: flag = True targetId = elm[0] break if flag: dbaccess.updateSkillLevelForLearnSkill(targetId, {'skillId':skillId, 'skillLevel':skill['level']}) else: dbaccess.insertForLearnSkill([0, id, skillId, skill['level']]) if skill['type'] == 3:#被动技能习得即装备,就直接获得隐式效果 string = '' for i in range(0, len(self._passiveSkills)): if i == 0: string += str(self._passiveSkills[i]) else: string += ';' + str(self._passiveSkills[i]) dbaccess.updatePlayerInfo(id, {'passiveSkills':string}) addEffectIds = skill['addEffect'].split(';') addEffectRates = skill['addEffectRate'].split(';') for i in range(0, len(addEffectIds)): if i == 0: if int(addEffectIds[i]) == -1: return effect = loader.getById('effect', int(addEffectIds[i]), '*') if effect: r = random.randint(0, 100000) if 0 <= r < int(addEffectRates[i]): self._owner.effect.triggerEffect(effect, 2) self.getLearnedSkills() self._owner.refreshInfectionOfSkill() return True, ''
def getWeaponName(self): '''获取装备的武器的名字''' weaponTemplateId = self.getWeaponTemplateId() if weaponTemplateId == -1: return u'没有装备武器' itemName = loader.getById('item_template', weaponTemplateId, ['name'])['name'] assert(itemName) return itemName
def init(self): id = self._owner.baseInfo.id record = dbaccess.getPlayerInstanceProgressRecord(id) if record: if record[2] != 0: self._instanceId = record[2] instanceInfo = loader.get('instance', 'entryPlace', record[2], ['layers'])[0] self._instanceName = loader.getById('place', record[2], ['name'])['name'] self._instancePlaceId = record[3] self._instancePlaceName = loader.getById('place', record[3], ['name'])['name'] if record[4] == 0: self._isInstanceLocked = False else: self._isInstanceLocked = True places = loader.getById('instance_layer', instanceInfo['layers'], ['place'])['place'].split(';') for elm in places: elm = int(elm) self._instanceLayers.append(elm)
def __init__(self, owner): ''' Constructor ''' Component.__init__(self, owner) self._profession = 1 #职业 self._professionStage = 0 #职业阶段 self._professionPosition = 0 #职位 self.info = loader.getById('profession', self._profession, '*') # 从数据表中读出的该职业的配置信息
def getCampName(self): camp = self._camp if camp == -1: return "中立" result = loader.getById('camp', camp, ['name'])['name'] if result: return result else: return ""
def getExtraAttributeValue(self,extraAttributeId): '''得到每个附加属性的价值''' eAttribute = loader.getById('extra_attributes', extraAttributeId, ['level']) cursor = connection.cursor() cursor.execute("select price from exattribute_level where level=%d"%eAttribute['level']) value = cursor.fetchone() cursor.close() return int(value['price'])
def getShopNpcInfo(self, placeId): '''获取商店npc信息''' shopNpcInfo = loader.get('shop', 'type', placeId, ['description']) shopNpcInfo = shopNpcInfo[0] npcId = loader.get('place_npc', 'placeId', placeId, ['npcId'])[0]['npcId'] npcImage = loader.getById('npc', npcId, ['image'])['image'] shopNpcInfo['image'] = npcImage shopNpcInfo['id'] = npcId return shopNpcInfo
def getMaxHp(self, professionId, characterId, characterLevel): ''' 计算当前最大HP 体力=(基础体力+(等级)*每级成长值)*(1+附加体力%)*(1+体质*0.01)+附加体力值)*(1+装备升级时附加体力%) ''' percentMaxHp = 0.0 skillMaxHp = 0.0 self._professionId = professionId self._characterLevel = characterLevel valuse = self._owner.pack.getEquipmentSlot() data = loader.getById('profession', self._professionId, '*') basehp = data["baseHp"] perlevelhp = data["perLevelHp"] basevit = data["baseVit"] perlevelvit = data["perLevelVit"] extraVit = self.getExtraVit() level = self._characterLevel maxHp = (basehp + (level) * perlevelhp) * (1 + self.getCurrentVit(self._manualVit, level, basevit, perlevelvit, extraVit) * 0.01) maxHpList = getCharacterExtraAttributes(self._owner.baseInfo.id, "maxHp") maxHpPercentList = getCharacterExtraAttributes(self._owner.baseInfo.id, "maxHPercent") listLen = len(maxHpPercentList) #加体力% for i in range(0, listLen): percentMaxHp += maxHpPercentList[i] - 1 percentMaxHp += 1 maxHp *= percentMaxHp listLen = len(maxHpList) #加体力值 for i in range(0, listLen): offsetMaxHp = maxHpList[i] maxHp += offsetMaxHp maxHp = int(maxHp * valuse) + int(maxHp) skillMaxHpList = self.getPassiveSkillsEffects(self._owner.baseInfo.id, 'maxHp', '+') listLen = len(skillMaxHpList) #技能加体力 for i in range(0, listLen): offsetMaxHp = skillMaxHpList[i] maxHp += offsetMaxHp skillMaxHpList = self.getPassiveSkillsEffects(self._owner.baseInfo.id, 'maxHp', '*') listLen = len(skillMaxHpList) #技能加体力% for i in range(0, listLen): skillMaxHp += skillMaxHpList[i] - 1 skillMaxHp += 1 maxHp = int(maxHp * skillMaxHp) if self._hp > int(maxHp): dbaccess.updatePlayerInfo(characterId, {'hp':self._hp}) self._hp = int(maxHp) return int(maxHp)
def getShopItemPrice(self, itemTemplateId, extraAttribute): '''获取商店物品的购买价格''' sellPrice = loader.getById('item_template', itemTemplateId, ['buyingRateCoin'])['buyingRateCoin'] extraAttributes = eval('[' + extraAttribute + ']') for extraAttrId in extraAttributes: extraAttrId = int(extraAttrId) isValidExtraAttrID = loader.getById('extra_attributes', extraAttrId, ['id']) if ((extraAttrId != -1) and isValidExtraAttrID): eAttribute = loader.getById('extra_attributes', extraAttrId, ['level']) cursor = connection.cursor() cursor.execute( "select price from exattribute_level where level=%d" % eAttribute['level']) value = cursor.fetchone() cursor.close() sellPrice += int(value['price']) return sellPrice
def getRewardQuestCountForToday(self): '''获取今天已接赏金任务数量''' id = self._owner.baseInfo.id count = 0 questRecordList = dbaccess.getQuestRecordOfToday(id) for record in questRecordList: type = loader.getById('quest_template', record[1], ['type'])['type'] if type == 2: count += 1 return count
def getQuestItemBouns(self, itemId): '''任务奖励物品''' itemInfo = dbaccess.getItemInfo(itemId) itemTemplateInfo = loader.getById('item_template', itemInfo[2], '*') item = Item(itemInfo[0], itemTemplateInfo['name']) item.baseInfo.setItemTemplate(itemTemplateInfo) item.baseInfo.setItemLevel(int(itemInfo[6])) item.binding.setType(itemTemplateInfo['bind']) item.binding.setBound(int(itemInfo[5])) item.attribute.setSelfExtraAttribute(itemInfo[3]) item.attribute.setDropExtraAttributes(itemInfo[4]) itemTemplateInfo = item.baseInfo.getItemTemplate() info = {} info['itemLevel'] = item.baseInfo.getItemLevel() info['itemId'] = item.baseInfo.id info['bindType'] = item.binding.getBindTypeName() info['isBound'] = item.binding.getBound() info['isBoundDesc'] = item.binding.getCurrentBoundStatus() info['sellPrice'] = item.finance.getPrice() # info['extraAttributeList'] = []#{'name':'','value':''} info['extraAttributeList'] = item.attribute.getExtraAttributeList() # info['effect'] = itemComponent.effect.getItemEffect() info['name'] = item.baseInfo.getName() info['from'] = "Character" info['itemTemplateInfo'] = itemTemplateInfo professionRequire = info['itemTemplateInfo']['professionRequire'] if info['itemTemplateInfo']['type'] < 1000000: if info['itemTemplateInfo']['type'] < 10: maxDamage = info['itemTemplateInfo']['maxDamage'] * 0.03 * (item.baseInfo.getItemLevel() - 1) minDamage = info['itemTemplateInfo']['minDamage'] * 0.03 * (item.baseInfo.getItemLevel() - 1) info['itemTemplateInfo']['maxDamage'] += int(maxDamage) info['itemTemplateInfo']['minDamage'] += int(minDamage) if professionRequire > 0: info['professionRequireName'] = loader.getById('profession', professionRequire, ['name'])['name'] else: info['professionRequireName'] = u'无职业需求' return info
def onSuccessKillOneMonster(self, monsterId, type = 'battle'): '''当成功杀死怪物,计算任务目标结果''' id = self._owner.baseInfo.id item = None self._owner.pack.setTempPackage() self._owner.pack.setPackage() progressingQuestList = self.getProgressingRecordList() for quest in progressingQuestList: for details in quest['progressesDetails']: if details['npcInfo']['id'] == monsterId: if details['killCount'] > 0:#杀怪 details['currentKillCount'] += 1 if details['currentKillCount'] > details['killCount']: details['currentKillCount'] = details['killCount'] dbaccess.updateQuestgoalProgress(quest['id'], details['questgoalId'], \ {'killMonsterCount':details['currentKillCount']}) if details['itemCount'] > 0:#收集 if type == 'battle': itemTemplateId = loader.getById('questgoal', details['questgoalId'], ['itemId'])['itemId'] if itemTemplateId <> -1: queryResult = dbaccess.getItemInfoByTemplateId(itemTemplateId, id) if queryResult and len(queryResult) > 0:#玩家身上有该物品,为了后面的叠加 item = queryResult[0] packageInfo = dbaccess.getItemInPackageByItemId(id, item[0]) if packageInfo:#物品在包裹栏中 dbaccess.updateItemAttrsInPackages('package', packageInfo[0], {'stack':packageInfo[4] + 1}) self._owner.pack.setPackage() else: packageInfo = dbaccess.getItemInTempPackageByItemId(id, item[0]) if packageInfo: dbaccess.updateItemAttrsInPackages('temporary_package', packageInfo[0], {'stack':packageInfo[4] + 1}) self._owner.pack.setTempPackage() # details['currentCollectCount'] += 1 else: ret = self._owner.pack._tempPackage.isTempPackageFull() if not ret[0]: dbaccess.insertItemRecord([0, id, itemTemplateId, '-1', '-1', 0, 1]) item = dbaccess.getLastInsertItemInfo() if item and len(item) > 0: self._owner.pack.putOneItemIntoTempPackage(item) pushMessage(str(self._owner.baseInfo.id), 'newTempPackage') self._owner.pack.setTempPackage() else: pass # if details['currentCollectCount']>details['itemCount']: # details['currentCollectCount']=details['itemCount'] # dbaccess.updateQuestgoalProgress(quest['id'], details['questgoalId'],\ # {'collectItemCount':details['currentCollectCount']}) self.setProgressingQuests() return item
def getRecievableQuestDetails(self, questTemplateId): '''获取可接任务详细信息''' templateInfo = loader.getById('quest_template', questTemplateId, '*') templateInfo = self.wrapRecievableQuestObject(templateInfo) questgoals = list(loader.get('questgoal', 'questId', questTemplateId, ['id', 'itemId', 'itemCount', 'killCount', 'npc'])) for questgoal in questgoals: if questgoal['itemId'] <> -1: itemName = loader.getById('item_template', questgoal['itemId'], ['name'])['name'] else: itemName = '' if questgoal['npc'] <> -1: npcNameInfo = loader.getById('npc', questgoal['npc'], ['name']) if npcNameInfo: npcName = npcNameInfo['name'] else: npcName = u'无' else: npcName = '' questgoal['itemName'] = itemName npcInfo = {'id':questgoal['npc'], 'name':npcName} questgoal['npcInfo'] = npcInfo npcInfo = self._getQuestNpcInfo(questgoal['npc'], npcInfo) questgoal['parentPlaceList'] = self.getFullPlaceList(npcInfo) if templateInfo['dropConfig'] != -1: result = dbaccess.selectQuestItem(self._owner.baseInfo.id, questTemplateId) if result: itemId = result[0] else: dropItem = self._owner.dropping.getItemByDropping(templateInfo['dropConfig'])[0] if dropItem: itemId = dropItem[0] dbaccess.insertQuestTempItem(self._owner.baseInfo.id, questTemplateId, itemId) templateInfo['itemBonus'] = self.getQuestItemBouns(itemId) templateInfo['questgoals'] = questgoals templateInfo['questType'] = 'receieval' return templateInfo
def refreshInfectionOfSkill(self): return owner = self.getCommonValues() bak1 = owner.copy() delta = owner.copy() learnedSkills = dbaccess.getLearnedSkills(self.baseInfo.id) if not learnedSkills or len(learnedSkills) == 0: return for skill in learnedSkills: skillId = skill[2] skillInfo = loader.getById('skill', skillId, '*') if skillInfo['type'] != 3: continue for effect in skillInfo['addEffect'].split(';'): if int(effect) != -1: effectInfo = loader.getById('effect', int(effect), '*') script = effectInfo['script'] try: exec(script) except Exception as e: print "error", e if bak1 == owner: return None for k in owner.keys(): __typeK = type(owner[k]) if __typeK is int or __typeK is long or __typeK is float: delta[k] = owner[k] - bak1[k] elif __typeK is list: delta[k] = [] elif __typeK is dict: delta[k] = {} elif __typeK is str or __typeK is unicode: delta[k] = '' else: print 'extra Type', __typeK data = dbaccess._queryPlayerInfo(self.baseInfo.id) self.attribute.setManualStr(data[10] + delta['growstr']) self.attribute.setManualVit(data[11] + delta['growvit']) self.attribute.setManualDex(data[12] + delta['growdex']) self.delta = delta
def formatEffectInfo(self, effects): '''格式化效果''' list = [] for effectInstance in effects: info = loader.getById('effect', effectInstance[2], ['timeDuration', 'icon', 'name', 'description']) if info: info['createTime'] = effectInstance[5] info['triggerType'] = effectInstance[6] info['currentTime'] = datetime.datetime.now() times = info['currentTime'] - info['createTime'] info['timeDuration']=info['timeDuration']- times.seconds * 1000 list.append(info) return list
def setEffectsList(self): '''设置效果列表''' newSkillStr = '' newAuxiliarySkills = [] id = self._owner.baseInfo.id auxiliarySkills = self._owner.skill.getAuxiliarySkills() effectInstances = dbaccess.getAllEffectInstances(id) for i in range(0,len(auxiliarySkills)): result = loader.getById('skill', auxiliarySkills[i], '*') effectList = result['addEffect'].split(';') effectCounts = len(effectList) difference = len(effectList) for list in effectList: for instance in effectInstances: effectInfo = loader.getById('effect', instance[2], ['icon', 'disPlayMode']) icon = effectInfo['icon'] effectDisplayMode = effectInfo['disPlayMode'] instance.append(icon) if instance[6] == 1: self._currentEffects.append(instance) elif instance[6] == 2: if effectDisplayMode == 3:#进入隐形状态列表 self._invisibleEffects.append(instance) elif effectDisplayMode == 2: self._skillEffects.append(instance) if list == instance[2]: difference -= 1 if difference != effectCounts: newAuxiliarySkills.append(auxiliarySkills[i]) if newSkillStr == '': newSkillStr += str(auxiliarySkills[i]) else: newSkillStr += ',' + str(auxiliarySkills[i]) self._owner.skill.setAuxiliarySkills(newAuxiliarySkills) dbaccess.updatePlayerInfo(id, {'auxiliarySkills':newSkillStr})
def __init__(self, id, name=None): Character.__init__(self, id, name) # self.attribute = CharacterAttributeComponent(self) # self.battle = CharacterBattleComponent(self) # self.camp = CharacterCampComponent(self) # self.dropping = CharacterDroppingComponent(self) # self.effect = CharacterEffectComponent(self) # self.balloon = CharacterBalloonComponent(self) # self.level = CharacterLevelComponent(self) # self.skill = CharacterSkillComponent(self) data = loader.getById('npc', id, '*') if data: self.initialise(data)