Beispiel #1
0
def process_gear(table_data, gear_list):
    remap = {
        "Cost": "price",
        "Weight": "weight",
        "Name": "name",
        "Aura": "aura"
    }
    for gear in gear_list:
        item = {"type": "item"}
        fix_cost(gear)
        fields = gear.keys()
        fields.sort()
        for key in fields:
            misc = item.setdefault('misc', [])
            if gear['Name'] in table_data.get('distinct_section', {}):
                value = gear[key]
                subsection = table_data['distinct_section'][gear['Name']]
                if key == "Cost":
                    key = "Price"
                if not key == "Name":
                    misc.append({
                        "field": key,
                        "subsection": subsection,
                        "value": value
                    })
            else:
                if key in remap.keys():
                    item[remap[key]] = gear[key]
                else:
                    value = gear[key]
                    misc.append({"field": key, "value": value})
        gear['item'] = item
        set_subtype(table_data, 'Gear Type', gear)
    return gear_list
Beispiel #2
0
def process_weapons(table_data, weapons):
	remap = {"Cost": "price", "Weight": "weight", "Name": "name"}
	for weapon in weapons:
		item = {"type": "item"}
		set_damage(weapon)
		fix_cost(weapon)
		fields = weapon.keys()
		fields.sort()
		for key in fields:
			if key in remap.keys():
				item[remap[key]] = weapon[key]
			else:
				misc = item.setdefault('misc', [])
				subsection = "Weapon"
				value = weapon[key]
				if weapon['Name'] in table_data.get('distinct_section', {}):
					subsection = table_data['distinct_section'][weapon['Name']]
				misc.append({
					"field": key,
					"subsection": subsection,
					"value": value})
		weapon['item'] = item
		set_subtype(table_data, "Weapon Class", weapon)
	#pp = pprint.PrettyPrinter(indent=4)
	#pp.pprint(weapons)
	return weapons
Beispiel #3
0
def process_gear(table_data, gear_list):
	remap = {
			"Cost": "price",
			"Weight": "weight",
			"Name": "name",
			"Aura": "aura"}
	for gear in gear_list:
		item = {"type": "item"}
		fix_cost(gear)
		fields = gear.keys()
		fields.sort()
		for key in fields:
			misc = item.setdefault('misc', [])
			if gear['Name'] in table_data.get('distinct_section', {}):
				value = gear[key]
				subsection = table_data['distinct_section'][gear['Name']]
				if key == "Cost":
					key = "Price"
				if not key == "Name":
					misc.append({
						"field": key,
						"subsection": subsection,
						"value": value})
			else:
				if key in remap.keys():
					item[remap[key]] = gear[key]
				else:
					value = gear[key]
					misc.append({
						"field": key,
						"value": value})
		gear['item'] = item
		set_subtype(table_data, 'Gear Type', gear)
	return gear_list
Beispiel #4
0
def process_armor(table_data, armor_list):
	remap = {"Cost": "price", "Weight": "weight", "Name": "name"}
	for armor in armor_list:
		item = {"type": "item"}
		fields = armor.keys()
		fields.sort()
		for key in fields:
			if key in remap.keys():
				item[remap[key]] = armor[key]
			else:
				misc = item.setdefault('misc', [])
				value = armor[key]
				if key == u'Armor/Shield Bonus':
					if armor['Armor Type'] == u'Shields':
						key = 'Shield Bonus'
					else:
						key = 'Armor Bonus'
				subsection = "Armor"
				if armor['Name'] in table_data.get('distinct_section', {}):
					subsection = table_data['distinct_section'][armor['Name']]
				misc.append({
					"field": key,
					"subsection": subsection,
					"value": value})
		armor['item'] = item
		set_subtype(table_data, "Armor Type", armor)
	#pp = pprint.PrettyPrinter(indent=4)
	#pp.pprint(armor_list)
	return armor_list