From 786ffc14a42c960cfd25727cd813ac5e409382fa Mon Sep 17 00:00:00 2001 From: agaringer Date: Fri, 2 Jun 2023 18:09:41 -0400 Subject: [PATCH] v2.1.7 release --- CHANGELOG.txt | 2 ++ packs/macros.db | 2 +- system.json | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 5e8b753..b03f7e9 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -209,3 +209,5 @@ v1.9.4 Fix Trauma tooltip z-indexing 2.1.5 Fix ship assignment to characters 2.1.6 Default Map Notes Visibility to true, V11 compatibility + +2.1.7 Fix to Jobs macro folder code (reimport to use) diff --git a/packs/macros.db b/packs/macros.db index 72e914d..f5a102c 100644 --- a/packs/macros.db +++ b/packs/macros.db @@ -1,2 +1,2 @@ -{"name":"Jobs","type":"script","author":"FIR7wPEGx1wVISuV","img":"icons/environment/people/commoner.webp","scope":"global","command":"/* - v1.1\nSource: brunocalado\nIcon: icons/environment/people/commoner.webp\n*/\n\n(async () => {\n const faction1 = await drawFromTable('Factions');\n const faction2 = await drawFromTable('Factions');\n const client = await drawFromTable('Client / Target');\n const target = await drawFromTable('Client / Target');\n const twist = await drawFromTable('Twist');\n const place = await drawFromTable('Job Location');\n const task = await drawFromTable('Work');\n const connection = await drawFromTable('Connection');\n\n let msg = `

Job

`;\n msg += ``;\n\n let message=msg;\n let msgId = randomID();\n\n let data = {\n name: `${task}`,\n content: msg\n }; \n \n message+=``;\n\n let chatData = {\n content: message,\n whisper : ChatMessage.getWhisperRecipients(\"GM\")\n }; \n ChatMessage.create(chatData, {}); \n \n addEventListenerOnHtmlElement(\"#createJob-\" + msgId, 'click', (e) => {\n createJob(data); \n });\n})()\n\n/* Functions */\nasync function drawFromTable(tableName) {\n\n let roll_compendiums;\n let job_compendiums;\n roll_compendiums = game.packs.filter( p => p.documentName === 'RollTable');\n job_compendiums = await roll_compendiums.filter( p => p.metadata.label === 'Job Tables' )[0].getDocuments();\n const table = await job_compendiums.filter( p=> p.name === tableName )[0]; \n \n if (!table) {\n ui.notifications.warn(`Table ${tableName} not found.`, {});\n return;\n }\n const output = await table.roll();\n const result = output.results[0].text;\n return result; \n}\n\nfunction addEventListenerOnHtmlElement(element, event, func){ \n Hooks.on(\"renderChatMessage\", (chatItem, html, data) => {\n if( html[0].querySelector(element) !== null ) {\n html[0].querySelector(element).addEventListener(event, func);\n }\n });\n}\n\nasync function createJob(data) {\n\n let folder;\n if( game.folders.find( f => f.name === \"Job Ideas\") === undefined ) {\n folder = await Folder.create( {\n name: \"Job Ideas\",\n type: \"JournalEntry\"\n } );\n } else {\n folder = game.folders.find( f => f.name === \"Job Ideas\");\n }\n folder = folder;\n\n const instantAdventure = await JournalEntry.create(data);\n await instantAdventure.sheet.render(true); \n}","folder":null,"sort":0,"flags":{"core":{"sourceId":"Macro.GVICe576rSbJ1REF"}},"_id":"oN7DpBJRIfOACpzL","ownership":{"default":0,"FIR7wPEGx1wVISuV":3},"_stats":{"systemId":"scum-and-villainy","systemVersion":"2.0.0","coreVersion":"10.270","createdTime":null,"modifiedTime":1655580822493,"lastModifiedBy":"FIR7wPEGx1wVISuV"}} +{"name":"Jobs","type":"script","author":"FIR7wPEGx1wVISuV","img":"icons/environment/people/commoner.webp","scope":"global","command":"/* - v1.1\nSource: brunocalado\nIcon: icons/environment/people/commoner.webp\n*/\n\n(async () => {\n const faction1 = await drawFromTable('Factions');\n const faction2 = await drawFromTable('Factions');\n const client = await drawFromTable('Client / Target');\n const target = await drawFromTable('Client / Target');\n const twist = await drawFromTable('Twist');\n const place = await drawFromTable('Job Location');\n const task = await drawFromTable('Work');\n const connection = await drawFromTable('Connection');\n\n let msg = `

Job

`;\n msg += ``;\n\n let message=msg;\n let msgId = randomID();\n\n let data = {\n name: `${task}`,\n content: msg\n }; \n \n message+=``;\n\n let chatData = {\n content: message,\n whisper : ChatMessage.getWhisperRecipients(\"GM\")\n }; \n ChatMessage.create(chatData, {}); \n \n addEventListenerOnHtmlElement(\"#createJob-\" + msgId, 'click', (e) => {\n createJob(data); \n });\n})()\n\n/* Functions */\nasync function drawFromTable(tableName) {\n\n let roll_compendiums;\n let job_compendiums;\n roll_compendiums = game.packs.filter( p => p.documentName === 'RollTable');\n job_compendiums = await roll_compendiums.filter( p => p.metadata.label === 'Job Tables' )[0].getDocuments();\n const table = await job_compendiums.filter( p=> p.name === tableName )[0]; \n \n if (!table) {\n ui.notifications.warn(`Table ${tableName} not found.`, {});\n return;\n }\n const output = await table.roll();\n const result = output.results[0].text;\n return result; \n}\n\nfunction addEventListenerOnHtmlElement(element, event, func){ \n Hooks.on(\"renderChatMessage\", (chatItem, html, data) => {\n if( html[0].querySelector(element) !== null ) {\n html[0].querySelector(element).addEventListener(event, func);\n }\n });\n}\n\nasync function createJob(data) {\n\n let folder;\n if( game.folders.find( f => f.name === \"Job Ideas\") === undefined ) {\n folder = await Folder.create( {\n name: \"Job Ideas\",\n type: \"JournalEntry\"\n } );\n } else {\n folder = game.folders.find( f => f.name === \"Job Ideas\");\n }\n data.folder = folder;\n\n const instantAdventure = await JournalEntry.create(data);\n await instantAdventure.sheet.render(true); \n}","folder":null,"sort":0,"flags":{"core":{"sourceId":"Macro.GVICe576rSbJ1REF"}},"_id":"oN7DpBJRIfOACpzL","ownership":{"default":0,"FIR7wPEGx1wVISuV":3},"_stats":{"systemId":"scum-and-villainy","systemVersion":"2.0.0","coreVersion":"10.270","createdTime":null,"modifiedTime":1655580822493,"lastModifiedBy":"FIR7wPEGx1wVISuV"}} {"name":"Change XP Bars","type":"script","author":"DndvQQR4KOtSK1iV","img":"icons/sundries/misc/lock-open-yellow.webp","scope":"global","command":"const version = '1.1';\n\n/*\nhttps://raw.githubusercontent.com/brunocalado/mestre-digital/master/Foundry%20VTT/Macros/Forged%20in%20the%20Dark/BladesintheDark-XpBar.js\nicon: icons/sundries/misc/lock-open-yellow.webp\n*/\n\nlet tokenD;\n\nif (canvas.tokens.controlled[0] === undefined){\n ui.notifications.warn(\"You must select a token!\"); \n} else {\n tokenD = canvas.tokens.controlled[0].actor;\n main();\n}\n\nasync function main() {\n let attribute = [];\n if(tokenD.type === 'character'){\n attribute = Object.keys( game.system.model.Actor.character.attributes );\n attribute.push(\"class\");\n attribute.push(\"stress\");\n } else if(tokenD.type === 'ship'){\n attribute = [\"crew\"];\n }\n\n let attributeList = ``;\n attribute.map((t) => {\n attributeList += ``;\n });\n \n new Dialog({\n title: `XP/Stress Bar - Manager - v${version}`,\n content: `\n

Bar Size

\n

\n \n


\n

Choose Bar

\n

\n \n

\n `,\n buttons: {\n roll: {\n label: \"Change\",\n callback: (html) => {\n changeActorSheetBar(html);\n }\n }, \n cancel: {\n label: \"Cancel\"\n }\n }\n }).render(true)\n}\n\nasync function changeActorSheetBar(html) {\n const xpBarSize = parseInt( html.find(\"#xpBarSize\")[0].value ); \n let attribute = html.find(\"#attribute\")[0].value;\n let updated; \n \n switch( attribute ){\n case 'class':\n updated = await Actor.updateDocuments([{_id: tokenD.id, \"system.experienceMax\": xpBarSize}]);\n break;\n case 'crew':\n updated = await Actor.updateDocuments([{_id: tokenD.id, \"system.crew_experienceMax\": xpBarSize}]);\n break;\n case 'stress':\n updated = await Actor.updateDocuments([{_id: tokenD.id, \"system.stress.max\": xpBarSize, \"system.stress.max_default\": xpBarSize}]);\n break;\n default:\n let key = \"system.attributes.\" + attribute + \".expMax\"; \n updated = await Actor.updateDocuments([{_id: tokenD.id, [key]: xpBarSize}]);\n }\n}","folder":null,"sort":0,"permission":{"default":0,"DndvQQR4KOtSK1iV":3},"flags":{"advanced-macros":{"runAsGM":false},"exportSource":{"world":"sav","system":"scum-and-villainy","coreVersion":"0.8.9","systemVersion":"1.9.4"},"core":{"sourceId":"Macro.R5S30v5UU19PIynf"}},"_id":"u1UhdaU5aGofIaAK"} diff --git a/system.json b/system.json index b7d94ae..f52a9aa 100644 --- a/system.json +++ b/system.json @@ -14,16 +14,16 @@ ], "url": "https://github.com/drewg13/foundryvtt-scum-and-villainy/", "flags": {}, - "version": "2.1.6", + "version": "2.1.7", "compatibility": { "minimum": 10, - "verified": 11.299 + "verified": 11.300 }, "system": [], "relationships": [], "socket": false, "manifest": "https://raw.githubusercontent.com/drewg13/foundryvtt-scum-and-villainy/master/system.json", - "download": "https://github.com/drewg13/foundryvtt-scum-and-villainy/archive/v2.1.6.zip", + "download": "https://github.com/drewg13/foundryvtt-scum-and-villainy/archive/v2.1.7.zip", "protected": false, "initiative": "1d20", "scripts": [],