def add_starting(merit_id, rank=None): """add a merit advancement to starting school rank""" first_rank_ = api.character.rankadv.get_first() if not first_rank_: return False merit_ = api.data.merits.get(merit_id) if not merit_: return False if not rank: rank = 1 merit_rank_ = api.data.merits.get_rank(merit_id, rank) if not merit_rank_: return False cost_ = 0 adv_ = models.PerkAdv(merit_id, merit_rank_.id, cost_, "merit") adv_.rule = merit_id adv_.desc = unicode.format(__api.tr("{0} Rank {1}, XP Cost: {2}"), merit_.name, merit_rank_.id, cost_) first_rank_.merits.append(adv_) return True
def get_requirements(sid): """returns the requirements to join the given school""" school_ = get(sid) if not school_: log.api.error(u"school not found: %s", sid) return [] requirements_by_data_ = school_.require # fixme. since i can't rewrite all alternate path # I decided to patch these requirement by code import api.character.schools from dal.requirements import Requirement coded_requirements_ = [] if is_path(sid): # An alternate path can only be joined # on the same school rank that its technique replaces path_rank_ = query(school_.techs).select(a_('rank')).first_or_default(0) if path_rank_ > 0: r = Requirement() r.field = api.character.schools.get_current() r.type = 'school' r.min = path_rank_ - 1 r.max = path_rank_ - 1 r.trg = None r.text = __api.tr("Replaces School Rank: {0}").format(path_rank_) coded_requirements_.append(r) return requirements_by_data_ + coded_requirements_
def add_starting(flaw_id, rank=None): """add a flaw advancement to starting school rank""" first_rank_ = api.character.rankadv.get_first() if not first_rank_: return False flaw_ = api.data.flaws.get(flaw_id) if not flaw_: return False if not rank: rank = 1 flaw_rank_ = api.data.flaws.get_rank(flaw_id, rank) if not flaw_rank_: return False gain_ = 0 adv_ = models.PerkAdv(flaw_id, flaw_rank_.id, -gain_, "flaw") adv_.rule = flaw_id adv_.desc = unicode.format(__api.tr("{0} Rank {1}, XP Gain: {2}"), flaw_.name, flaw_rank_.id, gain_) first_rank_.flaws.append(adv_) return True
def add(merit_id, rank=None): """add a merit advancement""" merit_ = api.data.merits.get(merit_id) if not merit_: return if not rank: rank = 1 merit_rank_ = api.data.merits.get_rank(merit_id, rank) if not merit_rank_: return cost_ = api.data.merits.get_rank_cost(merit_id, rank) adv_ = models.PerkAdv(merit_id, merit_rank_.id, cost_, "merit") adv_.rule = merit_id adv_.desc = unicode.format(__api.tr("{0} Rank {1}, XP Cost: {2}"), merit_.name, merit_rank_.id, cost_) return api.character.purchase_advancement(adv_)
def add(flaw_id, rank=None): """add a flaw advancement""" flaw_ = api.data.flaws.get(flaw_id) if not flaw_: return False if not rank: rank = 1 flaw_rank_ = api.data.flaws.get_rank(flaw_id, rank) if not flaw_rank_: return False gain_ = api.data.flaws.get_rank_gain(flaw_id, rank) adv_ = models.PerkAdv(flaw_id, flaw_rank_.id, -gain_, "flaw") adv_.rule = flaw_id adv_.desc = unicode.format(__api.tr("{0} Rank {1}, XP Gain: {2}"), flaw_.name, flaw_rank_.id, gain_) api.character.append_advancement(adv_) return True
def get_requirements(sid): """returns the requirements to join the given school""" school_ = get(sid) if not school_: log.api.error(u"school not found: %s", sid) return [] requirements_by_data_ = school_.require # fixme. since i can't rewrite all alternate path # I decided to patch these requirement by code import api.character.schools from dal.requirements import Requirement coded_requirements_ = [] if is_path(sid): # An alternate path can only be joined # on the same school rank that its technique replaces path_rank_ = query(school_.techs).select( a_('rank')).first_or_default(0) if path_rank_ > 0: r = Requirement() r.field = api.character.schools.get_current() r.type = 'school' r.min = path_rank_ - 1 r.max = path_rank_ - 1 r.trg = None r.text = __api.tr("Replaces School Rank: {0}").format(path_rank_) coded_requirements_.append(r) return requirements_by_data_ + coded_requirements_