Skip to content

Commit

Permalink
defect: Fix Recipe Import (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
misterpotts authored Sep 11, 2023
1 parent a357c29 commit f85f2d4
Show file tree
Hide file tree
Showing 21 changed files with 20 additions and 1,038 deletions.
2 changes: 1 addition & 1 deletion docs/_config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
title: Fabricate 0.9.3
title: Fabricate 0.9.4
email: [email protected]
description: >-
End user documentation for the Foundry Virtual Tabletop (VTT) Module, "Fabricate".
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fabricate",
"version": "0.9.3",
"version": "0.9.4",
"description": "A system-agnostic, flexible crafting module for FoundryVT",
"main": "index.js",
"type": "module",
Expand Down
18 changes: 0 additions & 18 deletions src/applications/common/LoadingModal.svelte

This file was deleted.

33 changes: 0 additions & 33 deletions src/applications/common/LoadingStore.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import {ComponentsStore} from "../stores/ComponentsStore";
import {SelectedRecipeStore} from "../stores/SelectedRecipeStore";
import {SelectedCraftingComponentStore} from "../stores/SelectedCraftingComponentStore";
import {LoadingStore} from "../common/LoadingStore";
import LoadingModal from "../common/LoadingModal.svelte";
import eventBus from "../common/EventBus";
import {onMount, setContext} from "svelte";
Expand All @@ -29,7 +27,6 @@
export let fabricateAPI;
const localizationPath = `${Properties.module.id}.CraftingSystemManagerApp`
const loading = new LoadingStore({});
const craftingSystems = new CraftingSystemsStore({});
const selectedCraftingSystem = new SelectedCraftingSystemStore({ craftingSystems });
Expand Down Expand Up @@ -77,8 +74,6 @@

<svelte:window on:itemDeleted={(e) => handleItemDeleted(e)} use:eventBus='{"itemDeleted"}'></svelte:window>

<LoadingModal loading={$loading} />

<CraftingSystemNavbar />

{#if $craftingSystems.length > 0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@
craftingSystems,
craftingSystemEditor,
selectedCraftingSystem,
localization,
loading
localization
} = getContext(key);
async function createCraftingSystem() {
$loading = true;
$selectedCraftingSystem = await craftingSystemEditor.createNewCraftingSystem();
$loading = false;
}
async function importCraftingSystem(targetCraftingSystemId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
} else {
salvageOption.addResult(component.id);
}
$selectedComponent.saveSalvageOption(salvageOption);
$selectedComponent.setSalvageOption(salvageOption);
await componentEditor.saveComponent($selectedComponent);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ class EssenceEditor {
return essence;
}

public async saveAll(essences: Essence[]) {
await this._fabricateAPI.essences.saveAll(essences);
this._essences.insertAll(essences);
}

}

export { EssenceEditor }
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,14 @@
recipes,
selectedRecipe,
selectedCraftingSystem,
loading,
recipeEditor
} = getContext(key);
const recipeSearchResults = new RecipeSearchStore({availableRecipes: recipes});
const searchTerms = recipeSearchResults.searchTerms;
async function importRecipe(event) {
$loading = true;
await recipeEditor.importRecipe(event, $selectedCraftingSystem);
$loading = false;
}
function clearSearch() {
Expand All @@ -33,14 +30,11 @@
}
async function deleteRecipe(event, recipe) {
$loading = true;
await recipeEditor.deleteRecipe(event, recipe, $selectedCraftingSystem);
$loading = false;
}
async function disableRecipe(recipe) {
recipe.isDisabled = true;
$loading = true;
await recipeEditor.saveRecipe(recipe, $selectedCraftingSystem);
const message = localization.format(
`${localizationPath}.recipe.disabled`,
Expand All @@ -49,12 +43,10 @@
}
);
ui.notifications.info(message);
$loading = false;
}
async function enableRecipe(recipe) {
recipe.isDisabled = false;
$loading = true;
await recipeEditor.saveRecipe(recipe, $selectedCraftingSystem);
const message = localization.format(
`${localizationPath}.recipe.enabled`,
Expand All @@ -63,17 +55,14 @@
}
);
ui.notifications.info(message);
$loading = false;
}
function toggleRecipeDisabled(recipe) {
return recipe.isDisabled ? enableRecipe(recipe) : disableRecipe(recipe);
}
async function duplicateRecipe(recipe) {
$loading = true;
await recipeEditor.duplicateRecipe(recipe, $selectedCraftingSystem);
$loading = false;
}
async function openItemSheet(recipe) {
Expand Down
10 changes: 10 additions & 0 deletions src/applications/stores/EssenceStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ class EssencesStore implements Writable<Essence[]> {
});
}

