diff --git a/src/lib/components/PlayersTable.svelte b/src/lib/components/PlayersTable.svelte new file mode 100644 index 0000000..331e33b --- /dev/null +++ b/src/lib/components/PlayersTable.svelte @@ -0,0 +1,292 @@ + + +
+
+ + +
+
+ +
+ {#each calculations as calculation, index} +
+
+ + +
    +
  • +
    +
    OVERALL
    +
    + {calculation?.levels?.player || "N/A"} +
    +
    +
  • + + {#each Object.values(Attribute) as attribute} +
  • +
    +
    + {attribute} +
    +
    + {calculation?.levels?.attributes?.[ + attribute + ] || "N/A"} +
    +
    +
  • + {/each} +
+ +
+ (calculation.levels = levelCalculator.calculate( + calculation.player, + calculation.activityPerformances, + ))} + > +
+ + + + + +
+
+ +
+ (calculation.levels = levelCalculator.calculate( + calculation.player, + calculation.activityPerformances, + ))} + > +
+ {#each calculation.activityPerformances as activityPerformance} + + {/each} +
+
+
+ +
+ {/each} +
diff --git a/src/lib/components/StandardsTable.svelte b/src/lib/components/StandardsTable.svelte new file mode 100644 index 0000000..ee00b33 --- /dev/null +++ b/src/lib/components/StandardsTable.svelte @@ -0,0 +1,127 @@ + + +
+
+
+

+ {#if !selected.cfg.disableGeneration && allStandards + .byActivity(selected.activity) + .getMetadata().generators.length} + (Generated data: {allStandards + .byActivity(selected.activity) + .getMetadata() + .generators.map((g) => g.metric) + .join(", ")}) + {:else} + (Generated data: NONE) + {/if} +

+
+
+ + {#if !selected.metrics.age} + {#each allStandards.agesFor(selected.activity, selected.metrics.gender) as age} + {@render standardsTable(selected.activity, { + ...selected.metrics, + age, + })} + {/each} + {:else} + {@render standardsTable(selected.activity, selected.metrics)} + {/if} +
+ +{#snippet standardsTable(activity: Activity, metrics: Metrics)} + {#snippet standardsTableRow(standard: Standard)} + + + {standard.metrics.weight + ? parseFloat(kgToLb(standard.metrics.weight).toFixed(2)) + : "None"} + {#each range(selected.cfg.maxLevel) as lvl} + {getLvlValue(activity, standard, lvl)} + {/each} + + {/snippet} +
+

{metrics.age}

+
+ + + + + {#each range(selected.cfg.maxLevel) as lvl} + + {/each} + + + + {#if metrics.weight} + {@const standard = allStandards + .byActivity(activity) + .byGender(metrics.gender) + .byAge(metrics.age) + .byWeight(metrics.weight) + .getOneInterpolated()} + {@render standardsTableRow(standard)} + {:else} + {@const standards = allStandards + .byActivity(activity) + .byGender(metrics.gender) + .byAge(metrics.age) + .getAllInterpolated({ normalizeForLb: true })} + {#each standards as standard} + {@render standardsTableRow(standard)} + {/each} + {/if} + +
Body weight{lvl}
+
+
+{/snippet} diff --git a/src/lib/services/calculator/main.ts b/src/lib/services/calculator/main.ts index a6f06a1..56fc0a5 100644 --- a/src/lib/services/calculator/main.ts +++ b/src/lib/services/calculator/main.ts @@ -15,7 +15,7 @@ type LevelCalculatorConfig = { compressTo?: number; } -type LevelCalculatorOutput = { +export type LevelCalculatorOutput = { player: number, attributes: Record } diff --git a/src/lib/services/calculator/util.ts b/src/lib/services/calculator/util.ts index 7791c7c..c99f501 100644 --- a/src/lib/services/calculator/util.ts +++ b/src/lib/services/calculator/util.ts @@ -6,6 +6,7 @@ import avgWeightDataRaw from "$lib/data/avg-weights.json" // ------------------------------------------------------------------------------------------------- export type Player = { + name?: string; metrics: Metrics; } diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index c0dc4af..e9699f3 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -4,7 +4,7 @@ import "../app.css"; const links = [ - { name: "Standards", path: "/standards" }, + { name: "Calculator", path: "/calculator" }, { name: "Commerce", path: "/commerce" }, ]; diff --git a/src/routes/+page.server.ts b/src/routes/+page.server.ts index 1ccd9e0..c271734 100644 --- a/src/routes/+page.server.ts +++ b/src/routes/+page.server.ts @@ -2,5 +2,5 @@ import { redirect } from '@sveltejs/kit'; import type { PageServerLoad } from './$types'; export const load: PageServerLoad = ({ }) => { - redirect(308, '/standards'); + redirect(308, '/calculator'); }; diff --git a/src/routes/calculator/+page.svelte b/src/routes/calculator/+page.svelte new file mode 100644 index 0000000..d6608aa --- /dev/null +++ b/src/routes/calculator/+page.svelte @@ -0,0 +1,242 @@ + + +
+ {#if activeTab === "standards"} +
+ + Metrics + +
+ + + + + + + +
+
+ {/if} + +
+ Data + +
+
+ + General + + +
+ +
+
+ +
+ + Data Generation + + +
+ + + + +
+
+
+
+
+ +
+ +
+ + + +
+ +{#if activeTab === "standards"} + +{/if} + +{#if activeTab === "players"} + +{/if} diff --git a/src/routes/standards/+page.svelte b/src/routes/standards/+page.svelte deleted file mode 100644 index 9199d7f..0000000 --- a/src/routes/standards/+page.svelte +++ /dev/null @@ -1,307 +0,0 @@ - - -
-
- Metrics -
- - - - - - - -
-
- -
- - Parameters - - -
-
- - General - - -
- -
-
- -
- - Data Generation - - -
- - - - -
-
-
-
-
- -
- -
-
-
-

- {#if !selected.cfg.disableGeneration && allStandards - .byActivity(selected.activity) - .getMetadata().generators.length} - (Generated data: {allStandards - .byActivity(selected.activity) - .getMetadata() - .generators.map((g) => g.metric) - .join(", ")}) - {:else} - (Generated data: NONE) - {/if} -

-
-
- - {#if !selected.metrics.age} - {#each allStandards.agesFor(selected.activity, selected.metrics.gender) as age} - {@render standardsTable(selected.activity, { - ...selected.metrics, - age, - })} - {/each} - {:else} - {@render standardsTable(selected.activity, selected.metrics)} - {/if} -
- -{#snippet standardsTable(activity: Activity, metrics: Metrics)} - {#snippet standardsTableRow(standard: Standard)} - - - {standard.metrics.weight - ? parseFloat(kgToLb(standard.metrics.weight).toFixed(2)) - : "None"} - {#each range(selected.cfg.maxLevel) as lvl} - {getLvlValue(activity, standard, lvl)} - {/each} - - {/snippet} -
-

{metrics.age}

-
- - - - - {#each range(selected.cfg.maxLevel) as lvl} - - {/each} - - - - {#if metrics.weight} - {@const standard = allStandards - .byActivity(activity) - .byGender(metrics.gender) - .byAge(metrics.age) - .byWeight(metrics.weight) - .getOneInterpolated()} - {@render standardsTableRow(standard)} - {:else} - {@const standards = allStandards - .byActivity(activity) - .byGender(metrics.gender) - .byAge(metrics.age) - .getAllInterpolated({ normalizeForLb: true })} - {#each standards as standard} - {@render standardsTableRow(standard)} - {/each} - {/if} - -
Body weight{lvl}
-
-
-{/snippet}