diff options
author | Your Name <you@example.com> | 2021-06-12 15:32:53 -0400 |
---|---|---|
committer | Your Name <you@example.com> | 2021-06-12 15:32:53 -0400 |
commit | 01293baa64fa905c5763020bd6c0b4903d41fc78 (patch) | |
tree | 4c49a63852fd84ead388a8fd092d64d2df7f9e1b /parser/utils.py | |
parent | b27700a7e0b281ece3dea23060c17e0cae28715d (diff) | |
download | dmtool-01293baa64fa905c5763020bd6c0b4903d41fc78.tar.gz dmtool-01293baa64fa905c5763020bd6c0b4903d41fc78.tar.bz2 dmtool-01293baa64fa905c5763020bd6c0b4903d41fc78.zip |
Verified some creature attacks
Diffstat (limited to 'parser/utils.py')
-rw-r--r--[-rwxr-xr-x] | parser/utils.py | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/parser/utils.py b/parser/utils.py index 645bc96..eb2fa67 100755..100644 --- a/parser/utils.py +++ b/parser/utils.py @@ -92,7 +92,7 @@ def getArmor(): if armor[1] == 'cost': header = armor[0] else: - 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'}) + 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 = [] @@ -128,32 +128,34 @@ def getWeapons(): damage['dmg_die_sides'] = 1 rang = [0, 0] reach = 5 - proporties = [] + properties = [] if weapon[4] != '-': - proporties = weapon[4].split(', ') - for i, p in enumerate(list(proporties)): + properties = weapon[4].split(', ') + for i, p in enumerate(list(properties)): if 'versatile' in p: - proporties[i] = 'versatile' + properties[i] = 'versatile' elif 'range' in p: - proporties[i] = p.split(' (')[0] + properties[i] = p.split(' (')[0] rang = [int(r) for r in p.split(' ')[-1][:-1].split('/')] if 'ammunition' in p: reach = 0 elif 'reach' in p: reach += 5 if name in special: - proporties.append(special[name]) - 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})) + properties.append(special[name]) + weapons.append(formatWeapon(name, rang[0], rang[1], reach, [damage], 'Provided from PHB.', baseWeapon = {'cost': cost2copper(weapon[1]), 'weight': float(Fraction(weapon[3].split(' ')[0].replace('-', '0'))), 'properties': properties, 'weapon_type': header})) return weapons # 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'}): +def formatWeapon(name, rangeShort, rangeLong, reach, damage, text, properties=[], toHitOverride=None, abilityOverride=None, dmgBonusOverride=None, baseWeapon = {'cost': -1, 'weight': -1.0, 'weapon_type': 'unknown', 'properties': []}): + if not properties: + properties = baseWeapon['properties'] for weapon in weapons: if weapon['name'] == name: baseWeapon = weapon 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} + return {'entry': 'item', 'type': 'weapons', 'name': name, 'cost': baseWeapon['cost'], 'damage': damage, 'weight': baseWeapon['weight'], 'range': [rangeShort, rangeLong], 'reach': reach, 'properties': properties, 'weapon_type': baseWeapon['weapon_type'], 'text': text, 'toHitOverride': toHitOverride, 'dmgBonusOverride': dmgBonusOverride, 'abilityOverride': abilityOverride} spells = [] def getSpells(): |