def add_spell_list(curs, struct): if not struct['type'] == 'spell_list': raise Exception("This should only be run on spell list files") if struct['class'] in ("Sorcerer/wizard", "Sorcerer/Wizard"): struct['class'] = "Sorcerer" add_spell_list(curs, struct) struct['class'] = "Wizard" add_spell_list(curs, struct) return struct = fix_spell_list(struct) level = struct['level'] class_name = cap_words(struct['class']) for sp in struct['spells']: name = cap_words(sp['name'].strip()) find_section(curs, name=name, type='spell') spell = curs.fetchone() if not spell: raise Exception("Cannot find spell %s" % name) fetch_spell_lists(curs, spell['section_id'], class_name=class_name) if not curs.fetchone(): magic_type = find_magic_type(class_name.lower()) insert_spell_list(curs, spell['section_id'], level, class_name, magic_type) fix_spell_level_text(curs, spell['section_id']) if sp.has_key('description'): update_section(curs, spell['section_id'], description=sp['description'])
def insert_spell_records(curs, curs_list, section_id, spell): if spell.has_key('parent'): orig = fetch_complete_spell(curs, spell['parent']) if not orig: # Need to handle case where spell is in a previous book for c in curs_list: orig = fetch_complete_spell(c, spell['parent']) if orig: break if not orig: raise ProcessLastException(spell['parent']) spell = merge_spells(orig, spell) descriptor_text = ', '.join(spell.get('descriptor', [])) if descriptor_text == "": descriptor_text = None else: spell['descriptor_text'] = descriptor_text level_list = [] for level in spell.get('level', []): level_list.append(level['class'] + ": " + str(level['level'])) level_text = "; ".join(level_list) spell['level_text'] = level_text insert_spell_detail(curs, **spell) if spell.has_key('subschool') and spell['subschool']: for subschool in subschool_list(spell['subschool']): insert_spell_subschool(curs, section_id, subschool) for descriptor in filter_descriptors(spell.get('descriptor', [])): insert_spell_descriptor(curs, section_id, descriptor) for level in spell.get('level', []): magic_type = find_magic_type(level['class']) insert_spell_list(curs, section_id, level['level'], cap_words(level['class']), magic_type) for component in spell.get('components', []): insert_spell_component(curs, section_id, component.get('type'), component.get('text'), 0) for effect in spell.get('effects', []): insert_spell_effect(curs, section_id, effect['name'], effect['text'])
def insert_spell_records(curs, section_id, spell): if spell.has_key('parent'): orig = fetch_complete_spell(curs, spell['parent']) if not orig: raise ProcessLastException(spell['parent']) spell = merge_spells(orig, spell) descriptor_text = ', '.join(spell.get('descriptor', [])) if descriptor_text == "": descriptor_text = None else: spell['descriptor_text'] = descriptor_text level_list = [] for level in spell.get('level', []): level_list.append(level['class'] + ": " + str(level['level'])) level_text = "; ".join(level_list) spell['level_text'] = level_text insert_spell_detail(curs, **spell) for descriptor in spell.get('descriptor', []): insert_spell_descriptor(curs, section_id, descriptor) for level in spell.get('level', []): magic_type = find_magic_type(level['class']) insert_spell_list(curs, section_id, level['level'], cap_words(level['class']), magic_type) for component in spell.get('components', []): insert_spell_component(curs, section_id, component['type'], component.get('text'), 0) for effect in spell.get('effects', []): insert_spell_effect(curs, section_id, effect['name'], effect['text'])
def insert_spell_records(curs, section_id, spell): if spell.has_key('parent'): orig = fetch_complete_spell(curs, spell['parent']) if not orig: raise ProcessLastException(spell['parent']) spell = merge_spells(orig, spell) descriptor_text = ', '.join(spell.get('descriptor', [])) if descriptor_text == "": descriptor_text = None else: spell['descriptor_text'] = descriptor_text level_list = [] for level in spell.get('level', []): level_list.append(level['class'] + ": " + str(level['level'])) level_text = "; ".join(level_list) spell['level_text'] = level_text insert_spell_detail(curs, **spell) for descriptor in spell.get('descriptor', []): insert_spell_descriptor(curs, section_id, descriptor) for level in spell.get('level', []): magic_type = find_magic_type(level['class']) insert_spell_list(curs, section_id, level['level'], cap_words(level['class']), magic_type) for component in spell.get('components', []): insert_spell_component(curs, section_id, component.get('type'), component.get('text'), 0) for effect in spell.get('effects', []): insert_spell_effect(curs, section_id, effect['name'], effect['text'])
def do_add_spell_list(curs, spell, sp, class_name, level): fetch_spell_lists(curs, spell['section_id'], class_name=class_name) if not curs.fetchone(): magic_type = find_magic_type(class_name.lower()) insert_spell_list(curs, spell['section_id'], level, class_name, magic_type) fix_spell_level_text(curs, spell['section_id']) if sp.has_key('description') and sp['description'] != '': update_section(curs, spell['section_id'], description=sp['description'])
def do_add_spell_list(curs, spell, sp, class_name, level): fetch_spell_lists(curs, spell['section_id'], class_name=class_name) if not curs.fetchone(): magic_type = find_magic_type(class_name.lower()) insert_spell_list(curs, spell['section_id'], level, class_name, magic_type) fix_spell_level_text(curs, spell['section_id']) if sp.has_key('description'): update_section(curs, spell['section_id'], description=sp['description'])
def do_add_spell_list(curs, spell, description, type, name, level, notes): fetch_spell_lists(curs, spell['section_id'], type=type, name=name) if not curs.fetchone(): magic_type = "divine" if type == "class": magic_type = find_magic_type(name.lower()) insert_spell_list(curs, spell['section_id'], level, type, name, notes, magic_type) fix_spell_list_text(curs, spell['section_id'], type) if description: update_section(curs, spell['section_id'], description=description)