Exemplo n.º 1
0
def domain_pass(struct):
    d = find_section(struct, name="Domains", section_type="section")
    if d:
        domains = find_all_sections(struct, name=re.compile("^.*Domain$"), section_type="section")
        for domain in domains:
            remove_section(struct, domain)
            domain["subtype"] = "cleric_domain"
            add_section(d, domain)
    return struct
Exemplo n.º 2
0
def domain_pass(struct):
	d = find_section(struct, name="Domains", section_type='section')
	if d:
		domains = find_all_sections(struct, name=re.compile('^.*Domain$'), section_type='section')
		for domain in domains:
			remove_section(struct, domain)
			domain['subtype'] = 'cleric_domain'
			add_section(d, domain)
	return struct
Exemplo n.º 3
0
def advanced_players_guide_structure_pass(rules, basename):
	if basename == 'advancedRaces.html':
		newsections = []
		racesections = []
		currparent = None
		isnew = True
		for section in rules['sections']:
			if section['name'] in ['Dwarves', 'Elves', 'Gnomes', 'Half-Elves', 'Half-Orcs', 'Halflings', 'Humans']:
				isnew = False
				currparent = section
				newsections.append(section)
				racesections = currparent.setdefault('sections', [])
			elif isnew:
				newsections.append(section)
			else:
				if section['name'] == 'Alternate Racial Traits':
					for trait in section['sections']:
						trait['type'] = 'racial_trait'
						trait['subtype'] = currparent['name'].lower()
				racesections.append(section)
			rules['sections'] = newsections
	elif basename == 'ranger.html':
		cl = rules['sections'][0]
		weap = find_section(rules, name='New Combat Styles')
		remove_section(rules, weap)
		newsec = []
		for section in weap['sections']:
			section['subtype'] = 'ranger_combat_style'
		last = weap['sections'][len(weap['sections']) -1]
		soup = BeautifulSoup(last['text'])
		last['text'] = unicode(soup.contents[0])
		newtext = ''.join([unicode(c) for c in soup.contents[1:]])
		newsec = {'type': 'section', 'source': rules['source'], 'text': newtext}
		weap['sections'].append(newsec)
		cl.setdefault('sections', []).append(weap)
	elif basename == 'cleric.html':
		subdomains = rules['sections'][1]
		for section in subdomains['sections']:
			if section['type'] == 'section':
				section['subtype'] = 'cleric_subdomain'
	elif basename == 'sorcerer.html':
		newsections = []
		cl = rules['sections'].pop(0)
		newsections.append(cl)
		arch = {'type': 'section', 'source': rules['source'], 'name': 'Sorcerer Bloodlines', 'sections': rules['sections']}
		for section in arch['sections']:
			section['subtype'] = 'sorcerer_bloodline'
		newsections.append(arch)
		rules['sections'] = newsections
	elif basename == 'wizard.html':
		rules = mark_subtype_pass(rules, "Elemental Arcane Schools", "elemental_arcane_school")
		rules = mark_subtype_pass(rules, "Focused Arcane Schools", "focused_arcane_school")
	if basename in ['barbarian.html', 'bard.html', 'druid.html', 'fighter.html', 'monk.html', 'paladin.html', 'ranger.html', 'rogue.html']:
		return ap_archetype_pass(rules)
	return rules
Exemplo n.º 4
0
def domain_pass(struct):
    d = find_section(struct, name="Domains", section_type='section')
    if d:
        domains = find_all_sections(struct,
                                    name=re.compile('^.*Domain$'),
                                    section_type='section')
        for domain in domains:
            remove_section(struct, domain)
            domain['subtype'] = 'cleric_domain'
            add_section(d, domain)
    return struct
Exemplo n.º 5
0
def structural_pass(struct, filename):
    if filename in ('druid.html'):
        struct = druid_structural_pass(struct)
    cs = find_section(struct, name="Class Skills", section_type='section')
    table = find_section(cs, name=struct['name'], section_type='table')
    idx = struct['sections'].index(cs)
    while table:
        idx = idx + 1
        if table:
            remove_section(struct, table)
            struct['sections'].insert(idx, table)
        table = find_section(cs, name=struct['name'], section_type='table')
    return struct
