Esempio n. 1
0
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'])
Esempio n. 2
0
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'])
Esempio n. 3
0
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'])
Esempio n. 4
0
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'])
Esempio n. 5
0
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)
Esempio n. 6
0
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)
def process_section(conn, curs, section, update):
	fields = filter_section_fields(update)
	if len(fields) > 0:
		update_section(curs, section['section_id'], **fields)
	if update.has_key('misc'):
		for misc in update['misc']:
			fetch_item_misc(curs, section['section_id'],
					field=misc.get('field', None),
					subsection=misc.get('subsection'))
			existing = curs.fetchone()
			if existing:
				delete_item_misc(curs, existing['item_misc_id'])
			insert_item_misc(curs, section['section_id'], **misc)
Esempio n. 8
0
def process_section(conn, curs, section, update):
    fields = filter_section_fields(update)
    if len(fields) > 0:
        update_section(curs, section['section_id'], **fields)
    if update.has_key('misc'):
        for misc in update['misc']:
            fetch_item_misc(curs,
                            section['section_id'],
                            field=misc.get('field', None),
                            subsection=misc.get('subsection'))
            existing = curs.fetchone()
            if existing:
                delete_item_misc(curs, existing['item_misc_id'])
            insert_item_misc(curs, section['section_id'], **misc)