def getBonuses(self, bonusName=None, isCompensation=False, bonusData=None, ctx=None): result = [] bonusData = bonusData or self._data.get('bonus', {}) if bonusName is None: for name, value in bonusData.iteritems(): for bonus in getBonuses(self, name, value, isCompensation, ctx=ctx): result.append(self._bonusDecorator(bonus)) elif bonusName in bonusData: for bonus in getBonuses(self, bonusName, bonusData[bonusName], isCompensation, ctx=ctx): result.append(self._bonusDecorator(bonus)) return sorted(result, cmp=compareBonuses, key=operator.methodcaller('getName'))
def getBonuses(self, bonusName=None, filterFunc=None, isMain=None, returnAwardList=False, isDelayed=False, ctx=None): if isMain is None: data = (self.__pmType.mainQuestInfo, self.__pmType.addQuestInfo) elif isMain: data = (self.__pmType.mainQuestInfo, ) else: data = (self.__pmType.addQuestInfo, ) if returnAwardList: data = (self.__pmType.addAwardListQuestInfo, ) result = [] for d in data: if isDelayed: bonuses = d.get('bonusDelayed', {}).iteritems() else: bonuses = d.get('bonus', {}).iteritems() for n, v in bonuses: if bonusName is not None and n != bonusName: continue if filterFunc is not None and not filterFunc(n, v): continue result.extend(getBonuses(self, n, v, ctx=ctx)) return sorted(result, cmp=compareBonuses, key=operator.methodcaller('getName'))
def _packAwards(self): result = [] for name, value in self._awards.iteritems(): if name not in self._INVISIBLE_AWARDS: for bonus in getBonuses(self._quest, name, value): result.extend(bonus.getRankedAwardVOs('big')) return result
def __packAwards(self): result = [] formatter = getRankedAwardsFormatter() for name, value in self._awards.iteritems(): result.extend( formatter.getFormattedBonuses(getBonuses( self._quest, name, value), size=AWARDS_SIZES.BIG)) return result
def getBonuses(self, bonusName=None, isCompensation=False, bonusData=None): """ Get quest's bonuses. :param bonusName: str, bonus name to be find :param isCompensation: bool, treat returned bonuses as compensation :param bonusData: dict, formed quest bonus dict section, wrap bonus data for existing bonus dict :return: list with found bonuses """ result = [] bonusData = bonusData or self._data.get('bonus', {}) if bonusName is None: for name, value in bonusData.iteritems(): for bonus in getBonuses(self, name, value, isCompensation): result.append(self._bonusDecorator(bonus)) elif bonusName in bonusData: for bonus in getBonuses(self, bonusName, bonusData[bonusName], isCompensation): result.append(self._bonusDecorator(bonus)) return sorted(result, cmp=compareBonuses, key=operator.methodcaller('getName'))