fixed range detection for actions

This commit is contained in:
CPTN Cosmo 2026-01-24 11:39:37 +01:00
parent fd0e718a1c
commit b6a1af9926
No known key found for this signature in database
2 changed files with 14 additions and 7 deletions

View file

@ -1,7 +1,7 @@
{ {
"id": "dh-importer", "id": "dh-importer",
"title": "Daggerheart Statblock Importer", "title": "Daggerheart Statblock Importer",
"version": "1.1.0", "version": "1.1.1",
"compatibility": { "compatibility": {
"minimum": "13", "minimum": "13",
"verified": "13" "verified": "13"
@ -34,5 +34,5 @@
"description": "Imports Adversaries and Environments from text blocks into the Daggerheart system.", "description": "Imports Adversaries and Environments from text blocks into the Daggerheart system.",
"url": "https://github.com/cptn-cosmo/dh-importer", "url": "https://github.com/cptn-cosmo/dh-importer",
"manifest": "https://git.geeks.gay/cosmo/dh-importer/raw/branch/main/module.json", "manifest": "https://git.geeks.gay/cosmo/dh-importer/raw/branch/main/module.json",
"download": "https://git.geeks.gay/cosmo/dh-importer/releases/download/1.1.0/dh-importer.zip" "download": "https://git.geeks.gay/cosmo/dh-importer/releases/download/1.1.1/dh-importer.zip"
} }

View file

@ -241,7 +241,10 @@ export class DHImporter {
// Ranges: Melee, Very Close, Close, Far, Very Far // Ranges: Melee, Very Close, Close, Far, Very Far
const rangeMatch = rest.match(/^(Melee|Very Close|Close|Far|Very Far)/i); const rangeMatch = rest.match(/^(Melee|Very Close|Close|Far|Very Far)/i);
if (rangeMatch) { if (rangeMatch) {
data.system.attack.range = rangeMatch[1].toLowerCase(); let rangeVal = rangeMatch[1].toLowerCase();
if (rangeVal === "very close") rangeVal = "veryClose";
if (rangeVal === "very far") rangeVal = "veryFar";
data.system.attack.range = rangeVal;
rest = rest.substring(rangeMatch[0].length).trim(); rest = rest.substring(rangeMatch[0].length).trim();
} }
@ -260,7 +263,7 @@ export class DHImporter {
formula = dmgMatch[1]; formula = dmgMatch[1];
type = dmgMatch[2].toLowerCase(); type = dmgMatch[2].toLowerCase();
if (type === "phy") type = "physical"; if (type === "phy") type = "physical";
else if (type === "mag") type = "magic"; else if (type === "mag" || type === "magic") type = "magical";
} }
data.system.attack.damage.parts.push({ data.system.attack.damage.parts.push({
@ -324,7 +327,7 @@ export class DHImporter {
damage: { parts: [], includeBase: false, direct: false }, damage: { parts: [], includeBase: false, direct: false },
range: "", range: "",
roll: { roll: {
type: "action", // Default to action, switch to attack if detected type: "attack", // Default to attack
diceRolling: { multiplier: "flat", dice: "d6" } diceRolling: { multiplier: "flat", dice: "d6" }
} }
}; };
@ -361,7 +364,11 @@ export class DHImporter {
// Parse Range // Parse Range
const rangeMatch = buffer.description.match(/(Melee|Very Close|Close|Far|Very Far)/i); const rangeMatch = buffer.description.match(/(Melee|Very Close|Close|Far|Very Far)/i);
if (rangeMatch) { if (rangeMatch) {
action.range = rangeMatch[1].toLowerCase(); let rangeVal = rangeMatch[1].toLowerCase();
if (rangeVal === "very close") rangeVal = "veryClose";
if (rangeVal === "very far") rangeVal = "veryFar";
action.range = rangeVal;
} }
// Parse Damage: "deal 3d4+10 direct physical damage" // Parse Damage: "deal 3d4+10 direct physical damage"
@ -376,7 +383,7 @@ export class DHImporter {
// Map short codes // Map short codes
if (type === "phy") type = "physical"; if (type === "phy") type = "physical";
else if (type === "mag") type = "magic"; else if (type === "mag" || type === "magic") type = "magical";
action.damage.direct = isDirect; action.damage.direct = isDirect;
action.damage.parts.push({ action.damage.parts.push({