Exemplo n.º 6
0
def structural_pass(struct, filename):
	if filename in ('druid.html'):
		struct = druid_structural_pass(struct)
	cs = find_section(struct, name="Class Skills", section_type='section')
	table = find_section(cs, name=struct['name'], section_type='table')
	idx = struct['sections'].index(cs)
	while table:
		idx = idx + 1
		if table:
			remove_section(struct, table)
			struct['sections'].insert(idx, table)
		table = find_section(cs, name=struct['name'], section_type='table')
	return struct
Exemplo n.º 7
0
def structural_pass(struct, filename):
    if filename in ("druid.html"):
        struct = druid_structural_pass(struct)
    cs = find_section(struct, name="Class Skills", section_type="section")
    table = find_section(cs, name=struct["name"], section_type="table")
    idx = struct["sections"].index(cs)
    while table:
        idx = idx + 1
        if table:
            remove_section(struct, table)
            struct["sections"].insert(idx, table)
        table = find_section(cs, name=struct["name"], section_type="table")
    return struct
Exemplo n.º 8
0
def bloodline_pass(struct):
	s = find_section(struct, name="Sorcerer Bloodlines", section_type='section')
	if s:
		collect = False
		bloodlines = []
		for section in struct['sections']:
			if collect:
				bloodlines.append(section)
			elif s == section:
				collect = True
		for bloodline in bloodlines:
			bloodline['subtype'] = 'sorcerer_bloodline'
			remove_section(struct, bloodline)
			add_section(s, bloodline)
	return struct
Exemplo n.º 9
0
def class_pass(struct):
	struct['type'] = 'class'
	align = find_section(struct, name="Alignment", section_type='section')
	if align:
		remove_section(struct, align)
		soup = BeautifulSoup(align['text'])
		struct['alignment'] = ''.join(soup.findAll(text=True))
	hd = find_section(struct, name="Hit Die", section_type='section')
	if hd:
		remove_section(struct, hd)
		soup = BeautifulSoup(hd['text'])
		hit = ''.join(soup.findAll(text=True))
		if hit.endswith("."):
			hit = hit[:-1]
		struct['hit_dice'] = hit
	return struct
Exemplo n.º 10
0
def arcane_school_pass(struct):
    s = find_section(struct, name="Arcane Schools", section_type='section')
    if s:
        collect = False
        schools = []
        for section in struct['sections']:
            if section.get('name') == 'Familiars':
                collect = False
            elif collect:
                schools.append(section)
            elif s == section:
                collect = True
        for school in schools:
            school['subtype'] = 'arcane_school'
            remove_section(struct, school)
            add_section(s, school)
    return struct
Exemplo n.º 11
0
def bloodline_pass(struct):
    s = find_section(struct,
                     name="Sorcerer Bloodlines",
                     section_type='section')
    if s:
        collect = False
        bloodlines = []
        for section in struct['sections']:
            if collect:
                bloodlines.append(section)
            elif s == section:
                collect = True
        for bloodline in bloodlines:
            bloodline['subtype'] = 'sorcerer_bloodline'
            remove_section(struct, bloodline)
            add_section(s, bloodline)
    return struct
Exemplo n.º 12
0
def arcane_school_pass(struct):
	s = find_section(struct, name="Arcane Schools", section_type='section')
	if s:
		collect = False
		schools = []
		for section in struct['sections']:
			if section.get('name') == 'Familiars':
				collect = False
			elif collect:
				schools.append(section)
			elif s == section:
				collect = True
		for school in schools:
			school['subtype'] = 'arcane_school'
			remove_section(struct, school)
			add_section(s, school)
	return struct
Exemplo n.º 13
0
def arcane_school_pass(struct):
    s = find_section(struct, name="Arcane Schools", section_type="section")
    if s:
        collect = False
        schools = []
        for section in struct["sections"]:
            if section.get("name") == "Familiars":
                collect = False
            elif collect:
                schools.append(section)
            elif s == section:
                collect = True
        for school in schools:
            school["subtype"] = "arcane_school"
            remove_section(struct, school)
            add_section(s, school)
    return struct
