Skip to content

Commit

Permalink
Merge pull request #22 from AngryBeaver/pf2e
Browse files Browse the repository at this point in the history
bug fix
  • Loading branch information
AngryBeaver authored Feb 6, 2023
2 parents d4308a2 + d4c3347 commit 1930fe3
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog
## 2.3.x feature system independent
## 2.3.1 bug pulling items from compendium
fixed: when dropping items from compendium they no longer have an itemType thus they will not be detected correctly as equal to any item on actor.

fixed: when one recipe refers to an item no longer in this world you could not open the compendium browser
## 2.3.0 feature system independent

⚠️This module now depends on other modules to work, you need to enable them ⚠️

This module can now run on multiple systems.
Expand Down
2 changes: 1 addition & 1 deletion 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": "2.3.0",
"version": "2.3.1",
"authors": [
{
"name": "angryBeaver",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "beavers-crafting",
"title": "Beaver's Crafting",
"version": "2.3.0",
"version": "2.3.1",
"description": "Crafting",
"devDir": "C:\\Users\\Riess\\AppData\\Local\\FoundryVTT\\Data\\modules",
"main": "src/main.js",
Expand Down
12 changes: 9 additions & 3 deletions src/Recipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ export class Recipe implements RecipeData {
addAttendant(entity, uuid, type) {
const uuidS = sanitizeUuid(uuid);
if (!this.attendants[uuidS]) {
this.attendants[uuidS] = beaversSystemInterface.componentCreate({...entity,uuid:uuid,type:type});
this.attendants[uuidS] = beaversSystemInterface.componentFromEntity(entity);
this.attendants[uuidS].uuid = uuid;
this.attendants[uuidS].type = type;
} else {
this.attendants[uuidS].quantity = this.attendants[uuidS].quantity+1;
}
Expand All @@ -130,7 +132,9 @@ export class Recipe implements RecipeData {
addIngredient(entity, uuid, type) {
const uuidS = sanitizeUuid(uuid);
if (!this.ingredients[uuidS]) {
this.ingredients[uuidS] = beaversSystemInterface.componentCreate({...entity,uuid:uuid,type:type});
this.ingredients[uuidS] = beaversSystemInterface.componentFromEntity(entity);
this.ingredients[uuidS].uuid = uuid;
this.ingredients[uuidS].type = type;
} else {
this.ingredients[uuidS].quantity = this.ingredients[uuidS].quantity+1;
}
Expand All @@ -144,7 +148,9 @@ export class Recipe implements RecipeData {
addResult(entity, uuid, type) {
const uuidS = sanitizeUuid(uuid);
if (!this.results[uuidS]) {
this.results[uuidS] = beaversSystemInterface.componentCreate({...entity,uuid:uuid,type:type});
this.results[uuidS] = beaversSystemInterface.componentFromEntity(entity);
this.results[uuidS].uuid = uuid;
this.results[uuidS].type = type;
} else {
this.results[uuidS].quantity = this.results[uuidS].quantity+1;
}
Expand Down
15 changes: 10 additions & 5 deletions src/apps/RecipeCompendium.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,16 @@ export class RecipeCompendium {
static async isAnyAnyOfInList(listOfAnyOfIngredients: Component[], listOfItems) {
for (const component of listOfAnyOfIngredients) {
if (component.type === Settings.ANYOF_SUBTYPE) {
const item = await component.getEntity();
const anyOf = new AnyOf(item);
const results = await anyOf.filter(listOfItems);
if (results.filter(c => c.quantity >= component.quantity).length == 0) {
return false;
try {
const item = await component.getEntity();
const anyOf = new AnyOf(item);
const results = await anyOf.filter(listOfItems);
if (results.filter(c => c.quantity >= component.quantity).length == 0) {
return false;
}
}catch(error)
{
console.warn(error);
}
}
}
Expand Down

0 comments on commit 1930fe3

Please sign in to comment.