Exemplo n.º 1
0
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_ = PerkAdv(flaw_id, flaw_rank_.id, -gain_, "flaw")
    adv_.rule = flaw_id
    adv_.desc = __api.tr("{0} Rank {1}, XP Gain: {2}").format(
                               flaw_.name, flaw_rank_.id, gain_)

    first_rank_.flaws.append(adv_)
    return True
Exemplo n.º 2
0
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 l5r.api.character.schools
    from l5rdal.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_
Exemplo n.º 3
0
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_ = PerkAdv(merit_id, merit_rank_.id, cost_, "merit")
    adv_.rule = merit_id
    adv_.desc = __api.tr("{0} Rank {1}, XP Cost: {2}").format(
        merit_.name, merit_rank_.id, cost_)

    first_rank_.merits.append(adv_)
    return True
Exemplo n.º 4
0
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_ = PerkAdv(merit_id, merit_rank_.id, cost_, "merit")
    adv_.rule = merit_id
    adv_.desc = __api.tr("{0} Rank {1}, XP Cost: {2}").format(
                               merit_.name, merit_rank_.id, cost_)

    first_rank_.merits.append(adv_)
    return True
Exemplo n.º 5
0
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_ = PerkAdv(merit_id, merit_rank_.id, cost_, "merit")
    adv_.rule = merit_id
    adv_.desc = __api.tr("{0} Rank {1}, XP Cost: {2}").format(
        merit_.name, merit_rank_.id, cost_)

    return api.character.purchase_advancement(adv_)
Exemplo n.º 6
0
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_ = PerkAdv(merit_id, merit_rank_.id, cost_, "merit")
    adv_.rule = merit_id
    adv_.desc = __api.tr("{0} Rank {1}, XP Cost: {2}").format(
                               merit_.name, merit_rank_.id, cost_)

    return api.character.purchase_advancement(adv_)
Exemplo n.º 7
0
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_ = PerkAdv(flaw_id, flaw_rank_.id, -gain_, "flaw")
    adv_.rule = flaw_id
    adv_.desc = __api.tr("{0} Rank {1}, XP Gain: {2}").format(
                               flaw_.name, flaw_rank_.id, gain_)

    api.character.append_advancement(adv_)
    return True