From 175797a8c282ca18d419d61492f7cd90d1dfcd87 Mon Sep 17 00:00:00 2001 From: AngryBeaver Date: Mon, 24 Jul 2023 11:53:34 +0200 Subject: [PATCH 1/2] 3.2.2 --- README.md | 4 ++ changelog.md | 5 ++ css/crafting.css | 9 +++ module.json | 32 ++++++++--- package.json | 4 +- src/Crafting.ts | 21 ++++++- src/Settings.js | 78 +++++++++++++------------- src/apps/CraftingApp.ts | 16 ++++-- src/apps/RecipeSheet.ts | 4 +- src/apps/ToolConfig.ts | 9 ++- src/types.ts | 2 +- templates/beavers-recipe-component.hbs | 2 + 12 files changed, 128 insertions(+), 58 deletions(-) diff --git a/README.md b/README.md index 7356aa8..d2617a8 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,10 @@ Or can start a crafting process by clicking on a recipe in your inventory (depre You will see a chat message with your result +Items updated or created in a successfull crafting process are flagged: +flags.beavers-crafting.status = "created" or "updated" + + ### AnyOf AnyOf is an Item that is intended to be used as ingredient to create recipes that do not need a specific ingredient but any ingredient of... e.g. specific type. diff --git a/changelog.md b/changelog.md index e39f126..d0ac216 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,10 @@ # Changelog ## 3.2.x simple or +## 3.2.2 +- automatically fix broken tools (dnd5e) +- add flag to created or updated items +- fix broken anyOf precast status +- fix recipes returning results that are based on items that do not have quantity ## 3.2.1 - recipe edit quantity ## 3.2.0 diff --git a/css/crafting.css b/css/crafting.css index 0730a7b..f733c35 100644 --- a/css/crafting.css +++ b/css/crafting.css @@ -262,6 +262,15 @@ width: 14px; padding: 0px 0px 0px 3px; } + +.beavers-crafting .fa-question{ + color: #3f678e; + width:14px; + padding-left:2px; + font-size:small; + margin: auto; +} + .beavers-crafting .fa-check{ color:#468847; margin: auto; diff --git a/module.json b/module.json index 797cb71..c0f1f79 100644 --- a/module.json +++ b/module.json @@ -1,8 +1,8 @@ { "title": "Beaver's Crafting Module", - "description": "A Crafting Module", + "description": "A Module for not only Crafting. But also Tracking any activities, Skill challenges, Quest and Progress, Faction reputation and more", "id": "beavers-crafting", - "version": "3.2.1", + "version": "3.2.2", "authors": [ { "name": "angryBeaver", @@ -44,16 +44,18 @@ "type": "module", "manifest": "https://github.com/AngryBeaver/beavers-system-interface/releases/latest/download/module.json", "compatibility": { - "minimum" : "2.1.1", - "verified": "2.1.1" + "minimum" : "2.1.2", + "verified": "2.1.2" } - }, + } + ], + "recommends": [ { "id": "bsa-dnd5e", "type": "module", "manifest": "https://github.com/AngryBeaver/bsa-dnd5e/releases/latest/download/module.json", "compatibility": { - "verified": "2.0.0" + "verified": "2.0.1" } }, { @@ -61,7 +63,23 @@ "type": "module", "manifest": "https://github.com/AngryBeaver/bsa-pf2e/releases/latest/download/module.json", "compatibility": { - "verified": "1.0.0" + "verified": "1.0.1" + } + }, + { + "id": "bsa-pf1", + "type": "module", + "manifest": "https://github.com/AngryBeaver/bsa-pf1/releases/latest/download/module.json", + "compatibility": { + "verified": "1.0.1" + } + }, + { + "id": "bsa-swade", + "type": "module", + "manifest": "https://github.com/AngryBeaver/bsa-swade/releases/latest/download/module.json", + "compatibility": { + "verified": "1.0.2" } } ] diff --git a/package.json b/package.json index 82751f2..45874a1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "beavers-crafting", "title": "Beaver's Crafting", - "version": "3.2.1", + "version": "3.2.2", "description": "Crafting", "devDir": "C:\\Users\\Riess\\AppData\\Local\\FoundryVTT\\Data\\modules", "#devDir": "C:\\data\\Data\\modules", @@ -24,7 +24,7 @@ "printWidth": 120 }, "devDependencies": { - "beavers-system-interface": "^2.1.1", + "beavers-system-interface": "^2.1.2", "@ethaks/fvtt-quench": "^0.6.0", "@league-of-foundry-developers/foundry-vtt-types": "^0.8.8-9", "@types/jest": "^27.4.1", diff --git a/src/Crafting.ts b/src/Crafting.ts index c2119f3..3d05cb7 100644 --- a/src/Crafting.ts +++ b/src/Crafting.ts @@ -336,7 +336,9 @@ export class Crafting implements CraftingData { } } try{ - await beaversSystemInterface.actorComponentListAdd(this.actor,componentList); + const itemChange = await beaversSystemInterface.actorComponentListAdd(this.actor,componentList); + const actor = await fromUuid(this.actor.uuid); + this._flagCreatedItems(actor, itemChange); }catch(e){ // @ts-ignore ui.notifications.error(e.message) @@ -368,6 +370,23 @@ export class Crafting implements CraftingData { } } } + async _flagCreatedItems(actor: any, itemChange:ItemChange){ + const updates:any[] = []; + if(!this.result.hasError()) { + for (const u of itemChange.update) { + const update = {_id: u._id}; + beaversSystemInterface.objectAttributeSet(update, "flags.beavers-crafting.status", "updated"); + updates.push(update); + } + for (const c of itemChange.create) { + const update = {_id: c._id || c.id} + beaversSystemInterface.objectAttributeSet(update, "flags.beavers-crafting.status", "created"); + updates.push(update); + } + await actor.updateEmbeddedDocuments("Item", updates); + } + } + get chatData(): ChatData { return this.getChatData(); } diff --git a/src/Settings.js b/src/Settings.js index 655f38b..30cb661 100644 --- a/src/Settings.js +++ b/src/Settings.js @@ -110,10 +110,10 @@ export class Settings { name: "ToolConfig", scope: "world", config: false, - default: getSystemSetting().toolConfig, + default: Settings.getSystemSetting().toolConfig, type: Object }); - if (getSystemSetting().hasTool) { + if (Settings.getSystemSetting().hasTool) { game.settings.registerMenu(this.NAMESPACE, this.TOOL_CONFIG_BUTTON, { name: game.i18n.localize('beaversCrafting.settings.toolButton.name'), label: game.i18n.localize("beaversCrafting.settings.toolButton.label"), @@ -137,43 +137,43 @@ export class Settings { return Settings.get(Settings.DISABLED_ACTOR).split(",").includes(actor.type); } -} - -export function getSystemSetting() { - if (game["system"].id === "dnd5e") { + static getSystemSetting() { + if (game["system"].id === "dnd5e") { + return { + toolConfig: [ + "Compendium.dnd5e.items.8NS6MSOdXtUqD7Ib", + "Compendium.dnd5e.items.rTbVrNcwApnuTz5E", + "Compendium.dnd5e.items.fC0lFK8P4RuhpfaU", + "Compendium.dnd5e.items.YfBwELTgPFHmQdHh", + "Compendium.dnd5e.items.hM84pZnpCqKfi8XH", + "Compendium.dnd5e.items.PUMfwyVUbtyxgYbD", + "Compendium.dnd5e.items.skUih6tBvcBbORzA", + "Compendium.dnd5e.items.YHCmjsiXxZ9UdUhU", + "Compendium.dnd5e.items.hJS8yEVkqgJjwfWa", + "Compendium.dnd5e.items.woWZ1sO5IUVGzo58", + "Compendium.dnd5e.items.KndVe2insuctjIaj", + "Compendium.dnd5e.items.0d08g1i5WXnNrCNA", + "Compendium.dnd5e.items.ap9prThUB2y9lDyj", + "Compendium.dnd5e.items.xKErqkLo4ASYr5EP", + "Compendium.dnd5e.items.SztwZhbhZeCqyAes", + "Compendium.dnd5e.items.Y9S75go1hLMXUD48", + "Compendium.dnd5e.items.jhjo20QoiD5exf09", + "Compendium.dnd5e.items.ccm5xlWhx74d6lsK", + "Compendium.dnd5e.items.ugzwHl8vYaPu2GNd", + "Compendium.dnd5e.items.i89okN7GFTWHsvPy", + "Compendium.dnd5e.items.IBhDAr7WkhWPYLVn", + "Compendium.dnd5e.items.cG3m4YlHfbQlLEOx", + "Compendium.dnd5e.items.il2GNi8C0DvGLL9P", + "Compendium.dnd5e.items.V13fjV5oSmvbRdgP", + "Compendium.dnd5e.items.6rocoBx5jdzG1QQH", + ], + hasTool: true, + } + } return { - toolConfig: [ - "Compendium.dnd5e.items.8NS6MSOdXtUqD7Ib", - "Compendium.dnd5e.items.rTbVrNcwApnuTz5E", - "Compendium.dnd5e.items.fC0lFK8P4RuhpfaU", - "Compendium.dnd5e.items.YfBwELTgPFHmQdHh", - "Compendium.dnd5e.items.hM84pZnpCqKfi8XH", - "Compendium.dnd5e.items.PUMfwyVUbtyxgYbD", - "Compendium.dnd5e.items.skUih6tBvcBbORzA", - "Compendium.dnd5e.items.YHCmjsiXxZ9UdUhU", - "Compendium.dnd5e.items.hJS8yEVkqgJjwfWa", - "Compendium.dnd5e.items.woWZ1sO5IUVGzo58", - "Compendium.dnd5e.items.KndVe2insuctjIaj", - "Compendium.dnd5e.items.0d08g1i5WXnNrCNA", - "Compendium.dnd5e.items.ap9prThUB2y9lDyj", - "Compendium.dnd5e.items.xKErqkLo4ASYr5EP", - "Compendium.dnd5e.items.SztwZhbhZeCqyAes", - "Compendium.dnd5e.items.Y9S75go1hLMXUD48", - "Compendium.dnd5e.items.jhjo20QoiD5exf09", - "Compendium.dnd5e.items.ccm5xlWhx74d6lsK", - "Compendium.dnd5e.items.ugzwHl8vYaPu2GNd", - "Compendium.dnd5e.items.i89okN7GFTWHsvPy", - "Compendium.dnd5e.items.IBhDAr7WkhWPYLVn", - "Compendium.dnd5e.items.cG3m4YlHfbQlLEOx", - "Compendium.dnd5e.items.il2GNi8C0DvGLL9P", - "Compendium.dnd5e.items.V13fjV5oSmvbRdgP", - "Compendium.dnd5e.items.6rocoBx5jdzG1QQH", - ], - hasTool: true, + toolConfig: [], + hasTool: false, } } - return { - toolConfig: [], - hasTool: false, - } -} \ No newline at end of file + +} diff --git a/src/apps/CraftingApp.ts b/src/apps/CraftingApp.ts index 53d921c..a3672a8 100644 --- a/src/apps/CraftingApp.ts +++ b/src/apps/CraftingApp.ts @@ -106,7 +106,7 @@ export class CraftingApp extends Application { return; } const crafting = await Crafting.fromRecipe(this.data.actor.id, this.data.recipe); - RecipeCompendium.validateRecipeToItemList(RecipeCompendium._filterData(this.data.recipe.input,(c)=>true), this.data.actor.items,crafting.result); + RecipeCompendium.validateRecipeToItemList(RecipeCompendium._filterData(this.data.recipe.input,(c)=>c.type==="Item"), this.data.actor.items,crafting.result); await crafting.checkTool(); await crafting.checkAttendants(); await crafting.checkCurrency(); @@ -323,16 +323,22 @@ export class CraftingApp extends Application { preCastData.input[group] = {}; for(const key in recipe.input[group]){ const component = recipe.input[group][key]; - preCastData.input[group][key]= result._components.consumed.hasError(component)?'error':'success' + if( result._components.consumed.findComponentResult(component)){ + preCastData.input[group][key]= result._components.consumed.hasError(component)?'error':'success' + }else{ + preCastData.input[group][key]= 'unknown'; + } } - - } for(const group in recipe.required){ preCastData.required[group] = {}; for(const key in recipe.required[group]){ const component = recipe.required[group][key]; - preCastData.required[group][key]=result._components.required.hasError(component)?'error':'success' + if( result._components.required.findComponentResult(component)) { + preCastData.required[group][key] = result._components.required.hasError(component) ? 'error' : 'success' + }else{ + preCastData.required[group][key]= 'unknown'; + } } } return preCastData; diff --git a/src/apps/RecipeSheet.ts b/src/apps/RecipeSheet.ts index cb8a650..204ec81 100644 --- a/src/apps/RecipeSheet.ts +++ b/src/apps/RecipeSheet.ts @@ -1,5 +1,5 @@ import {Recipe} from "../Recipe.js"; -import {getSystemSetting, Settings} from "../Settings.js"; +import {Settings} from "../Settings.js"; import {getDataFrom} from "../helpers/Utility.js"; import {AnyOf} from "../AnyOf.js"; import {getToolConfig} from "./ToolConfig.js"; @@ -97,7 +97,7 @@ export class RecipeSheet { displayResults:Settings.get(Settings.DISPLAY_RESULTS), displayIngredients:Settings.get(Settings.DISPLAY_RESULTS), useAttendants: Settings.get(Settings.USE_ATTENDANTS), - canRollTool:getSystemSetting().hasTool, + canRollTool:Settings.getSystemSetting().hasTool, canRollAbility:beaversSystemInterface.configCanRollAbility, }); let description = await renderTemplate('modules/beavers-crafting/templates/recipe-description.hbs', diff --git a/src/apps/ToolConfig.ts b/src/apps/ToolConfig.ts index ff6ef13..3fff4d5 100644 --- a/src/apps/ToolConfig.ts +++ b/src/apps/ToolConfig.ts @@ -91,9 +91,16 @@ export async function getToolConfig(): Promise{ async function _setToolConfig(){ components.length = 0; const tools = Settings.get(Settings.TOOL_CONFIG) || []; + const resultTools : string[] = []; for (const uuid of tools) { - await _addToolConfig(uuid); + try { + await _addToolConfig(uuid); + resultTools.push(uuid); + } catch( e ){ + console.warn("Could not find tool uuid, automatically fixed by removing it"); + } } + Settings.set(Settings.TOOL_CONFIG,resultTools); } async function _addToolConfig(uuid){ const item = await beaversSystemInterface.uuidToDocument(uuid); diff --git a/src/types.ts b/src/types.ts index 64aa15f..2607416 100644 --- a/src/types.ts +++ b/src/types.ts @@ -66,7 +66,7 @@ type DataType = "required" | "input" | "output"; type TestType = "skill" | "tool" | "ability" | "hit"; -type ComponentStatus = "success"|"error"|"locked"|"undefined"; +type ComponentStatus = "success"|"error"|"locked"|"undefined"|"unknown"; interface ComponentChatData { diff --git a/templates/beavers-recipe-component.hbs b/templates/beavers-recipe-component.hbs index 101cf91..802b249 100644 --- a/templates/beavers-recipe-component.hbs +++ b/templates/beavers-recipe-component.hbs @@ -17,6 +17,8 @@ {{else if (eq status 'locked') }} + {{else if (eq status 'unknown') }} + {{/if}} {{#if editable}} From 5675eb14efd439baa23f988e2d24afb409dde0ba Mon Sep 17 00:00:00 2001 From: AngryBeaver Date: Mon, 24 Jul 2023 11:54:26 +0200 Subject: [PATCH 2/2] 3.2.2 --- package-lock.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index cf23919..db9ca08 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "beavers-crafting", - "version": "3.1.5", + "version": "3.2.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "beavers-crafting", - "version": "3.1.5", + "version": "3.2.2", "dependencies": { "save-dev": "^0.0.1-security" }, @@ -14,7 +14,7 @@ "@ethaks/fvtt-quench": "^0.6.0", "@league-of-foundry-developers/foundry-vtt-types": "^0.8.8-9", "@types/jest": "^27.4.1", - "beavers-system-interface": "^2.1.1", + "beavers-system-interface": "^2.1.2", "del": "^6.0.0", "gulp": "^4.0.2", "gulp-cli": "^2.3.0", @@ -1934,9 +1934,9 @@ } }, "node_modules/beavers-system-interface": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/beavers-system-interface/-/beavers-system-interface-2.1.1.tgz", - "integrity": "sha512-wvUTltbeaDZOlEA6VqVDPlzJuvvgxcuDEM1NDN2NbI0di6Vc9SRgW9gzzCTGXJCyXa2zDs3RQ7bmfLT2RoxByw==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/beavers-system-interface/-/beavers-system-interface-2.1.2.tgz", + "integrity": "sha512-3m7nDTFHcqE/lR7gF94S0i13+Q91jOlGki4PF+3QBknboSyILHfaqBxzJU/dsyKrNq5Bvm2x+9JzvXaujzqbfQ==", "dev": true, "dependencies": { "save-dev": "^0.0.1-security" @@ -9168,9 +9168,9 @@ "dev": true }, "beavers-system-interface": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/beavers-system-interface/-/beavers-system-interface-2.1.1.tgz", - "integrity": "sha512-wvUTltbeaDZOlEA6VqVDPlzJuvvgxcuDEM1NDN2NbI0di6Vc9SRgW9gzzCTGXJCyXa2zDs3RQ7bmfLT2RoxByw==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/beavers-system-interface/-/beavers-system-interface-2.1.2.tgz", + "integrity": "sha512-3m7nDTFHcqE/lR7gF94S0i13+Q91jOlGki4PF+3QBknboSyILHfaqBxzJU/dsyKrNq5Bvm2x+9JzvXaujzqbfQ==", "dev": true, "requires": { "save-dev": "^0.0.1-security"