Exemplo n.º 14
0
def class_pass(struct):
    struct['type'] = 'class'
    align = find_section(struct, name="Alignment", section_type='section')
    if align:
        remove_section(struct, align)
        soup = BeautifulSoup(align['text'])
        struct['alignment'] = ''.join(soup.findAll(text=True))
    hd = find_section(struct, name="Hit Die", section_type='section')
    if not hd:
        hd = find_section(struct, name="Hit Dice", section_type='section')
    if hd:
        remove_section(struct, hd)
        soup = BeautifulSoup(hd['text'])
        hit = ''.join(soup.findAll(text=True))
        if hit.endswith("."):
            hit = hit[:-1]
        struct['hit_dice'] = hit
    return struct
Exemplo n.º 15
0
def class_pass(struct):
    struct["type"] = "class"
    align = find_section(struct, name="Alignment", section_type="section")
    if align:
        remove_section(struct, align)
        soup = BeautifulSoup(align["text"])
        struct["alignment"] = "".join(soup.findAll(text=True))
    hd = find_section(struct, name="Hit Die", section_type="section")
    if not hd:
        hd = find_section(struct, name="Hit Dice", section_type="section")
    if hd:
        remove_section(struct, hd)
        soup = BeautifulSoup(hd["text"])
        hit = "".join(soup.findAll(text=True))
        if hit.endswith("."):
            hit = hit[:-1]
        struct["hit_dice"] = hit
    return struct
Exemplo n.º 16
0
def advanced_players_guide_structure_pass(rules, basename):
    if basename == 'advancedRaces.html':
        newsections = []
        racesections = []
        currparent = None
        isnew = True
        for section in rules['sections']:
            if section['name'] in [
                    'Dwarves', 'Elves', 'Gnomes', 'Half-Elves', 'Half-Orcs',
                    'Halflings', 'Humans'
            ]:
                isnew = False
                currparent = section
                newsections.append(section)
                racesections = currparent.setdefault('sections', [])
            elif isnew:
                newsections.append(section)
            else:
                if section['name'] == 'Alternate Racial Traits':
                    for trait in section['sections']:
                        trait['type'] = 'racial_trait'
                        trait['subtype'] = currparent['name'].lower()
                racesections.append(section)
            rules['sections'] = newsections
    elif basename == 'ranger.html':
        cl = rules['sections'][0]
        weap = find_section(rules, name='New Combat Styles')
        remove_section(rules, weap)
        newsec = []
        for section in weap['sections']:
            section['subtype'] = 'ranger_combat_style'
        last = weap['sections'][len(weap['sections']) - 1]
        soup = BeautifulSoup(last['text'])
        last['text'] = unicode(soup.contents[0])
        newtext = ''.join([unicode(c) for c in soup.contents[1:]])
        newsec = {
            'type': 'section',
            'source': rules['source'],
            'text': newtext
        }
        weap['sections'].append(newsec)
        cl.setdefault('sections', []).append(weap)
    elif basename == 'cleric.html':
        subdomains = rules['sections'][1]
        for section in subdomains['sections']:
            if section['type'] == 'section':
                section['subtype'] = 'cleric_subdomain'
    elif basename == 'sorcerer.html':
        newsections = []
        cl = rules['sections'].pop(0)
        newsections.append(cl)
        arch = {
            'type': 'section',
            'source': rules['source'],
            'name': 'Sorcerer Bloodlines',
            'sections': rules['sections']
        }
        for section in arch['sections']:
            section['subtype'] = 'sorcerer_bloodline'
        newsections.append(arch)
        rules['sections'] = newsections
    elif basename == 'wizard.html':
        rules = mark_subtype_pass(rules, "Elemental Arcane Schools",
                                  "elemental_arcane_school")
        rules = mark_subtype_pass(rules, "Focused Arcane Schools",
                                  "focused_arcane_school")
    if basename in [
            'barbarian.html', 'bard.html', 'druid.html', 'fighter.html',
            'monk.html', 'paladin.html', 'ranger.html', 'rogue.html'
    ]:
        return ap_archetype_pass(rules)
    return rules