Skip to content

Commit

Permalink
#84 - added store and altered progress calc based on subclass presence
Browse files Browse the repository at this point in the history
  • Loading branch information
geoidesic committed Aug 9, 2024
1 parent 014dc89 commit 4daf9e9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/molecules/Footer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
isMultiClass,
pointBuy,
abilityRolls,
isStandardArrayValues
isStandardArrayValues,
subClassesForClass
} from "~/src/helpers/store";
// import { prepareItemForDrop } from "~/src/helpers/Utility";
import ProgressBar from "~/src/components/molecules/ProgressBar.svelte";
Expand Down Expand Up @@ -64,6 +65,8 @@
// Derive the progress value from the store states
const progress = derived(stores, ($stores) => {
const [race, characterClass, characterSubClass, background, abilityGenerationMethod, pointBuy, abilityRolls, isStandardArrayValues] = $stores;
//- @why: some classes don't have subclasses until later levels
const length = $subClassesForClass.length > 0 ? 5 : 4;
const total = $stores.slice(0, 5).length; // Only count the main five stores for total
const completed = $stores.slice(0, 5).filter((value, index) => {
if (index === 4) { // Index of abilityGenerationMethod
Expand Down
3 changes: 3 additions & 0 deletions src/components/organisms/dnd5e/Tabs/Class.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
characterSubClass,
level,
tabs,
subClassesForClass
} from "~/src/helpers/store";
import { localize } from "#runtime/svelte/helper";
import { TJSSelect } from "@typhonjs-fvtt/svelte-standard/component";
Expand Down Expand Up @@ -106,6 +107,8 @@
await tick();
subClassesIndex = await getFilteredSubclassIndex();
$subClassesForClass = subClassesIndex;
await tick();
importClassAdvancements();
richHTML = await TextEditor.enrichHTML(html);
Expand Down
3 changes: 3 additions & 0 deletions src/helpers/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const tabs = writable(initialTabs);
export const levelUpTabs = writable(upTabs);
export const actorInGame = writable(false);
export const abilityGenerationMethod = writable(null);
export const subClassesForClass = writable([]);

export const isMultiClass = derived([characterClass, activeClass, newClassLevel], ([$characterClass, $characterSubClass, $newClassLevel]) => {
if($newClassLevel) return false;
Expand Down Expand Up @@ -110,4 +111,6 @@ export function resetStores() {
isActorCreated.set(false);
actorInGame.set(false);
abilityGenerationMethod.set(null);
subClassesForClass = writable([]);

}

0 comments on commit 4daf9e9

Please sign in to comment.