From 3e9bc42ca443f8fb86b9cea4f54421fa3c8d9292 Mon Sep 17 00:00:00 2001 From: CPTN Cosmo Date: Sat, 24 Jan 2026 12:02:46 +0100 Subject: [PATCH] Going back to the input from the preview no longer empties the textfield, allowing for easier edits before importing --- module.json | 4 ++-- scripts/app.js | 7 ++++++- scripts/importer.js | 12 ++++++++++-- templates/importer.hbs | 2 +- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/module.json b/module.json index 7c240de..90458b6 100644 --- a/module.json +++ b/module.json @@ -1,7 +1,7 @@ { "id": "dh-importer", "title": "Daggerheart Statblock Importer", - "version": "1.1.1", + "version": "1.2.0", "compatibility": { "minimum": "13", "verified": "13" @@ -34,5 +34,5 @@ "description": "Imports Adversaries and Environments from text blocks into the Daggerheart system.", "url": "https://github.com/cptn-cosmo/dh-importer", "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.1/dh-importer.zip" + "download": "https://git.geeks.gay/cosmo/dh-importer/releases/download/1.2.0/dh-importer.zip" } \ No newline at end of file diff --git a/scripts/app.js b/scripts/app.js index dd72686..2d30b66 100644 --- a/scripts/app.js +++ b/scripts/app.js @@ -8,6 +8,7 @@ export class DHImporterApp extends HandlebarsApplicationMixin(ApplicationV2) { this.step = "input"; this.parsedData = null; this.parsedDataType = null; + this.inputText = ""; } static DEFAULT_OPTIONS = { @@ -45,7 +46,8 @@ export class DHImporterApp extends HandlebarsApplicationMixin(ApplicationV2) { types: { adversary: "Adversary", environment: "Environment" - } + }, + inputText: this.inputText }; } @@ -75,6 +77,9 @@ export class DHImporterApp extends HandlebarsApplicationMixin(ApplicationV2) { const text = form.querySelector("textarea[name='text']").value; const type = form.querySelector("select[name='type']").value; + // Store input text + this.inputText = text; + if (!text) { ui.notifications.warn("Please enter text to import."); return; diff --git a/scripts/importer.js b/scripts/importer.js index 2ad4f3b..1500f3c 100644 --- a/scripts/importer.js +++ b/scripts/importer.js @@ -314,10 +314,18 @@ export class DHImporter { }; if (isAction) { + // Determine if this is an attack or a generic ability + const isAttack = buffer.description.match(/make.*?attack/i) || + buffer.description.match(/(?:deal|inflict|take)\s+(\d+(?:d\d+)?(?:[\s]*[\+\-][\s]*\d+)?)\s+(direct\s+)?(\w+)\s+damage/i); + + const actionType = isAttack ? "attack" : "ability"; + const rollType = isAttack ? "attack" : "ability"; + const actionId = foundry.utils.randomID(); + const action = { _id: actionId, - type: "attack", + type: actionType, name: buffer.name, actionType: "action", img: "icons/svg/item-bag.svg", @@ -327,7 +335,7 @@ export class DHImporter { damage: { parts: [], includeBase: false, direct: false }, range: "", roll: { - type: "attack", // Default to attack + type: rollType, diceRolling: { multiplier: "flat", dice: "d6" } } }; diff --git a/templates/importer.hbs b/templates/importer.hbs index 833799c..4ad3828 100644 --- a/templates/importer.hbs +++ b/templates/importer.hbs @@ -13,7 +13,7 @@
- +