generated from League-of-Foundry-Developers/foundry-typescript-template
-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Search and view recipes in the new Actor Crafting App (#215)
Co-authored-by: Matt Potts <matt@@mrpotts.uk>
- Loading branch information
1 parent
a2f584d
commit b2df256
Showing
16 changed files
with
660 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
title: Fabricate 0.10.7 | ||
title: Fabricate 0.10.8 | ||
email: [email protected] | ||
description: >- | ||
End user documentation for the Foundry Virtual Tabletop (VTT) Module, "Fabricate". | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
288 changes: 229 additions & 59 deletions
288
src/applications/actorCraftingApp/ActorCraftingApp.svelte
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
interface CraftingProcess { | ||
|
||
readonly isReady: boolean; | ||
|
||
readonly recipeName: string; | ||
|
||
} | ||
|
||
export { CraftingProcess }; | ||
|
||
class DefaultCraftingProcess implements CraftingProcess { | ||
|
||
private readonly _recipeName: string; | ||
|
||
constructor({ | ||
recipeName, | ||
}: { | ||
recipeName: string; | ||
}) { | ||
this._recipeName = recipeName; | ||
} | ||
|
||
get recipeName(): string { | ||
return this._recipeName; | ||
} | ||
|
||
get isReady(): boolean { | ||
return true; | ||
} | ||
|
||
} | ||
|
||
export { DefaultCraftingProcess }; | ||
|
||
class NoCraftingProcess implements CraftingProcess { | ||
|
||
get recipeName(): string { | ||
return "No Recipe"; | ||
} | ||
|
||
get isReady(): boolean { | ||
return false; | ||
} | ||
|
||
} | ||
|
||
export { NoCraftingProcess }; |
71 changes: 71 additions & 0 deletions
71
src/applications/actorCraftingApp/RecipeSummarySearchStore.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import {writable, Writable, Readable, derived, Subscriber} from "svelte/store"; | ||
import {CraftingAssessment} from "./CraftingAssessment"; | ||
|
||
interface RecipeSummarySearchTerms { | ||
|
||
name?: string; | ||
craftableOnly?: boolean; | ||
|
||
} | ||
|
||
class RecipeSummarySearchStore { | ||
|
||
private readonly _availableRecipes: Writable<CraftingAssessment[]>; | ||
private readonly _searchResults: Readable<CraftingAssessment[]>; | ||
private readonly _searchTerms: Writable<RecipeSummarySearchTerms>; | ||
|
||
constructor({ | ||
availableRecipes = writable([]), | ||
searchTerms = {} | ||
}: { | ||
availableRecipes?: Writable<CraftingAssessment[]>; | ||
searchTerms?: RecipeSummarySearchTerms; | ||
} = {}) { | ||
this._availableRecipes = availableRecipes; | ||
this._searchTerms = writable(searchTerms); | ||
this._searchResults = derived( | ||
[this._availableRecipes, this._searchTerms], | ||
([$availableRecipes, $searchTerms], set) => { | ||
set(this.searchRecipes($availableRecipes, $searchTerms)); | ||
} | ||
); | ||
} | ||
|
||
set availableRecipes(value: CraftingAssessment[]) { | ||
this._availableRecipes.set(value); | ||
} | ||
|
||
private searchRecipes(recipes: CraftingAssessment[], searchTerms: RecipeSummarySearchTerms) { | ||
return recipes.filter((recipe) => { | ||
if (searchTerms.craftableOnly && !recipe.isCraftable) { | ||
return false; | ||
} | ||
if (!searchTerms.name) { | ||
return true; | ||
} | ||
return recipe.recipeName.search(new RegExp(searchTerms.name, "i")) >= 0; | ||
}); | ||
} | ||
|
||
public subscribe(subscriber: Subscriber<RecipeSummarySearchTerms[]>) { | ||
return this._searchResults.subscribe(subscriber); | ||
} | ||
|
||
get searchTerms(): Readable<RecipeSummarySearchTerms> { | ||
return this._searchTerms; | ||
} | ||
|
||
set searchTerms(value: RecipeSummarySearchTerms) { | ||
this._searchTerms.set(value); | ||
} | ||
|
||
clear() { | ||
this._searchTerms.set({ | ||
name: "", | ||
craftableOnly: false | ||
}); | ||
} | ||
|
||
} | ||
|
||
export { RecipeSummarySearchStore, RecipeSummarySearchTerms } |
Oops, something went wrong.