diff options
Diffstat (limited to 'parser/utils.py')
-rwxr-xr-x | parser/utils.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/parser/utils.py b/parser/utils.py index 34f8af2..34649ca 100755 --- a/parser/utils.py +++ b/parser/utils.py @@ -119,7 +119,7 @@ def getWeapons(): name = parts[1] + ' ' + parts[0] if weapon[2] == '-': weapon[2] = '0d0 -' - damage = {'dmg_type': weapon[2].split(' ')[1]} + damage = {'dmg_type': weapon[2].split(' ')[1], 'is_or': False} if 'd' in weapon[2].split(' ')[0]: damage['dmg_die_count'] = int(weapon[2].split('d')[0]) damage['dmg_die_sides'] = int(weapon[2].split(' ')[0].split('d')[1]) @@ -143,15 +143,17 @@ def getWeapons(): reach += 5 if name in special: proporties.append(special[name]) - 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'}) + weapons.append(formatWeapon(name, rang[0], rang[1], reach, [damage], 'Provided from PHB', {'cost': cost2copper(weapon[1]), 'weight': float(Fraction(weapon[3].split(' ')[0].replace('-', '0'))), 'properties': proporties, 'weapon_type': header})) return weapons -def formatWeapon(name, rangeShort, rangeLong, reach, dmgType, dmgCount, dmgSides, text): - baseWeapon = {'cost': 0, 'weight': 0.0, 'properties': [], 'weapon_type': 'unknown'} +# damage is formatted {'dmg_die_count': ddc, 'dmg_die_sides': dds, 'dmg_type': dt, 'is_or': bool} +def formatWeapon(name, rangeShort, rangeLong, reach, damage, text, baseWeapon = {'cost': -1, 'weight': -1.0, 'properties': [], 'weapon_type': 'unknown'}): for weapon in weapons: if weapon['name'] == name: baseWeapon = weapon - 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} + for dmg in damage: + assert 'dmg_die_count' in dmg and 'dmg_die_sides' in dmg and 'dmg_type' in dmg and 'is_or' in dmg + return {'entry': 'item', 'type': 'weapons', 'name': name, 'cost': baseWeapon['cost'], 'damage': damage, 'weight': baseWeapon['weight'], 'range': [rangeShort, rangeLong], 'reach': reach, 'properties': baseWeapon['properties'], 'weapon_type': baseWeapon['weapon_type'], 'text': text} spells = [] def getSpells(): |