def add_spell(spell_id): """add a spell, not bound to a specific rank advancement""" spell_ = api.data.spells.get(spell_id) if not spell_: log.api.error(u"add_school_spell. spell not found: %s", spell_id) return False adv = models.SpellAdv(spell_id) adv.desc = (api.tr('{0}, Mastery {1}. Element: {2}') .format(spell_.name, spell_.mastery, spell_.element)) api.character.append_advancement(adv) return True
def purchase_memo_spell(spell_id): """purchase a memorized spell""" log.api.info(u"purchase memorized spell: %s", spell_id) spell_ = api.data.spells.get(spell_id) if not spell_: log.api.error(u"spell not found") return api.data.CMErrors.INTERNAL_ERROR # no special rules for memorized spells cost = spell_.mastery text = spell_.name adv = models.MemoSpellAdv(spell_id, cost) adv.desc = (api.tr('{0}, Mastery {1}. Cost: {2} xp') .format(text, spell_.mastery, adv.cost)) return api.character.purchase_advancement(adv)