diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 28dee15..0d1e4bf 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -56,7 +56,7 @@ export class BladesActorSheet extends ActorSheet { html.find('.item-delete').click(ev => { const element = $(ev.currentTarget).parents(".item"); this.actor.deleteOwnedItem(element.data("itemId")); - li.slideUp(200, () => this.render(false)); + element.slideUp(200, () => this.render(false)); }); } @@ -162,34 +162,62 @@ export class BladesActorSheet extends ActorSheet { async _onDrop (event) { event.preventDefault(); - const actor = this.actor; // Get dropped data let data; + let item; try { data = JSON.parse(event.dataTransfer.getData('text/plain')); } catch (err) { return false; } + // Add only Items. if (data.type === "Item") { - // Class must be distinct. - let item = game.items.get(data.id); - if (item.data.type === "class") { - actor.items.forEach(i => { - if (i.data.type === "class") { - actor.deleteOwnedItem(i.id); - } + // Import from Compendium + if (data.pack) { + const pack = game.packs.find(p => p.collection === data.pack); + await pack.getEntity(data.id).then(ent => { + item = ent; }); } + // Get from Items list. + else { + // Class must be distinct. + item = game.items.get(data.id); + } + + if (item) { + this._removeDuplicatedItemType(item.data.type); + } + + // Call parent on drop logic + return super._onDrop(event); } - // Call parent on drop logic - return super._onDrop(event); } /* -------------------------------------------- */ + /** + * Removes a duplicate item type from charlist. + * + * @param {string} item_type + */ + _removeDuplicatedItemType(item_type) { + const actor = this.actor; + let distinct_types = ["class", "heritage", "background", "vice"]; + + if (distinct_types.indexOf(item_type) >= 0) { + actor.items.forEach(i => { + if (i.data.type === item_type) { + actor.deleteOwnedItem(i.id); + } + }); + } + } + + /* -------------------------------------------- */ } diff --git a/module/item-sheet.js b/module/item-sheet.js index aa66950..51fa886 100644 --- a/module/item-sheet.js +++ b/module/item-sheet.js @@ -18,7 +18,7 @@ export class BladesItemSheet extends ItemSheet { /** @override */ get template() { - const path = "systems/blades-in-the-dark/templates/items/"; + const path = "systems/blades-in-the-dark/templates/items"; return `${path}/${this.item.data.type}.html`; } diff --git a/packs/backgrounds.db b/packs/backgrounds.db new file mode 100644 index 0000000..878ac56 --- /dev/null +++ b/packs/backgrounds.db @@ -0,0 +1,7 @@ +{"_id":"7q2RhjaBzYBoWmMa","name":"Law","permission":{"default":0},"type":"background","data":{"description":""},"folder":"YkuVHwuSV9IfsxU0","sort":300000,"flags":{}} +{"_id":"7zLXN88TgLkP0JlK","name":"Noble","permission":{"default":0},"type":"background","data":{"description":""},"folder":"YkuVHwuSV9IfsxU0","sort":600000,"flags":{}} +{"_id":"8bDf9RzcGeNz48Kp","name":"Underworld","permission":{"default":0},"type":"background","data":{"description":""},"folder":"YkuVHwuSV9IfsxU0","sort":700000,"flags":{}} +{"_id":"S1CvKYfGwHFq9yxR","name":"Trade","permission":{"default":0},"type":"background","data":{"description":""},"folder":"YkuVHwuSV9IfsxU0","sort":400000,"flags":{}} +{"_id":"ZplBgIXHxWLUXX1o","name":"Academic","permission":{"default":0},"type":"background","data":{"description":""},"folder":"YkuVHwuSV9IfsxU0","sort":100000,"flags":{}} +{"_id":"ex7Mqv42SKZrfUL0","name":"Military","permission":{"default":0},"type":"background","data":{"description":""},"folder":"YkuVHwuSV9IfsxU0","sort":500000,"flags":{}} +{"_id":"qGkgWsdxcnl0cFhm","name":"Labor","permission":{"default":0},"type":"background","data":{"description":""},"folder":"YkuVHwuSV9IfsxU0","sort":200000,"flags":{}} diff --git a/packs/classes.db b/packs/classes.db new file mode 100644 index 0000000..a78b877 --- /dev/null +++ b/packs/classes.db @@ -0,0 +1,8 @@ +{"_id":"8jExf4Zqad6e3bvn","name":"Leech","permission":{"default":0},"type":"class","data":{"description":"","base_skills":{"hunt":[0],"study":[0],"survey":[0],"tinker":[0],"finesse":[0],"prowl":[0],"skirmish":[0],"wreck":[0],"attune":[0],"command":[0],"consort":[0],"sway":[0]},"class_items":[]},"folder":"Q5shG4toM5PkRSnX","sort":400000,"flags":{}} +{"_id":"CAHfNrPDJZKVNMrH","name":"Lurk","permission":{"default":0},"type":"class","data":{"description":"","base_skills":{"hunt":[0],"study":[0],"survey":[0],"tinker":[0],"finesse":[0],"prowl":[0],"skirmish":[0],"wreck":[0],"attune":[0],"command":[0],"consort":[0],"sway":[0]},"class_items":[]},"folder":"Q5shG4toM5PkRSnX","sort":500000,"flags":{}} +{"_id":"JGxBjlbooxuUHe4E","name":"Hound","permission":{"default":0},"type":"class","data":{"description":"","base_skills":{"hunt":[0],"study":[0],"survey":[0],"tinker":[0],"finesse":[0],"prowl":[0],"skirmish":[0],"wreck":[0],"attune":[0],"command":[0],"consort":[0],"sway":[0]}},"folder":"Q5shG4toM5PkRSnX","sort":100000,"flags":{}} +{"_id":"OKRtWdhpwIAdX3RS","name":"Itemko","permission":{"default":0},"type":"item","data":{"class_restriction":"","load":0,"description":""},"folder":"3Rl8reBeGom1vbie","sort":100000,"flags":{}} +{"_id":"P6LMZBrG5U9eCjhX","name":"Spider","permission":{"default":0},"type":"class","data":{"description":"","base_skills":{"hunt":[0],"study":[0],"survey":[0],"tinker":[0],"finesse":[0],"prowl":[0],"skirmish":[0],"wreck":[0],"attune":[0],"command":[0],"consort":[0],"sway":[0]},"class_items":[]},"folder":"Q5shG4toM5PkRSnX","sort":700000,"flags":{}} +{"_id":"YUGDdyADj0PTBVcP","name":"Slide","permission":{"default":0},"type":"class","data":{"description":"","base_skills":{"hunt":[0],"study":[0],"survey":[0],"tinker":[0],"finesse":[0],"prowl":[0],"skirmish":[0],"wreck":[0],"attune":[0],"command":[0],"consort":[0],"sway":[0]},"class_items":[]},"folder":"Q5shG4toM5PkRSnX","sort":600000,"flags":{}} +{"_id":"tEob41rtEbHcswNM","name":"Cutter","permission":{"default":0},"type":"class","data":{"description":"","base_skills":{"hunt":[0],"study":[0],"survey":[0],"tinker":[0],"finesse":[0],"prowl":[0],"skirmish":[0],"wreck":[0],"attune":[0],"command":[0],"consort":[0],"sway":[0]},"class_items":[]},"folder":"Q5shG4toM5PkRSnX","sort":300000,"flags":{}} +{"_id":"zOg14xy8ZEku6bNq","name":"Whisper","permission":{"default":0},"type":"class","data":{"description":"","base_skills":{"hunt":[0],"study":[0],"survey":[0],"tinker":[0],"finesse":[0],"prowl":[0],"skirmish":[0],"wreck":[0],"attune":[0],"command":[0],"consort":[0],"sway":[0]},"class_items":[]},"folder":"Q5shG4toM5PkRSnX","sort":200000,"flags":{}} \ No newline at end of file diff --git a/packs/heritages.db b/packs/heritages.db new file mode 100644 index 0000000..77383ea --- /dev/null +++ b/packs/heritages.db @@ -0,0 +1,6 @@ +{"_id":"ANBgWHbSQVgUQecV","name":"Iruvia","permission":{"default":0},"type":"heritage","data":{"description":""},"folder":"2TX8ibE6E4CDUGYX","sort":300000,"flags":{}} +{"_id":"RrvbKXClyyNBYFBB","name":"Severos","permission":{"default":0},"type":"heritage","data":{"description":""},"folder":"2TX8ibE6E4CDUGYX","sort":400000,"flags":{}} +{"_id":"TiL4AssY9Ryty6f9","name":"The Dagger Isles","permission":{"default":0},"type":"heritage","data":{"description":""},"folder":"2TX8ibE6E4CDUGYX","sort":200000,"flags":{}} +{"_id":"Tk61Y7K84GgQpqPz","name":"Skovlan","permission":{"default":0},"type":"heritage","data":{"description":""},"folder":"2TX8ibE6E4CDUGYX","sort":500000,"flags":{}} +{"_id":"WRzLNozCfzFLg0d6","name":"Tycheros","permission":{"default":0},"type":"heritage","data":{"description":""},"folder":"2TX8ibE6E4CDUGYX","sort":600000,"flags":{}} +{"_id":"fKEJOkqoAwinyzrm","name":"Akoros","permission":{"default":0},"type":"heritage","data":{"description":""},"folder":"2TX8ibE6E4CDUGYX","sort":100000,"flags":{}} \ No newline at end of file diff --git a/packs/items.db b/packs/items.db index 0123945..75406f2 100644 --- a/packs/items.db +++ b/packs/items.db @@ -1 +1,28 @@ -{"_id":"tXgoknEdkgZrDOiI","name":"Test item","permission":{"default":0},"type":"base","data":{},"folder":null,"sort":100001,"flags":{}} +{"_id":"0GbyUKjjMof6D8fb","name":"Faith","permission":{"default":0},"type":"vice","data":{"description":""},"folder":"Jz1yD35kaDA2NZtZ","sort":100000,"flags":{}} +{"_id":"43dWmFJgAeqcsOJl","name":"Pleasure","permission":{"default":0},"type":"vice","data":{"description":""},"folder":"Jz1yD35kaDA2NZtZ","sort":500000,"flags":{}} +{"_id":"7q2RhjaBzYBoWmMa","name":"Law","permission":{"default":0},"type":"background","data":{"description":""},"folder":"YkuVHwuSV9IfsxU0","sort":300000,"flags":{}} +{"_id":"7zLXN88TgLkP0JlK","name":"Noble","permission":{"default":0},"type":"background","data":{"description":""},"folder":"YkuVHwuSV9IfsxU0","sort":600000,"flags":{}} +{"_id":"8bDf9RzcGeNz48Kp","name":"Underworld","permission":{"default":0},"type":"background","data":{"description":""},"folder":"YkuVHwuSV9IfsxU0","sort":700000,"flags":{}} +{"_id":"8jExf4Zqad6e3bvn","name":"Leech","permission":{"default":0},"type":"class","data":{"description":"","base_skills":{"hunt":[0],"study":[0],"survey":[0],"tinker":[0],"finesse":[0],"prowl":[0],"skirmish":[0],"wreck":[0],"attune":[0],"command":[0],"consort":[0],"sway":[0]},"class_items":[]},"folder":"Q5shG4toM5PkRSnX","sort":400000,"flags":{}} +{"_id":"ANBgWHbSQVgUQecV","name":"Iruvia","permission":{"default":0},"type":"heritage","data":{"description":""},"folder":"2TX8ibE6E4CDUGYX","sort":300000,"flags":{}} +{"_id":"CAHfNrPDJZKVNMrH","name":"Lurk","permission":{"default":0},"type":"class","data":{"description":"","base_skills":{"hunt":[0],"study":[0],"survey":[0],"tinker":[0],"finesse":[0],"prowl":[0],"skirmish":[0],"wreck":[0],"attune":[0],"command":[0],"consort":[0],"sway":[0]},"class_items":[]},"folder":"Q5shG4toM5PkRSnX","sort":500000,"flags":{}} +{"_id":"JGxBjlbooxuUHe4E","name":"Hound","permission":{"default":0},"type":"class","data":{"description":"","base_skills":{"hunt":[0],"study":[0],"survey":[0],"tinker":[0],"finesse":[0],"prowl":[0],"skirmish":[0],"wreck":[0],"attune":[0],"command":[0],"consort":[0],"sway":[0]}},"folder":"Q5shG4toM5PkRSnX","sort":100000,"flags":{}} +{"_id":"Lp7ezgXB3USzviHa","name":"Obligation","permission":{"default":0},"type":"vice","data":{"description":""},"folder":"Jz1yD35kaDA2NZtZ","sort":400000,"flags":{}} +{"_id":"OKRtWdhpwIAdX3RS","name":"Itemko","permission":{"default":0},"type":"item","data":{"class_restriction":"","load":0,"description":""},"folder":"3Rl8reBeGom1vbie","sort":100000,"flags":{}} +{"_id":"P6LMZBrG5U9eCjhX","name":"Spider","permission":{"default":0},"type":"class","data":{"description":"","base_skills":{"hunt":[0],"study":[0],"survey":[0],"tinker":[0],"finesse":[0],"prowl":[0],"skirmish":[0],"wreck":[0],"attune":[0],"command":[0],"consort":[0],"sway":[0]},"class_items":[]},"folder":"Q5shG4toM5PkRSnX","sort":700000,"flags":{}} +{"_id":"PJ4m6YEsMEzfgAqy","name":"Weird","permission":{"default":0},"type":"vice","data":{"description":""},"folder":"Jz1yD35kaDA2NZtZ","sort":700000,"flags":{}} +{"_id":"RrvbKXClyyNBYFBB","name":"Severos","permission":{"default":0},"type":"heritage","data":{"description":""},"folder":"2TX8ibE6E4CDUGYX","sort":400000,"flags":{}} +{"_id":"S1CvKYfGwHFq9yxR","name":"Trade","permission":{"default":0},"type":"background","data":{"description":""},"folder":"YkuVHwuSV9IfsxU0","sort":400000,"flags":{}} +{"_id":"TiL4AssY9Ryty6f9","name":"The Dagger Isles","permission":{"default":0},"type":"heritage","data":{"description":""},"folder":"2TX8ibE6E4CDUGYX","sort":200000,"flags":{}} +{"_id":"Tk61Y7K84GgQpqPz","name":"Skovlan","permission":{"default":0},"type":"heritage","data":{"description":""},"folder":"2TX8ibE6E4CDUGYX","sort":500000,"flags":{}} +{"_id":"VNt88GVp0Td0Q8H6","name":"Luxury","permission":{"default":0},"type":"vice","data":{"description":""},"folder":"Jz1yD35kaDA2NZtZ","sort":300000,"flags":{}} +{"_id":"WRzLNozCfzFLg0d6","name":"Tycheros","permission":{"default":0},"type":"heritage","data":{"description":""},"folder":"2TX8ibE6E4CDUGYX","sort":600000,"flags":{}} +{"_id":"Y0aq94hQO9LyMJN9","name":"Stupor","permission":{"default":0},"type":"vice","data":{"description":""},"folder":"Jz1yD35kaDA2NZtZ","sort":600000,"flags":{}} +{"_id":"YUGDdyADj0PTBVcP","name":"Slide","permission":{"default":0},"type":"class","data":{"description":"","base_skills":{"hunt":[0],"study":[0],"survey":[0],"tinker":[0],"finesse":[0],"prowl":[0],"skirmish":[0],"wreck":[0],"attune":[0],"command":[0],"consort":[0],"sway":[0]},"class_items":[]},"folder":"Q5shG4toM5PkRSnX","sort":600000,"flags":{}} +{"_id":"ZplBgIXHxWLUXX1o","name":"Academic","permission":{"default":0},"type":"background","data":{"description":""},"folder":"YkuVHwuSV9IfsxU0","sort":100000,"flags":{}} +{"_id":"ex7Mqv42SKZrfUL0","name":"Military","permission":{"default":0},"type":"background","data":{"description":""},"folder":"YkuVHwuSV9IfsxU0","sort":500000,"flags":{}} +{"_id":"fKEJOkqoAwinyzrm","name":"Akoros","permission":{"default":0},"type":"heritage","data":{"description":""},"folder":"2TX8ibE6E4CDUGYX","sort":100000,"flags":{}} +{"_id":"qGkgWsdxcnl0cFhm","name":"Labor","permission":{"default":0},"type":"background","data":{"description":""},"folder":"YkuVHwuSV9IfsxU0","sort":200000,"flags":{}} +{"_id":"tEob41rtEbHcswNM","name":"Cutter","permission":{"default":0},"type":"class","data":{"description":"","base_skills":{"hunt":[0],"study":[0],"survey":[0],"tinker":[0],"finesse":[0],"prowl":[0],"skirmish":[0],"wreck":[0],"attune":[0],"command":[0],"consort":[0],"sway":[0]},"class_items":[]},"folder":"Q5shG4toM5PkRSnX","sort":300000,"flags":{}} +{"_id":"ueBoUHFBMHlCowB0","name":"Gambling","permission":{"default":0},"type":"vice","data":{"description":""},"folder":"Jz1yD35kaDA2NZtZ","sort":200000,"flags":{}} +{"_id":"zOg14xy8ZEku6bNq","name":"Whisper","permission":{"default":0},"type":"class","data":{"description":"","base_skills":{"hunt":[0],"study":[0],"survey":[0],"tinker":[0],"finesse":[0],"prowl":[0],"skirmish":[0],"wreck":[0],"attune":[0],"command":[0],"consort":[0],"sway":[0]},"class_items":[]},"folder":"Q5shG4toM5PkRSnX","sort":200000,"flags":{}} diff --git a/packs/vices.db b/packs/vices.db new file mode 100644 index 0000000..da5192d --- /dev/null +++ b/packs/vices.db @@ -0,0 +1,7 @@ +{"_id":"Lp7ezgXB3USzviHa","name":"Obligation","permission":{"default":0},"type":"vice","data":{"description":""},"folder":"Jz1yD35kaDA2NZtZ","sort":400000,"flags":{}} +{"_id":"PJ4m6YEsMEzfgAqy","name":"Weird","permission":{"default":0},"type":"vice","data":{"description":""},"folder":"Jz1yD35kaDA2NZtZ","sort":700000,"flags":{}} +{"_id":"VNt88GVp0Td0Q8H6","name":"Luxury","permission":{"default":0},"type":"vice","data":{"description":""},"folder":"Jz1yD35kaDA2NZtZ","sort":300000,"flags":{}} +{"_id":"Y0aq94hQO9LyMJN9","name":"Stupor","permission":{"default":0},"type":"vice","data":{"description":""},"folder":"Jz1yD35kaDA2NZtZ","sort":600000,"flags":{}} +{"_id":"ueBoUHFBMHlCowB0","name":"Gambling","permission":{"default":0},"type":"vice","data":{"description":""},"folder":"Jz1yD35kaDA2NZtZ","sort":200000,"flags":{}} +{"_id":"43dWmFJgAeqcsOJl","name":"Pleasure","permission":{"default":0},"type":"vice","data":{"description":""},"folder":"Jz1yD35kaDA2NZtZ","sort":500000,"flags":{}} +{"_id":"0GbyUKjjMof6D8fb","name":"Faith","permission":{"default":0},"type":"vice","data":{"description":""},"folder":"Jz1yD35kaDA2NZtZ","sort":100000,"flags":{}} \ No newline at end of file diff --git a/system.json b/system.json index f2e6d5c..f447e0b 100644 --- a/system.json +++ b/system.json @@ -9,10 +9,39 @@ "author": "megastruktur", "esmodules": ["module/blades.js"], "styles": ["styles/blades.css"], - "packs": [], - "languages": [], + "languages": ["en"], "gridDistance": 1, "gridUnits": "m", "primaryTokenAttribute": null, - "secondaryTokenAttribute": null + "secondaryTokenAttribute": null, + "packs": [ + { + "name": "Classes", + "label": "Classes", + "system": "blades-in-the-dark", + "path": "./packs/classes.db", + "entity": "Item" + }, + { + "name": "Heritages", + "label": "Heritages", + "system": "blades-in-the-dark", + "path": "./packs/heritages.db", + "entity": "Item" + }, + { + "name": "Vices", + "label": "Vices", + "system": "blades-in-the-dark", + "path": "./packs/vices.db", + "entity": "Item" + }, + { + "name": "Backgrounds", + "label": "Backgrounds", + "system": "blades-in-the-dark", + "path": "./packs/backgrounds.db", + "entity": "Item" + } +] } diff --git a/template.json b/template.json index 41c284a..59a2a31 100644 --- a/template.json +++ b/template.json @@ -3,9 +3,6 @@ "types": ["character", "crew"], "character": { "alias": "", - "heritage": "", - "background": "", - "vice": "", "stress": [0], "traumas": [], "healing-clock": [0], @@ -63,92 +60,6 @@ } } }, - "heritages": { - "akoros": { - "label": "Akoros", - "dtype": "String" - }, - "the-dagger-isles": { - "label": "The Dagger Isles", - "dtype": "String" - }, - "iruvia": { - "label": "Iruvia", - "dtype": "String" - }, - "severos": { - "label": "Severos", - "dtype": "String" - }, - "skovlan": { - "label": "Skovlan", - "dtype": "String" - }, - "tycheros": { - "label": "Tycheros", - "dtype": "String" - } - }, - "backgrounds": { - "academic": { - "label": "Academic", - "dtype": "String" - }, - "labor": { - "label": "Labor", - "dtype": "String" - }, - "law": { - "label": "Law", - "dtype": "String" - }, - "trade": { - "label": "Trade", - "dtype": "String" - }, - "military": { - "label": "Military", - "dtype": "String" - }, - "noble": { - "label": "Noble", - "dtype": "String" - }, - "underworld": { - "label": "Underworld", - "dtype": "String" - } - }, - "vices": { - "faith": { - "label": "Faith", - "dtype": "String" - }, - "gambling": { - "label": "Gambling", - "dtype": "String" - }, - "luxury": { - "label": "Luxury", - "dtype": "String" - }, - "obligation": { - "label": "Obligation", - "dtype": "String" - }, - "pleasure": { - "label": "Pleasure", - "dtype": "String" - }, - "stupor": { - "label": "Stupor", - "dtype": "String" - }, - "weird": { - "label": "Weird", - "dtype": "String" - } - }, "classes": { "cutter": { "skills": { @@ -196,7 +107,7 @@ } }, "Item": { - "types": ["item", "class", "ability", "heritages", "backgrounds", "vices"], + "types": ["item", "class", "ability", "heritage", "background", "vice"], "item": { "class_restriction": "", "load": 0, @@ -223,6 +134,15 @@ "ability": { "class": "", "description": "" + }, + "heritage": { + "description": "" + }, + "background": { + "description": "" + }, + "vice": { + "description": "" } } } diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index ce00e21..cb224be 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -1,52 +1,28 @@