aboutsummaryrefslogtreecommitdiff
path: root/parser/utils.py
diff options
context:
space:
mode:
authorYour Name <you@example.com>2021-04-29 14:17:08 -0400
committerYour Name <you@example.com>2021-04-29 14:17:08 -0400
commit5a813a75412ac9b8fadb90c9abd46dd95aee8e9b (patch)
tree75c5466d459c793430a6481cd276a624cd843794 /parser/utils.py
parentcd57ad6e208728bafcbc8c7d7b85d88603706978 (diff)
downloaddmtool-5a813a75412ac9b8fadb90c9abd46dd95aee8e9b.tar.gz
dmtool-5a813a75412ac9b8fadb90c9abd46dd95aee8e9b.tar.bz2
dmtool-5a813a75412ac9b8fadb90c9abd46dd95aee8e9b.zip
Removed data files from repo
Diffstat (limited to 'parser/utils.py')
-rwxr-xr-xparser/utils.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/parser/utils.py b/parser/utils.py
index 087334d..34f8af2 100755
--- a/parser/utils.py
+++ b/parser/utils.py
@@ -4,6 +4,8 @@ import json
import re
from fractions import Fraction
+docsLoc = '../5thSRD/docs/'
+
skillsByAbility = {'str': ['Athletics'], 'dex': ['Acrobatics', 'Sleight of Hand', 'Stealth'], 'con': [], 'int': ['Arcana', 'History', 'Investigation', 'Nature', 'Religion'], 'wis': ['Animal Handling', 'Insight', 'Medicine', 'Perception', 'Survival'], 'cha': ['Deception', 'Intimidation', 'Performance', 'Persuasion']}
armorByType = {'light': [('padded', 11), ('leather', 11), ('studded leather', 12)], 'medium': [('hide', 12), ('chain shirt', 13), ('scale mail', 14), ('breastplate', 14), ('half plate', 15)], 'heavy': [('ring mail', 14), ('chain mail', 16), ('splint', 17), ('plate', 18)], 'misc': [('shield', 2), ('ring of protection', 1)]}
@@ -80,7 +82,7 @@ def cost2copper(cost):
return amnt
def getArmor():
- with open('../../5thSRD/docs/adventuring/equipment/armor.md') as f:
+ with open(docsLoc + '/adventuring/equipment/armor.md') as f:
data = f.read()
tables = re.search('(?sm)(?<=## Armor Table).*?(?=##)', data).group(0)
armors = []
@@ -90,7 +92,7 @@ def getArmor():
if armor[1] == 'cost':
header = armor[0]
else:
- armors.append({'name': armor[0], 'cost': cost2copper(armor[1]), 'ac': int(armor[2].split(' ')[0]), 'strength': int(armor[3].replace('-', '0').split(' ')[-1]), 'disadvantage': armor[4] == 'Disadvantage', 'weight': float(armor[5].split(' ')[0]), 'type': header.split(' ')[0]})
+ armors.append({'entry': 'item', 'type': 'armor', 'name': armor[0], 'cost': cost2copper(armor[1]), 'ac': int(armor[2].split(' ')[0]), 'strength': int(armor[3].replace('-', '0').split(' ')[-1]), 'disadvantage': armor[4] == 'disadvantage', 'weight': float(armor[5].split(' ')[0]), 'armor_type': header.split(' ')[0], 'text': 'Provided from PHB'})
return armors
weapons = []
@@ -98,7 +100,7 @@ def getWeapons():
global weapons
if weapons:
return weapons
- with open('../../5thSRD/docs/adventuring/equipment/weapons.md') as f:
+ with open(docsLoc + '/adventuring/equipment/weapons.md') as f:
data = f.read()
special = {}
for s in ['Lance', 'Net']:
@@ -141,27 +143,27 @@ def getWeapons():
reach += 5
if name in special:
proporties.append(special[name])
- weapons.append({'name': name, 'cost': cost2copper(weapon[1]), 'damage': damage, 'weight': float(Fraction(weapon[3].split(' ')[0].replace('-', '0'))), 'range': rang, 'reach': reach, 'properties': proporties, 'type': header, 'text': 'Provided from PHB'})
+ weapons.append({'entry': 'item', 'type': 'weapon', 'name': name, 'cost': cost2copper(weapon[1]), 'damage': damage, 'weight': float(Fraction(weapon[3].split(' ')[0].replace('-', '0'))), 'range': rang, 'reach': reach, 'properties': proporties, 'weapon_type': header, 'text': 'Provided from PHB'})
return weapons
def formatWeapon(name, rangeShort, rangeLong, reach, dmgType, dmgCount, dmgSides, text):
- baseWeapon = {'cost': 0, 'weight': 0.0, 'properties': [], 'type': 'unknown'}
+ baseWeapon = {'cost': 0, 'weight': 0.0, 'properties': [], 'weapon_type': 'unknown'}
for weapon in weapons:
if weapon['name'] == name:
baseWeapon = weapon
- return {'name': name, 'cost': baseWeapon['cost'], 'damage': {'dmg_type': dmgType, 'dmg_die_count': dmgCount, 'dmg_die_sides': dmgSides}, 'weight': baseWeapon['weight'], 'range': [rangeShort, rangeLong], 'reach': reach, 'properties': baseWeapon['properties'], 'type': baseWeapon['type'], 'text': text}
+ return {'name': name, 'type': 'weapon', 'cost': baseWeapon['cost'], 'damage': {'dmg_type': dmgType, 'dmg_die_count': dmgCount, 'dmg_die_sides': dmgSides}, 'weight': baseWeapon['weight'], 'range': [rangeShort, rangeLong], 'reach': reach, 'properties': baseWeapon['properties'], 'weapon_type': baseWeapon['weapon_type'], 'text': text}
spells = []
def getSpells():
global spells
if spells:
return spells
- names2names = {'name': 'name', 'level': 'level', 'school': 'school', 'classes': 'classes', 'casting_time': 'Casting Time', 'range': 'Range', 'components': 'Components', 'duration': 'Duration'}
+ names2names = {'name': 'name', 'level': 'level', 'type': 'school', 'classes': 'classes', 'casting_time': 'Casting Time', 'range': 'Range', 'components': 'Components', 'duration': 'Duration'}
from pathlib import Path
- for s in Path('../../5thSRD/docs/spellcasting/spells/').iterdir():
+ for s in Path(docsLoc + '/spellcasting/spells/').iterdir():
with s.open() as f:
data = f.read()
- spell = {}
+ spell = {'entry': 'spell'}
for name in names2names:
spell[name] = re.search('(?sm)[\*]*{}[\*:]* (.*?)^[a-zA-Z#\*]'.format(names2names[name]), data).group(1).strip()
spell['name'] = spell['name'].lower()