MCPcopy Index your code
hub / github.com/pyfa-org/Pyfa / setLevel

Method setLevel

eos/saveddata/character.py:365–393  ·  view source on GitHub ↗
(self, level, persist=False, ignoreRestrict=False)

Source from the content-addressed store, hash-verified

363 return self.activeLevel or 0
364
365 def setLevel(self, level, persist=False, ignoreRestrict=False):
366
367 if level is not None and (level < 0 or level > 5):
368 raise ValueError(str(level) + " is not a valid value for level")
369
370 if hasattr(self, "_Skill__ro") and self.__ro is True:
371 raise ReadOnlyException()
372
373 self.activeLevel = level
374
375 # todo: have a way to do bulk skill level editing. Currently, everytime a single skill is changed, this runs,
376 # which affects performance. Should have a checkSkillLevels() or something that is more efficient for bulk.
377 if not ignoreRestrict and eos.config.settings['strictSkillLevels']:
378 start = time.time()
379 for item, rlevel in self.item.requiredFor.items():
380 if item.group.category.ID == 16: # Skill category
381 if level is None or level < rlevel:
382 skill = self.character.getSkill(item.ID)
383 # print "Removing skill: {}, Dependant level: {}, Required level: {}".format(skill, level, rlevel)
384 skill.setLevel(None, persist)
385 pyfalog.debug("Strict Skill levels enabled, time to process {}: {}".format(self.item.ID, time.time() - start))
386
387 if persist:
388 self.saveLevel()
389 else:
390 self.character.dirtySkills.add(self)
391
392 if self.activeLevel == self.__level and self in self.character.dirtySkills:
393 self.character.dirtySkills.remove(self)
394
395 @property
396 def item(self):

Callers 2

changeLevelMethod · 0.80
_trainSkillReqsMethod · 0.80

Calls 5

saveLevelMethod · 0.95
itemsMethod · 0.80
getSkillMethod · 0.80
ReadOnlyExceptionClass · 0.70
removeMethod · 0.45

Tested by

no test coverage detected