insertAll(essences: Essence[]) {
this._essences.update((existingEssences) => {
const essencesById = new Map(existingEssences.map((essence) => [essence.id, essence]));
essences.forEach((essence) => {
essencesById.set(essence.id, essence);
});
return Array.from(essencesById.values());
});
}

remove(essence: Essence) {
this._essences.update((components) => {
const index = components.findIndex((candidate) => candidate.id === essence.id);
Expand Down
2 changes: 1 addition & 1 deletion src/public/module.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "fabricate",
"title": "Fabricate",
"version": "0.9.3",
"version": "0.9.4",
"description": "A system-agnostic, flexible crafting module for FoundryVTT",
"authors": [
{
Expand Down
35 changes: 0 additions & 35 deletions src/scripts/crafting/Tool.ts

This file was deleted.

45 changes: 0 additions & 45 deletions src/scripts/crafting/component/Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@ interface ComponentJson {

class Component implements Identifiable, Serializable<ComponentJson> {

private static readonly _NONE: Component = new Component({
id: "NO_ID",
craftingSystemId: "NO_CRAFTING_SYSTEM_ID",
itemData: NoFabricateItemData.INSTANCE(),
disabled: true,
essences: Combination.EMPTY(),
salvageOptions: new SelectableOptions({})
});

private readonly _id: string;
private readonly _embedded: boolean;
private readonly _craftingSystemId: string;
Expand Down Expand Up @@ -95,10 +86,6 @@ class Component implements Identifiable, Serializable<ComponentJson> {
return this._itemData.uuid;
}

public static NONE() {
return this._NONE;
}

get name(): string {
return this._itemData.name;
}
Expand All @@ -111,26 +98,6 @@ class Component implements Identifiable, Serializable<ComponentJson> {
return this._essences;
}

get selectedSalvage(): Combination<ComponentReference> {
return this._salvageOptions.selectedOption.results;
}

get selectedSalvageOptionName(): string {
return this._salvageOptions.selectedOptionId;
}

public selectSalvageOption(combinationId: string) {
this._salvageOptions.select(combinationId);
}

public selectNextSalvageOption(): void {
this._salvageOptions.selectNext();
}

public selectPreviousSalvageOption(): void {
this._salvageOptions.selectPrevious();
}

get isDisabled(): boolean {
return this._disabled;
}
Expand Down Expand Up @@ -212,10 +179,6 @@ class Component implements Identifiable, Serializable<ComponentJson> {
return this._salvageOptions;
}

public selectFirstOption(): void {
this._salvageOptions.selectFirst()
}

get salvageOptionsById(): Map<string, SalvageOption> {
return this._salvageOptions.byId;
}
Expand All @@ -236,10 +199,6 @@ class Component implements Identifiable, Serializable<ComponentJson> {
return this._itemData.errors.map(error => error.code);
}

deselectSalvage() {
this._salvageOptions.deselect();
}

removeEssence(essenceIdToDelete: string) {
this._essences = this._essences.without(essenceIdToDelete);
}
Expand Down Expand Up @@ -277,10 +236,6 @@ class Component implements Identifiable, Serializable<ComponentJson> {
this._salvageOptions.set(created);
}

public saveSalvageOption(value: SalvageOption) {
this._salvageOptions.set(value);
}

addEssence(essenceId: string, quantity: number = 1) {
this._essences = this._essences.addUnit(new Unit(new EssenceReference(essenceId), quantity));
}
Expand Down
35 changes: 0 additions & 35 deletions src/scripts/error/ValidationFailures.ts

This file was deleted.

Loading

0 comments on commit f85f2d4

Please sign in to comment.