Skip to content

Commit

Permalink
Version 3.3.4
Browse files Browse the repository at this point in the history
* Fix for gear parsing, e.g. Combat Gear and Other Gear on separate lines (#488)
* Fix for wrongly calculated BAB for attacks with enchanted weapons (#503)
  • Loading branch information
Lavaeolous committed Feb 9, 2022
1 parent 93ee680 commit 4a510ad
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 30 deletions.
48 changes: 31 additions & 17 deletions statblock-converter/module.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
{
"name": "pf1-statblock-converter",
"title": "sbc | PF1 Stackblock Converter",
"description": "Convert Pathfinder 1. Edition Statblocks into working NPC or PC Actors",
"version": "3.3.3",
"author": "Lavaeolous",
"systems": ["pf1"],
"esmodules": ["./scripts/sbc.js"],
"styles": ["./styles/sbc.css"],
"templates": ["./templates/sbcModal.html", "./templates/sbcPreview"],
"packs": [],
"url": "https://github.com/Lavaeolous/PF1-StatBlock-Converter-Module",
"bugs": "https://github.com/Lavaeolous/PF1-StatBlock-Converter-Module/issues",
"manifest": "https://github.com/Lavaeolous/PF1-StatBlock-Converter-Module/releases/download/v3.3.3/module.json",
"download": "https://github.com/Lavaeolous/PF1-StatBlock-Converter-Module/releases/download/v3.3.3/3.3.3_statblock-converter.zip",
"minimumCoreVersion": "9",
"compatibleCoreVersion": "9"
}
"name": "pf1-statblock-converter",
"title": "sbc | PF1 Stackblock Converter",
"description": "Convert Pathfinder 1. Edition Statblocks into working NPC or PC Actors",
"author": "Lavaeolous",
"authors": [],
"url": "https://github.com/Lavaeolous/PF1-StatBlock-Converter-Module",
"bugs": "https://github.com/Lavaeolous/PF1-StatBlock-Converter-Module/issues",
"flags": {},
"version": "3.3.4",
"minimumCoreVersion": "9",
"compatibleCoreVersion": "9",
"scripts": [],
"esmodules": [
"./scripts/sbc.js"
],
"styles": [
"./styles/sbc.css"
],
"languages": [],
"packs": [],
"system": [
"pf1"
],
"dependencies": [],
"socket": false,
"manifest": "https://github.com/Lavaeolous/PF1-StatBlock-Converter-Module/releases/download/v3.3.4/module.json",
"download": "https://github.com/Lavaeolous/PF1-StatBlock-Converter-Module/releases/download/v3.3.4/3.3.4_statblock-converter.zip",
"protected": false,
"coreTranslation": false,
"library": false
}
Binary file not shown.
2 changes: 1 addition & 1 deletion statblock-converter/scripts/sbc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Author: Lavaeolous
* Additional Authors: Noon
* Version: 3.3.3
* Version: 3.3.4
*
*/

Expand Down
28 changes: 27 additions & 1 deletion statblock-converter/scripts/sbcConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const sbcConfig = {};
/* ------------------------------------ */

sbcConfig.modData = {
"version": "3.3.3",
"version": "3.3.4",
"mod": "pf1-statblock-converter",
"modName": "sbc | PF1 Statblock Converter"
}
Expand All @@ -16,6 +16,32 @@ sbcConfig.const = {
"lineheight": 20,
"crFractions": { "1/8" : 0.125, "1/6" : 0.1625, "1/4": 0.25, "1/3": 0.3375, "1/2": 0.5 },
"actorType": { 0 : "npc", 1 : "character" },
"actorSizes": {
"col": "Colossal",
"dim": "Diminutive",
"fine": "Fine",
"grg": "Gargantuan",
"huge": "Huge",
"lg": "Large",
"med": "Medium",
"sm": "Small",
"tiny": "Tiny"
},
"creatureTypes": {
"aberratio": "Aberration",
"animal": "Animal",
"construct": "Construct",
"dragon": "Dragon",
"fey": "Fey",
"humanoid": "Humanoid",
"magicalBeast": "Magical Beast",
"monstrousHumanoid": "Monstrous Humanoid",
"ooze": "Ooze",
"outsider": "Outsider",
"plant": "Plant",
"undead": "Undead",
"vermin": "Vermin"
},
"tokenBarAttributes": [
"attributes.hp",
"spells.spellbooks.primary.spellPoints",
Expand Down
49 changes: 38 additions & 11 deletions statblock-converter/scripts/sbcParsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,12 @@ export async function parseBase(data, startLine) {

// Parse Size and Space / Token Size
if (!parsedSubCategories["size"]) {
let patternSize = new RegExp("(" + Object.values(CONFIG.PF1.actorSizes).join("\\b|\\b") + ")", "i")
let patternSize = new RegExp("(" + Object.values(sbcConfig.const.actorSizes).join("\\b|\\b") + ")", "i")
if (patternSize.test(lineContent) && patternAlignment.test(lineContent)) {
let parserSize = sbcMapping.map.base.size
let size = lineContent.match(patternSize)[1].trim()
sbcData.notes.base.size = size
let actorSize = sbcUtils.getKeyByValue(CONFIG.PF1.actorSizes, size)
let actorSize = sbcUtils.getKeyByValue(sbcConfig.const.actorSizes, size)

// Values derived from Size
let parserSpace = new singleValueParser(["token.height", "token.width"], "number")
Expand All @@ -352,10 +352,11 @@ export async function parseBase(data, startLine) {

// Parse Creature Type and Subtype, but only when they are found after a size declaration
if (!parsedSubCategories["creatureType"]) {
let patternCreatureType = new RegExp("(?:" + Object.values(CONFIG.PF1.actorSizes).join("\\b|\\b") + ")\\s*(" + Object.values(CONFIG.PF1.creatureTypes).join("\\b.*|\\b") + ")", "i")
let patternCreatureType = new RegExp("(?:" + Object.values(sbcConfig.const.actorSizes).join("\\b|\\b") + ")\\s*(" + Object.values(sbcConfig.const.creatureTypes).join("\\b.*|\\b") + ")", "i")
if (patternCreatureType.test(lineContent)) {
let creatureType = lineContent.match(patternCreatureType)[1]
let parserCreatureType = sbcMapping.map.base.creatureType

parsedSubCategories["creatureType"] = await parserCreatureType.parse(creatureType, line)
}
}
Expand Down Expand Up @@ -671,6 +672,10 @@ class creatureTypeParser extends sbcParserBase {

let tempCreatureType = sbcParsing.parseSubtext(value)

// Localization
let creatureTypeKey = sbcUtils.getKeyByValue(sbcConfig.const.creatureTypes, tempCreatureType[0])
let localizedCreatureType = CONFIG.PF1.creatureTypes[creatureTypeKey]

let creatureType = {
"name": tempCreatureType[0],
"type": "racial",
Expand All @@ -682,6 +687,7 @@ class creatureTypeParser extends sbcParserBase {
}

let compendium = "pf1.racialhd"
// Always search the english compendia for entries, so use the english creatureType instead of the localized one
let creatureTypeItem = await sbcUtils.findEntityInCompendium(compendium, creatureType, line)
creatureTypeItem.data.data.useCustomTag = true
creatureTypeItem.data.data.tag = game.pf1.utils.createTag(creatureType.name)
Expand All @@ -696,7 +702,8 @@ class creatureTypeParser extends sbcParserBase {
}

if (creatureType.subTypes !== "") {
creatureTypeItem.data.name = sbcUtils.capitalize(creatureType.name) + " (" + sbcUtils.capitalize(creatureType.subTypes) + ")"
//creatureTypeItem.data.name = sbcUtils.capitalize(creatureType.name) + " (" + sbcUtils.capitalize(creatureType.subTypes) + ")"
creatureTypeItem.data.name = sbcUtils.capitalize(localizedCreatureType) + " (" + sbcUtils.capitalize(creatureType.subTypes) + ")"
}

sbcData.notes.creatureType = creatureTypeItem.data.name
Expand Down Expand Up @@ -727,7 +734,7 @@ class creatureTypeParser extends sbcParserBase {
let camelizedCreatureType = sbcUtils.camelize(creatureType.name)

let race = {
"name": "Race: " + sbcUtils.capitalize(creatureType.name),
"name": sbcUtils.capitalize(localizedCreatureType),
"type": "race",
"creatureType": camelizedCreatureType,
"subTypes": subTypesArray,
Expand Down Expand Up @@ -2389,8 +2396,22 @@ class attacksParser extends sbcParserBase {
}

// attackModifier
if (attack.match(/(\+\d+|-\d+)(?:[+0-9/ ]+\(*)/) !== null) {
inputAttackModifier = attack.match(/(\+\d+|-\d+)(?:[+0-9/ ]+\(*)/)[1]
if (attack.match(/(\+\d+|-\d+)(?:[+0-9/ ]*\(*)/) !== null) {

// Prefer matches that are not at the start and are followed by a parenthesis
if (attack.match(/(?!^)(\+\d+|-\d+)(?:[+0-9/ ]*\(+)/) !== null) {
inputAttackModifier = attack.match(/(?!^)(\+\d+|-\d+)(?:[+0-9/ ]*\(+)/)[1]
} else if (attack.match(/(?!^)(\+\d+|-\d+)(?:[+0-9/ ]*)/) !== null) {
// Otherwise try to get just an attackModifier, e.g. for attacks without damage
inputAttackModifier = attack.match(/(?!^)(\+\d+|-\d+)(?:[+0-9/ ]*)/)[1]
} else {
// If nothing is found, fail gracefully
let errorMessage = "Failed to find a useable attack modifier"
let error = new sbcError(1, "Parse/Offense", errorMessage, line)
sbcData.errors.push(error)
}


attackNotes += inputAttackModifier
}

Expand Down Expand Up @@ -3296,15 +3317,21 @@ export async function parseStatistics(data, startLine) {
}

// Parse Gear
if (!parsedSubCategories["gear"]) {
//if (!parsedSubCategories["gear"]) {
if (/(Combat Gear|Other Gear|Gear)\b/i.test(lineContent)) {
let parserGear = sbcMapping.map.statistics.gear
// Combat Gear, Other Gear, Gear
let gear = lineContent.replace(/(Combat Gear|Other Gear|Gear)/g, "").replace(/[,;]+/g,",").trim()
sbcData.notes.statistics.gear = gear
let gear = lineContent.replace(/(Combat Gear|Other Gear|Gear)/g, "").replace(/[,;]+/g,",").replace(/[,;]$/, "").trim()

if (!sbcData.notes.statistics.gear) {
sbcData.notes.statistics.gear = gear
} else {
sbcData.notes.statistics.gear += gear
}

parsedSubCategories["gear"] = await parserGear.parse(gear, startLine + line)
}
}
//}

} catch (err) {

Expand Down

0 comments on commit 4a510ad

Please sign in to comment.