From 1ec8ee6451dac6fb37850d0e9b8942607d92512f Mon Sep 17 00:00:00 2001 From: sladecraven Date: Wed, 9 Nov 2022 20:09:50 +0100 Subject: [PATCH] Module stuff and fixes on other items --- lang/en.json | 8 +- modules/avd12-item-sheet.js | 101 ++++++++++++++++-- modules/avd12-utility.js | 4 + styles/simple.css | 7 ++ system.json | 8 +- template.json | 38 ++++++- templates/items/item-action-sheet.hbs | 30 ++++++ templates/items/item-freeaction-sheet.hbs | 30 ++++++ templates/items/item-module-sheet.hbs | 25 +++++ templates/items/item-reaction-sheet.hbs | 31 ++++++ templates/items/item-stance-sheet.hbs | 31 ++++++ templates/items/item-trait-sheet.hbs | 58 ++++++++++ .../items/partial-common-item-fields.hbs | 27 +++++ .../items/partial-options-focus-bond.hbs | 8 ++ .../items/partial-options-focus-core.hbs | 9 ++ .../items/partial-options-focus-treatment.hbs | 9 ++ .../items/partial-options-weapon-types.hbs | 1 + 17 files changed, 408 insertions(+), 17 deletions(-) create mode 100644 templates/items/item-action-sheet.hbs create mode 100644 templates/items/item-freeaction-sheet.hbs create mode 100644 templates/items/item-reaction-sheet.hbs create mode 100644 templates/items/item-stance-sheet.hbs create mode 100644 templates/items/item-trait-sheet.hbs create mode 100644 templates/items/partial-options-focus-bond.hbs create mode 100644 templates/items/partial-options-focus-core.hbs create mode 100644 templates/items/partial-options-focus-treatment.hbs diff --git a/lang/en.json b/lang/en.json index 65be28e..6a772b5 100644 --- a/lang/en.json +++ b/lang/en.json @@ -11,6 +11,12 @@ "TypeSpell": "Spell", "TypeModule": "Module", "TypeMoney": "Money", - "TypeEquipment": "Equipment" + "TypeEquipment": "Equipment", + "TypeAction": "Action", + "TypeFreeaction": "Free Action", + "TypeReaction": "Reaction", + "TypeStance": "Stance", + "TypeTrait": "Trait", + "TypeCondition": "Condition" } } \ No newline at end of file diff --git a/modules/avd12-item-sheet.js b/modules/avd12-item-sheet.js index e272981..bb78e88 100644 --- a/modules/avd12-item-sheet.js +++ b/modules/avd12-item-sheet.js @@ -1,5 +1,7 @@ import { Avd12Utility } from "./avd12-utility.js"; +const __ALLOWED_MODULE_TYPES = { "action": 1, "reaction": 1, "freeaction": 1, "trait": 1 } + /** * Extend the basic ItemSheet with some very simple modifications * @extends {ItemSheet} @@ -15,7 +17,7 @@ export class Avd12ItemSheet extends ItemSheet { dragDrop: [{ dragSelector: null, dropSelector: null }], width: 620, height: 550, - tabs: [{navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description"}] + tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description" }] }); } @@ -48,7 +50,16 @@ export class Avd12ItemSheet extends ItemSheet { /* -------------------------------------------- */ async getData() { - + + // Specific case for formating descriptions of sub-items + if (this.object.type == "module") { + for (let level of this.object.system.levels) { + for (let id in level.features) { + level.features[id].descriptionHTML = await TextEditor.enrichHTML(level.features[id].system.description, { async: true }) + } + } + } + let formData = { title: this.title, id: this.id, @@ -61,6 +72,7 @@ export class Avd12ItemSheet extends ItemSheet { limited: this.object.limited, options: this.options, owner: this.document.isOwner, + description: await TextEditor.enrichHTML(this.object.system.description, { async: true }), isGM: game.user.isGM } @@ -104,6 +116,58 @@ export class Avd12ItemSheet extends ItemSheet { }); } + /* -------------------------------------------- */ + async _onDrop(event) { + + const levelIndex = Number($(event.toElement).data("level-index")) + let data = event.dataTransfer.getData('text/plain') + let dataItem = JSON.parse(data) + let item = fromUuidSync(dataItem.uuid) + if (item.pack) { + item = await Avd12Utility.searchItem(item) + } + if (!item) { + ui.notifications.warn("Unable to find relevant item - Aborting drag&drop " + data.uuid) + return + } + if (this.object.type == "module" && __ALLOWED_MODULE_TYPES[item.type]) { + let levels = duplicate(this.object.system.levels) + levels[levelIndex].features[item.id] = duplicate(item) + this.object.update({ 'system.levels': levels }) + return + } + ui.notifications.warn("This item is not allowed dropped here") + } + + /* -------------------------------------------- */ + async viewSubitem(ev) { + let field = $(ev.currentTarget).data('type'); + let idx = Number($(ev.currentTarget).data('index')); + let itemData = this.object.system[field][idx]; + if (itemData.name != 'None') { + let spec = await Item.create(itemData, { temporary: true }); + spec.system.origin = "embeddedItem"; + new Avd12ItemSheet(spec).render(true); + } + } + + /* -------------------------------------------- */ + async deleteSubitem(ev) { + let field = $(ev.currentTarget).data('type'); + let idx = Number($(ev.currentTarget).data('index')); + let oldArray = this.object.system[field]; + let itemData = this.object.system[field][idx]; + if (itemData.name != 'None') { + let newArray = []; + for (var i = 0; i < oldArray.length; i++) { + if (i != idx) { + newArray.push(oldArray[i]); + } + } + this.object.update({ [`system.${field}`]: newArray }); + } + } + /* -------------------------------------------- */ /** @override */ activateListeners(html) { @@ -120,10 +184,6 @@ export class Avd12ItemSheet extends ItemSheet { item.sheet.render(true); }); - html.find('.delete-spec').click(ev => { - this.object.update({ "data.specialisation": [{ name: 'None' }] }); - }); - html.find('.delete-subitem').click(ev => { this.deleteSubitem(ev); }); @@ -139,14 +199,33 @@ export class Avd12ItemSheet extends ItemSheet { this.viewSubitem(ev); }); - html.find('.view-spec').click(ev => { - this.manageSpec(); - }); + html.find('.add-module-level').click(ev => { + let levels = duplicate(this.object.system.levels) + levels.push({ features: {} }) + this.object.update({ 'system.levels': levels }) + }) + html.find('.module-feature-delete').click(ev => { + let levels = duplicate(this.object.system.levels) + let levelIndex = Number($(ev.currentTarget).parents(".item").data("level-index")) + let featureId = $(ev.currentTarget).parents(".item").data("feature-id") + levels[levelIndex].features[featureId] = undefined + this.object.update({ 'system.levels': levels }) + }) + + html.find('.feature-level-selected').change(ev => { + let levels = duplicate(this.object.system.levels) + let levelIndex = Number($(ev.currentTarget).parents(".item").data("level-index")) + let featureId = $(ev.currentTarget).parents(".item").data("feature-id") + for (let id in levels[levelIndex].features) { + let feature = levels[levelIndex].features[id] + feature.system.selected = false // Everybody to false + } + levels[levelIndex].features[featureId].system.selected = ev.currentTarget.value + this.object.update({ 'system.levels': levels }) + }) } - - /* -------------------------------------------- */ get template() { let type = this.item.type; diff --git a/modules/avd12-utility.js b/modules/avd12-utility.js index 97cb834..0a014c9 100644 --- a/modules/avd12-utility.js +++ b/modules/avd12-utility.js @@ -133,6 +133,10 @@ export class Avd12Utility { 'systems/fvtt-avd12/templates/items/partial-options-attributes.hbs', 'systems/fvtt-avd12/templates/items/partial-options-equipment-types.hbs', 'systems/fvtt-avd12/templates/items/partial-options-spell-types.hbs', + 'systems/fvtt-avd12/templates/items/partial-options-spell-levels.hbs', + 'systems/fvtt-avd12/templates/items/partial-options-focus-bond.hbs', + 'systems/fvtt-avd12/templates/items/partial-options-focus-treatment.hbs', + 'systems/fvtt-avd12/templates/items/partial-options-focus-core.hbs', ] return loadTemplates(templatePaths); } diff --git a/styles/simple.css b/styles/simple.css index 34e0cd5..03bd6b3 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -1299,3 +1299,10 @@ ul, li { min-width:2rem; max-width: 2rem; } + +.drop-module-step { + background: linear-gradient(to bottom, #6c95b9fc 5%, #105177ab 100%); + background-color: #7d5d3b00; + border-radius: 3px; + border: 2px ridge #846109; +} diff --git a/system.json b/system.json index 6a319bc..127aab2 100644 --- a/system.json +++ b/system.json @@ -3,8 +3,8 @@ "esmodules": [ "modules/avd12-main.js" ], - "gridDistance": 5, - "gridUnits": "m", + "gridDistance": 1, + "gridUnits": "u", "languages": [ { "lang": "en", @@ -37,7 +37,7 @@ ], "title": "AnyVenture D12 RPG", "url": "https://www.uberwald.me/gitea/uberwald/fvtt-avd12", - "version": "10.0.0", - "download": "https://www.uberwald.me/gitea/public/fvtt-avd12/archive/fvtt-avd12-v10.0.0.zip", + "version": "10.0.1", + "download": "https://www.uberwald.me/gitea/public/fvtt-avd12/archive/fvtt-avd12-v10.0.1.zip", "background": "systems/fvtt-avd12/images/ui/avd12_welcome_page.webp" } \ No newline at end of file diff --git a/template.json b/template.json index d0b8e94..094b5ff 100644 --- a/template.json +++ b/template.json @@ -228,7 +228,12 @@ "weapon", "module", "money", - "condition" + "condition", + "action", + "freeaction", + "reaction", + "stance", + "trait" ], "templates": { "commonitem": { @@ -272,12 +277,42 @@ "value": 0 } }, + "focus": { + "isfocus": false, + "core": "", + "treatment": "", + "bond": "" + }, "weight": 0, "cost": 0, "health": 0, "movespeed": 0 } }, + "action": { + "selected": false, + "description": "" + }, + "reaction": { + "selected": false, + "description": "" + }, + "freeaction": { + "selected": false, + "description": "" + }, + "stance": { + "active": false, + "description": "" + }, + "trait": { + "traittype": "", + "computebonus": false, + "bonusdata": "", + "bonusvalue": 0, + "selected": false, + "description": "" + }, "skill": { "attribute": "", "value": 0, @@ -352,6 +387,7 @@ "description": "" }, "module": { + "levels": [], "description": "" }, "condition": { diff --git a/templates/items/item-action-sheet.hbs b/templates/items/item-action-sheet.hbs new file mode 100644 index 0000000..feeb0aa --- /dev/null +++ b/templates/items/item-action-sheet.hbs @@ -0,0 +1,30 @@ +
+
+ +
+

+
+
+ + {{> systems/fvtt-avd12/templates/items/partial-item-nav.hbs}} + + + {{!-- Sheet Body --}} +
+ + {{> systems/fvtt-avd12/templates/items/partial-item-description.hbs}} + +
+ +
+
    +
  • + + +
  • +
+
+
+ +
+
diff --git a/templates/items/item-freeaction-sheet.hbs b/templates/items/item-freeaction-sheet.hbs new file mode 100644 index 0000000..feeb0aa --- /dev/null +++ b/templates/items/item-freeaction-sheet.hbs @@ -0,0 +1,30 @@ +
+
+ +
+

+
+
+ + {{> systems/fvtt-avd12/templates/items/partial-item-nav.hbs}} + + + {{!-- Sheet Body --}} +
+ + {{> systems/fvtt-avd12/templates/items/partial-item-description.hbs}} + +
+ +
+
    +
  • + + +
  • +
+
+
+ +
+
diff --git a/templates/items/item-module-sheet.hbs b/templates/items/item-module-sheet.hbs index 5875d41..f29617c 100644 --- a/templates/items/item-module-sheet.hbs +++ b/templates/items/item-module-sheet.hbs @@ -18,9 +18,34 @@
+ diff --git a/templates/items/item-reaction-sheet.hbs b/templates/items/item-reaction-sheet.hbs new file mode 100644 index 0000000..91e9447 --- /dev/null +++ b/templates/items/item-reaction-sheet.hbs @@ -0,0 +1,31 @@ +
+
+ +
+

+
+
+ + {{> systems/fvtt-avd12/templates/items/partial-item-nav.hbs}} + + + {{!-- Sheet Body --}} +
+ + {{> systems/fvtt-avd12/templates/items/partial-item-description.hbs}} + +
+ +
+
    +
  • + + +
  • + +
+
+
+ +
+
diff --git a/templates/items/item-stance-sheet.hbs b/templates/items/item-stance-sheet.hbs new file mode 100644 index 0000000..8420b74 --- /dev/null +++ b/templates/items/item-stance-sheet.hbs @@ -0,0 +1,31 @@ +
+
+ +
+

+
+
+ + {{> systems/fvtt-avd12/templates/items/partial-item-nav.hbs}} + + + {{!-- Sheet Body --}} +
+ + {{> systems/fvtt-avd12/templates/items/partial-item-description.hbs}} + +
+ +
+
    +
  • + + +
  • + +
+
+
+ +
+
diff --git a/templates/items/item-trait-sheet.hbs b/templates/items/item-trait-sheet.hbs new file mode 100644 index 0000000..27286e4 --- /dev/null +++ b/templates/items/item-trait-sheet.hbs @@ -0,0 +1,58 @@ +
+
+ +
+

+
+
+ + {{> systems/fvtt-avd12/templates/items/partial-item-nav.hbs}} + + + {{!-- Sheet Body --}} +
+ + {{> systems/fvtt-avd12/templates/items/partial-item-description.hbs}} + +
+ +
+
    +
  • + + +
  • + + {{#if (eq system.traittype "traitbonus")}} +
  • + + +
  • + {{#if system.computebonus}} +
  • + + + +
  • +
  • + + +
  • + {{/if}} + {{/if}} + +
  • + + +
  • +
+
+
+ +
+
diff --git a/templates/items/partial-common-item-fields.hbs b/templates/items/partial-common-item-fields.hbs index 65098d9..7c76da9 100644 --- a/templates/items/partial-common-item-fields.hbs +++ b/templates/items/partial-common-item-fields.hbs @@ -91,6 +91,33 @@ {{/each}} +
  • +

    + Focus +

    + +
  • + + {{#if system.focus.isfocus}} +
  • + + + +
  • +{{/if}} +
  • Various diff --git a/templates/items/partial-options-focus-bond.hbs b/templates/items/partial-options-focus-bond.hbs new file mode 100644 index 0000000..74cf7cb --- /dev/null +++ b/templates/items/partial-options-focus-bond.hbs @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/templates/items/partial-options-focus-core.hbs b/templates/items/partial-options-focus-core.hbs new file mode 100644 index 0000000..9ec1707 --- /dev/null +++ b/templates/items/partial-options-focus-core.hbs @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/templates/items/partial-options-focus-treatment.hbs b/templates/items/partial-options-focus-treatment.hbs new file mode 100644 index 0000000..cfa22a7 --- /dev/null +++ b/templates/items/partial-options-focus-treatment.hbs @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/templates/items/partial-options-weapon-types.hbs b/templates/items/partial-options-weapon-types.hbs index 6abdf62..0116e0d 100644 --- a/templates/items/partial-options-weapon-types.hbs +++ b/templates/items/partial-options-weapon-types.hbs @@ -1,3 +1,4 @@ +