Skip to content

Commit

Permalink
Merge pull request #27 from AngryBeaver/fix_2_3_2
Browse files Browse the repository at this point in the history
fix anyOf
  • Loading branch information
AngryBeaver authored Feb 7, 2023
2 parents fddd047 + 44e24ad commit b3510ed
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 13 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog
## 2.3.x feature system independent
## 2.3.3 anyOf bugs
fixed: dropping items on an anyOf ingredient does no longer work.
fixed: evaluated anyOf items are incorrectly detected as non matching to the actor.
## 2.3.2 fix tools
fixed: using tools was completely broken.
(jfi: tools are deprecated in favour of attendants dnd5e only)
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.2",
"version": "2.3.3",
"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.2",
"version": "2.3.3",
"description": "Crafting",
"devDir": "C:\\Users\\Riess\\AppData\\Local\\FoundryVTT\\Data\\modules",
"main": "src/main.js",
Expand Down
4 changes: 2 additions & 2 deletions src/AnyOf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export class AnyOf {
return result;
}

async filter(itemList): Promise<ComponentData[]>{
const resultList:ComponentData[] = [];
async filter(itemList): Promise<Component[]>{
const resultList:Component[] = [];
for(const item of itemList){
const result = await this.executeMacro(item);
const componentItem = beaversSystemInterface.componentFromEntity(item);
Expand Down
4 changes: 2 additions & 2 deletions src/Crafting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class Crafting implements CraftingData {

async evaluateAnyOf() {
const toDelete: string[] = [];
const toAdd: ComponentData[] = [];
const toAdd: Component[] = [];
for (const [key, component] of Object.entries(this.recipe.ingredients)) {
if (component.type === Settings.ANYOF_SUBTYPE) {
const item = await component.getEntity();
Expand All @@ -165,7 +165,7 @@ export class Crafting implements CraftingData {
}
toDelete.forEach(k => this.recipe.removeIngredient(k));
toAdd.forEach(component => {
this.recipe.addIngredient(component, component.uuid, component.type)
this.recipe.addIngredientComponent(component)
});
}

Expand Down
8 changes: 8 additions & 0 deletions src/Recipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ export class Recipe implements RecipeData {
this.ingredients[uuidS].quantity = this.ingredients[uuidS].quantity+1;
}
}
addIngredientComponent(component) {
const uuidS = sanitizeUuid(component.uuid);
if (!this.ingredients[uuidS]) {
this.ingredients[uuidS] = component;
} else {
this.ingredients[uuidS].quantity = this.ingredients[uuidS].quantity+1;
}
}

removeIngredient(uuidS) {
delete this.ingredients[uuidS];
Expand Down
10 changes: 5 additions & 5 deletions src/apps/CraftingApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ export class CraftingApp extends Application {
}

activateRecipeSheetListener(html) {
html.find('.results .item-name').on("click",e=>{
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));
}
});
html.find('.ingredients .item-name').on("click",e=>{
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));
Expand All @@ -144,7 +144,7 @@ export class CraftingApp extends Application {

addDragDrop(html) {
const dropFilter = new DragDrop({
dropSelector: '.drop-area, .ingredients .item-name',
dropSelector: '.drop-area, .ingredients .flexrow',
permissions: {
dragstart: this._canDragStart.bind(this),
drop: this._canDragDrop.bind(this)
Expand All @@ -167,8 +167,8 @@ export class CraftingApp extends Application {
if(isFilterDrop){
return this._onDropFilter(e);
}
const isIngredient = $(e.target).parent("item");
if(isIngredient){
const uuid = $(e.currentTarget).data("id");
if(uuid != undefined){
const uuid = $(e.currentTarget).data("id");
const key = $(e.currentTarget).data("key");
getItem(uuid).then(
Expand Down
4 changes: 2 additions & 2 deletions templates/recipe-main.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
{{/if}}
</div>
{{#each recipe.ingredients}}
<div class="flexrow" style="margin:0 5px;padding:1px 0;">
<div class="flexrow" style="margin:0 5px;padding:1px 0;" data-key="{{@key}}" data-id="{{this.uuid}}">
<div class="crafting-item-img {{#if ../displayIngredients}}clickable{{/if}}" style="flex:0 0 auto;margin: 0 5px 0 0px;background-image: url('{{this.img}}')" data-id="{{this.uuid}}" data-key="{{@key}}"></div>
<span style="line-height:30px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">{{this.name}}</span>
<div style="flex: 0 0 auto; width:60px; line-height: 30px;text-align: center;">
Expand Down Expand Up @@ -230,7 +230,7 @@
{{/if}}
</div>
{{#each recipe.results}}
<div class="flexrow" style="margin:0 5px;padding:1px 0;">
<div class="flexrow" style="margin:0 5px;padding:1px 0;" data-key="{{@key}}" data-id="{{this.uuid}}">
<div class="crafting-item-img {{#if ../displayResults}}clickable{{/if}}" style="flex:0 0 auto;margin: 0 5px 0 0px;background-image: url('{{this.img}}')" data-id="{{this.uuid}}" data-key="{{@key}}"></div>
<span style="line-height:30px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">{{this.name}}</span>
<div style="flex: 0 0 auto; width:60px; line-height: 30px;text-align: center;">
Expand Down

0 comments on commit b3510ed

Please sign in to comment.