Skip to content

Commit

Permalink
Merge pull request #39 from AngryBeaver/3.0.1
Browse files Browse the repository at this point in the history
compatibility v11
  • Loading branch information
AngryBeaver authored Mar 11, 2023
2 parents 480efc7 + 40ffd91 commit 698979e
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 30 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Changelog
## 3.0.1 v11 support
- enables support for v11

## 3.0.x progress tracking and multiple tests
- This module now enables tracking of your progress through a series of tests.
- You can now specify a tool roll test in dnd5e.
Expand Down
8 changes: 4 additions & 4 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title": "Beaver's Crafting Module",
"description": "A Crafting Module for DnD",
"id": "beavers-crafting",
"version": "3.0.0",
"version": "3.0.1",
"authors": [
{
"name": "angryBeaver",
Expand Down Expand Up @@ -44,15 +44,15 @@
"type": "module",
"manifest": "https://github.com/AngryBeaver/beavers-system-interface/releases/latest/download/module.json",
"compatibility": {
"verified": "1.0.5"
"verified": "1.1.0"
}
},
{
"id": "bsa-dnd5e",
"type": "module",
"manifest": "https://github.com/AngryBeaver/bsa-dnd5e/releases/latest/download/module.json",
"compatibility": {
"verified": "1.0.0"
"verified": "1.0.1"
}
},
{
Expand All @@ -67,6 +67,6 @@
},
"compatibility": {
"minimum": "10",
"verified": "10"
"verified": "11"
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "beavers-crafting",
"title": "Beaver's Crafting",
"version": "3.0.0",
"version": "3.0.1",
"description": "Crafting",
"devDir": "C:\\Users\\Riess\\AppData\\Local\\FoundryVTT\\Data\\modules",
"#devDir": "C:\\data\\Data\\modules",
"main": "src/main.js",
"scripts": {
"build": "npx gulp",
Expand Down
5 changes: 2 additions & 3 deletions src/Crafting.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {Recipe} from "./Recipe.js";
import {Settings} from "./Settings.js";
import {RecipeCompendium} from "./apps/RecipeCompendium.js";
import {getItem} from "./helpers/Utility.js";
import {AnyOf} from "./AnyOf.js";
import {Result} from "./Result.js";
import {TestHandler} from "./TestHandler.js";
Expand Down Expand Up @@ -463,7 +462,7 @@ export class Crafting implements CraftingData {
}

async _rollTableToComponents(component: Component, result: Result) {
const table = await getItem(component.uuid);
const table = await beaversSystemInterface.uuidToDocument(component.uuid);
let components: Component[] = [];
if (!table) {
// @ts-ignore
Expand All @@ -485,7 +484,7 @@ export class Crafting implements CraftingData {
}
uuid = "Compendium." + uuid;
}
const item = await getItem(uuid)
const item = await beaversSystemInterface.uuidToDocument(uuid)
if (!item) {
// @ts-ignore
ui.notifications.error(game.i18n.localize(`beaversCrafting.crafting-app.errors.tableItemNotFound`) + r.name);
Expand Down
10 changes: 5 additions & 5 deletions src/apps/CraftingApp.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {FilterType, RecipeCompendium} from "./RecipeCompendium.js";
import {Crafting} from "../Crafting.js";
import {getDataFrom, getItem, sanitizeUuid} from "../helpers/Utility.js";
import {getDataFrom, sanitizeUuid} from "../helpers/Utility.js";
import {Settings} from "../Settings.js";
import {getToolConfig} from "./ToolConfig.js";
import {AnyOf} from "../AnyOf.js";
Expand Down Expand Up @@ -130,13 +130,13 @@ export class CraftingApp extends Application {
html.find('.results .flexrow').on("click",e=>{
const uuid = $(e.currentTarget).data("id");
if(Settings.get(Settings.DISPLAY_RESULTS)) {
getItem(uuid).then(i=>i.sheet._render(true));
beaversSystemInterface.uuidToDocument(uuid).then(i=>i.sheet._render(true));
}
});
html.find('.ingredients .flexrow').on("click",e=>{
const uuid = $(e.currentTarget).data("id");
if(Settings.get(Settings.DISPLAY_INGREDIENTS)) {
getItem(uuid).then(i=>i.sheet._render(true));
beaversSystemInterface.uuidToDocument(uuid).then(i=>i.sheet._render(true));
}
});
this.addDragDrop(html);
Expand Down Expand Up @@ -171,7 +171,7 @@ export class CraftingApp extends Application {
if(uuid != undefined){
const uuid = $(e.currentTarget).data("id");
const key = $(e.currentTarget).data("key");
getItem(uuid).then(
beaversSystemInterface.uuidToDocument(uuid).then(
item => {
if(AnyOf.isAnyOf(item)){
return this._onDropAnyOf(new AnyOf(item),key,e);
Expand Down Expand Up @@ -248,7 +248,7 @@ export class CraftingApp extends Application {
}
}
if(Settings.get(Settings.USE_TOOL) && recipe.tool){
const item = await getItem(recipe.tool);
const item = await beaversSystemInterface.uuidToDocument(recipe.tool);
const component = beaversSystemInterface.componentFromEntity(item);
preCastData.tool = !result._components.required.hasError(component)
}
Expand Down
3 changes: 1 addition & 2 deletions src/apps/RecipeCompendium.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {Recipe} from "../Recipe.js";
import {Settings} from "../Settings.js";
import {AnyOf} from "../AnyOf.js";
import {getItem} from "../helpers/Utility.js";
import {Result} from "../Result.js";

export class RecipeCompendium {
Expand Down Expand Up @@ -112,7 +111,7 @@ export class RecipeCompendium {

static async validateTool(recipe,listOfItems,result : Result): Promise<Result>{
if( recipe.tool && Settings.get(Settings.USE_TOOL)) {
const item = await getItem(recipe.tool);
const item = await beaversSystemInterface.uuidToDocument(recipe.tool);
const component = beaversSystemInterface.componentFromEntity(item);
result.updateComponent("required",component);
}
Expand Down
8 changes: 4 additions & 4 deletions src/apps/RecipeSheet.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Recipe} from "../Recipe.js";
import {getSystemSetting, Settings} from "../Settings.js";
import {getDataFrom, getItem} from "../helpers/Utility.js";
import {getDataFrom} from "../helpers/Utility.js";
import {AnyOf} from "../AnyOf.js";
import {getToolConfig} from "./ToolConfig.js";

Expand Down Expand Up @@ -188,19 +188,19 @@ export class RecipeSheet {
this.recipeElement.find('.results .crafting-item-img').on("click",e=>{
const uuid = $(e.currentTarget).data("id");
if(Settings.get(Settings.DISPLAY_RESULTS)) {
getItem(uuid).then(i=>i.sheet._render(true));
beaversSystemInterface.uuidToDocument(uuid).then(i=>i.sheet._render(true));
}
});
this.recipeElement.find('.ingredients .crafting-item-img').on("click",e=>{
const uuid = $(e.currentTarget).data("id");
if(Settings.get(Settings.DISPLAY_INGREDIENTS)) {
getItem(uuid).then(i=>i.sheet._render(true));
beaversSystemInterface.uuidToDocument(uuid).then(i=>i.sheet._render(true));
}
});
this.recipeElement.find('.attendants .crafting-item-img').on("click",e=>{
const uuid = $(e.currentTarget).data("id");
if(Settings.get(Settings.DISPLAY_INGREDIENTS)) {
getItem(uuid).then(i=>i.sheet._render(true));
beaversSystemInterface.uuidToDocument(uuid).then(i=>i.sheet._render(true));
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/apps/ToolConfig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Settings} from "../Settings.js";
import {getDataFrom, getItem} from "../helpers/Utility.js";
import {getDataFrom} from "../helpers/Utility.js";

const components:ComponentData[] = [];

Expand Down Expand Up @@ -98,7 +98,7 @@ async function _setToolConfig(){
}
}
async function _addToolConfig(uuid){
const item = await getItem(uuid);
const item = await beaversSystemInterface.uuidToDocument(uuid);
const component = beaversSystemInterface.componentFromEntity(item);
components.push(component);
}
9 changes: 0 additions & 9 deletions src/helpers/Utility.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
export async function getItem(uuid) {
const parts = uuid.split(".");
if (parts[0] === "Compendium") {
return await game.packs.get(parts[1] + "." + parts[2]).getDocument(parts[3]);
} else {
return await fromUuid(uuid);
}
}

export function getDataFrom(e) {
try {
return JSON.parse(e.dataTransfer.getData('text/plain'));
Expand Down

0 comments on commit 698979e

Please sign in to comment.