def getAchievements(self, isInDossier=True): result = [] for section in dossiers_utils.getAchievementsLayout(self.dossierType): sectionAchieves = [] for achieveName in section: if not dossiers_utils.isAchieveValid(achieveName, self): continue try: factory = getAchievementFactory(achieveName, self) if isInDossier is None or factory.isInDossier( ) and isInDossier or not factory.isInDossier( ) and not isInDossier: if isinstance(factory, _SequenceAchieveFactory): sectionAchieves.extend( factory.create(self.proxy).values()) else: sectionAchieves.append(factory.create(self.proxy)) except Exception: LOG_ERROR('There is exception while achievement creating', achieveName) LOG_CURRENT_EXCEPTION() continue result.append(tuple(sorted(sectionAchieves))) return tuple(result)
def getNearestAchievements(self): achievements = map(lambda x: self.getAchievement(x), _NEAREST_ACHIEVEMENTS) uncompletedAchievements = itertools.ifilter(lambda x: not x.isDone and dossiers_utils.isAchieveValid(x.name, self) and x.isInNear, achievements) def nearestComparator(x, y): if x.lvlUpValue == 1 or y.lvlUpValue == 1: if x.lvlUpValue == y.lvlUpValue: return cmp(x.progress, y.progress) elif x.lvlUpValue == 1: return 1 else: return -1 else: return cmp(x.progress, y.progress) result = sorted(uncompletedAchievements, cmp=nearestComparator, reverse=True)[:_NEAREST_ACHIEVEMENTS_COUNT] return tuple(result)
def getNearestAchievements(self): achievements = map(lambda x: self.getAchievement(x), _NEAREST_ACHIEVEMENTS) uncompletedAchievements = itertools.ifilter( lambda x: not x.isDone and dossiers_utils.isAchieveValid( x.name, self) and x.isInNear, achievements) def nearestComparator(x, y): if x.lvlUpValue == 1 or y.lvlUpValue == 1: if x.lvlUpValue == y.lvlUpValue: return cmp(x.progress, y.progress) elif x.lvlUpValue == 1: return 1 else: return -1 else: return cmp(x.progress, y.progress) result = sorted(uncompletedAchievements, cmp=nearestComparator, reverse=True)[:_NEAREST_ACHIEVEMENTS_COUNT] return tuple(result)
def getAchievements(self, isInDossier = True): result = [] for section in dossiers_utils.getAchievementsLayout(self.dossierType): sectionAchieves = [] for achieveName in section: if not dossiers_utils.isAchieveValid(achieveName, self): continue try: factory = getAchievementFactory(achieveName, self) if isInDossier is None or factory.isInDossier() and isInDossier or not factory.isInDossier() and not isInDossier: if isinstance(factory, _SequenceAchieveFactory): sectionAchieves.extend(factory.create(self.proxy).values()) else: sectionAchieves.append(factory.create(self.proxy)) except Exception: LOG_ERROR('There is exception while achievement creating', achieveName) LOG_CURRENT_EXCEPTION() continue result.append(tuple(sorted(sectionAchieves))) return tuple(result)