Finish basic setup for configuration loading
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
DEFAULT_STANDARDS_CONFIG,
|
FALLBACK_STANDARDS_CONFIG,
|
||||||
StandardsDataSchema,
|
StandardsDataSchema,
|
||||||
StandardsParamsSchema,
|
StandardsParamsSchema,
|
||||||
} from "@blade-and-brawn/calculator";
|
} from "@blade-and-brawn/calculator";
|
||||||
@@ -19,9 +19,9 @@ async function seedStandardsDataset(): Promise<string> {
|
|||||||
return existing.id;
|
return existing.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value.Assert(StandardsDataSchema, DEFAULT_STANDARDS_CONFIG.data);
|
Value.Assert(StandardsDataSchema, FALLBACK_STANDARDS_CONFIG.data);
|
||||||
const result = await db.insertInto("standards_datasets")
|
const result = await db.insertInto("standards_datasets")
|
||||||
.values({ name: DEFAULT_NAME, data: DEFAULT_STANDARDS_CONFIG.data })
|
.values({ name: DEFAULT_NAME, data: FALLBACK_STANDARDS_CONFIG.data })
|
||||||
.returning("id")
|
.returning("id")
|
||||||
.executeTakeFirstOrThrow();
|
.executeTakeFirstOrThrow();
|
||||||
log.info({ id: result.id }, "seeded default standards dataset");
|
log.info({ id: result.id }, "seeded default standards dataset");
|
||||||
@@ -43,12 +43,12 @@ async function seedStandardsConfig(datasetId: string): Promise<void> {
|
|||||||
.where("is_selected", "=", true)
|
.where("is_selected", "=", true)
|
||||||
.executeTakeFirst();
|
.executeTakeFirst();
|
||||||
|
|
||||||
Value.Assert(StandardsParamsSchema, DEFAULT_STANDARDS_CONFIG.params);
|
Value.Assert(StandardsParamsSchema, FALLBACK_STANDARDS_CONFIG.params);
|
||||||
const result = await db.insertInto("standards_configs")
|
const result = await db.insertInto("standards_configs")
|
||||||
.values({
|
.values({
|
||||||
name: DEFAULT_NAME,
|
name: DEFAULT_NAME,
|
||||||
dataset_id: datasetId,
|
dataset_id: datasetId,
|
||||||
params: DEFAULT_STANDARDS_CONFIG.params,
|
params: FALLBACK_STANDARDS_CONFIG.params,
|
||||||
is_selected: !hasSelected,
|
is_selected: !hasSelected,
|
||||||
})
|
})
|
||||||
.returning("id")
|
.returning("id")
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
type Levels,
|
type Levels,
|
||||||
DEFAULT_STANDARDS_CONFIG,
|
FALLBACK_STANDARDS_CONFIG,
|
||||||
} from "@blade-and-brawn/calculator";
|
} from "@blade-and-brawn/calculator";
|
||||||
import { Activity, clamp, Gender, range } from "@blade-and-brawn/domain";
|
import { Activity, clamp, Gender, range } from "@blade-and-brawn/domain";
|
||||||
import { levenbergMarquardt as LM } from "ml-levenberg-marquardt";
|
import { levenbergMarquardt as LM } from "ml-levenberg-marquardt";
|
||||||
@@ -15,7 +15,7 @@ for (const activity of Object.values(Activity)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const gender of Object.values(Gender)) {
|
for (const gender of Object.values(Gender)) {
|
||||||
const standardsByGender = DEFAULT_STANDARDS_CONFIG.data[
|
const standardsByGender = FALLBACK_STANDARDS_CONFIG.data[
|
||||||
activity
|
activity
|
||||||
].standards.filter((s) => s["metrics"].gender === gender);
|
].standards.filter((s) => s["metrics"].gender === gender);
|
||||||
const ages = [...new Set(standardsByGender.map((s) => s.metrics.age))];
|
const ages = [...new Set(standardsByGender.map((s) => s.metrics.age))];
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ export const app = new Elysia()
|
|||||||
(app) => app
|
(app) => app
|
||||||
// Non-authenticated
|
// Non-authenticated
|
||||||
.post("/calculate", async ({ body }) => {
|
.post("/calculate", async ({ body }) => {
|
||||||
return { levels: s.Calculator.calculate(body.player, body.activityPerformances) };
|
return { levels: await s.Calculator.calculate(body.player, body.activityPerformances) };
|
||||||
}, {
|
}, {
|
||||||
body: t.Object({
|
body: t.Object({
|
||||||
player: PlayerSchema,
|
player: PlayerSchema,
|
||||||
|
|||||||
@@ -1,14 +1,25 @@
|
|||||||
import { LevelCalculator, Standards, DEFAULT_STANDARDS_CONFIG, type StandardsParams, StandardsParamsSchema, StandardsDataSchema, type StandardsConfig } from "@blade-and-brawn/calculator";
|
import { LevelCalculator, Standards, FALLBACK_STANDARDS_CONFIG, type StandardsParams, StandardsParamsSchema, StandardsDataSchema, type StandardsConfig } from "@blade-and-brawn/calculator";
|
||||||
import type { ActivityPerformance, Player } from "@blade-and-brawn/domain";
|
import type { ActivityPerformance, Player } from "@blade-and-brawn/domain";
|
||||||
import { db } from "../database/db";
|
import { db } from "../database/db";
|
||||||
import { Value } from "@sinclair/typebox/value";
|
import { Value } from "@sinclair/typebox/value";
|
||||||
import { log } from "../util";
|
import { log } from "../util";
|
||||||
|
|
||||||
export class CalculatorService {
|
export class CalculatorService {
|
||||||
private Calculator = new LevelCalculator(new Standards(DEFAULT_STANDARDS_CONFIG));
|
private Calculator = new LevelCalculator(new Standards(FALLBACK_STANDARDS_CONFIG));
|
||||||
Standards: StandardsService = new StandardsService(this.Calculator);
|
Standards: StandardsService = new StandardsService(this.Calculator);
|
||||||
|
private ready: Promise<void>;
|
||||||
|
|
||||||
calculate(player: Player, activityPerformances: ActivityPerformance[]) {
|
constructor() {
|
||||||
|
// Load the selected config on startup instead of waiting for the
|
||||||
|
// first `calculate()` call. If it fails (e.g. no config selected
|
||||||
|
// yet, DB unreachable at boot), fall back to DEFAULT_STANDARDS_CONFIG
|
||||||
|
// and keep serving — it'll retry on the next refresh.
|
||||||
|
this.ready = this.Standards.Config.refresh()
|
||||||
|
.catch((err) => log.error({ err }, "failed to load initial standards config, falling back to defaults"));
|
||||||
|
}
|
||||||
|
|
||||||
|
async calculate(player: Player, activityPerformances: ActivityPerformance[]) {
|
||||||
|
await this.ready;
|
||||||
this.Standards.Config.refresh({ onlyIfStale: true }).catch((err) => log.error({ err }, "failed to refresh standards config"));
|
this.Standards.Config.refresh({ onlyIfStale: true }).catch((err) => log.error({ err }, "failed to refresh standards config"));
|
||||||
return this.Calculator.calculate(player, activityPerformances);
|
return this.Calculator.calculate(player, activityPerformances);
|
||||||
}
|
}
|
||||||
@@ -92,7 +103,7 @@ class StandardsConfigService {
|
|||||||
.set({ is_selected: true })
|
.set({ is_selected: true })
|
||||||
.where("id", "=", id)
|
.where("id", "=", id)
|
||||||
.execute();
|
.execute();
|
||||||
if (result[0]?.numUpdatedRows === 0n) throw new Error(`No config with id "${id}"`);
|
if (result[0]?.numUpdatedRows === 0n) throw new Error(`No standards config with id "${id}"`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import {
|
import {
|
||||||
Standards,
|
Standards,
|
||||||
type Standard,
|
type Standard,
|
||||||
type StandardsParams,
|
type StandardsConfig,
|
||||||
} from "@blade-and-brawn/calculator";
|
} from "@blade-and-brawn/calculator";
|
||||||
import {
|
import {
|
||||||
Activity,
|
Activity,
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
selected: {
|
selected: {
|
||||||
activity: Activity;
|
activity: Activity;
|
||||||
metrics: Metrics;
|
metrics: Metrics;
|
||||||
params: StandardsParams;
|
standardsConfig: StandardsConfig;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<p class="text-xs label">
|
<p class="text-xs label">
|
||||||
{#if selected.params.activity[selected.activity].enableGeneration && allStandards
|
{#if selected.standardsConfig.params.activity[selected.activity].enableGeneration && allStandards
|
||||||
.byActivity(selected.activity)
|
.byActivity(selected.activity)
|
||||||
.getMetadata().generators.length}
|
.getMetadata().generators.length}
|
||||||
(Generated data: {allStandards
|
(Generated data: {allStandards
|
||||||
@@ -87,7 +87,7 @@
|
|||||||
? parseFloat(kgToLb(standard.metrics.weight).toFixed(2))
|
? parseFloat(kgToLb(standard.metrics.weight).toFixed(2))
|
||||||
: "None"}</th
|
: "None"}</th
|
||||||
>
|
>
|
||||||
{#each range(selected.params.global.maxLevel).map((i) => ++i) as lvl}
|
{#each range(selected.standardsConfig.params.global.maxLevel).map((i) => ++i) as lvl}
|
||||||
<td>{getLvlValue(activity, standard, lvl)}</td>
|
<td>{getLvlValue(activity, standard, lvl)}</td>
|
||||||
{/each}
|
{/each}
|
||||||
</tr>
|
</tr>
|
||||||
@@ -99,7 +99,7 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Body weight</th>
|
<th>Body weight</th>
|
||||||
{#each range(selected.params.global.maxLevel).map((i) => ++i) as lvl}
|
{#each range(selected.standardsConfig.params.global.maxLevel).map((i) => ++i) as lvl}
|
||||||
<td>{lvl}</td>
|
<td>{lvl}</td>
|
||||||
{/each}
|
{/each}
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {
|
import {
|
||||||
DEFAULT_STANDARDS_CONFIG,
|
|
||||||
Standards,
|
Standards,
|
||||||
type StandardsParams,
|
StandardsConfigSchema,
|
||||||
|
type StandardsConfig,
|
||||||
} from "@blade-and-brawn/calculator";
|
} from "@blade-and-brawn/calculator";
|
||||||
import {
|
import {
|
||||||
Activity,
|
Activity,
|
||||||
@@ -12,6 +12,9 @@
|
|||||||
} from "@blade-and-brawn/domain";
|
} from "@blade-and-brawn/domain";
|
||||||
import StandardsTable from "$lib/components/StandardsTable.svelte";
|
import StandardsTable from "$lib/components/StandardsTable.svelte";
|
||||||
import PlayersTable from "$lib/components/PlayersTable.svelte";
|
import PlayersTable from "$lib/components/PlayersTable.svelte";
|
||||||
|
import { api } from "$lib/api";
|
||||||
|
import { Value } from "@sinclair/typebox/value";
|
||||||
|
import { onMount } from "svelte";
|
||||||
|
|
||||||
let activeTab = $state("standards");
|
let activeTab = $state("standards");
|
||||||
|
|
||||||
@@ -22,9 +25,7 @@
|
|||||||
age: null as number | null,
|
age: null as number | null,
|
||||||
weight: null as number | null, // lb
|
weight: null as number | null, // lb
|
||||||
},
|
},
|
||||||
params: structuredClone(
|
standardsConfig: null as StandardsConfig | null,
|
||||||
DEFAULT_STANDARDS_CONFIG.params,
|
|
||||||
) as StandardsParams,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const selected = $derived({
|
const selected = $derived({
|
||||||
@@ -34,32 +35,61 @@
|
|||||||
age: input.metrics.age ?? 0,
|
age: input.metrics.age ?? 0,
|
||||||
weight: lbToKg(input.metrics.weight ?? 0),
|
weight: lbToKg(input.metrics.weight ?? 0),
|
||||||
} as Metrics,
|
} as Metrics,
|
||||||
params: input.params,
|
standardsConfig: input.standardsConfig,
|
||||||
});
|
});
|
||||||
|
|
||||||
const allStandards = $derived(
|
const allStandards = $derived(
|
||||||
new Standards({
|
selected.standardsConfig
|
||||||
data: DEFAULT_STANDARDS_CONFIG.data,
|
? new Standards($state.snapshot(selected.standardsConfig))
|
||||||
params: selected.params,
|
: null,
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$effect(() => {
|
let standardsConfigLoadError = $state<string | null>(null);
|
||||||
const savedParameters = localStorage.getItem("parameters");
|
|
||||||
if (!savedParameters) return;
|
|
||||||
|
|
||||||
const parsed = JSON.parse(savedParameters);
|
onMount(async () => {
|
||||||
if (parsed?.params) input = parsed;
|
try {
|
||||||
|
const savedInputStringified = localStorage.getItem("input");
|
||||||
|
if (savedInputStringified) {
|
||||||
|
input = JSON.parse(savedInputStringified);
|
||||||
|
} else {
|
||||||
|
const res = await api.calculator.config.get();
|
||||||
|
if (res.error) throw res.error;
|
||||||
|
Value.Assert(StandardsConfigSchema, res.data);
|
||||||
|
input.standardsConfig = res.data;
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error("failed to load standards config", err);
|
||||||
|
const value = (err as { value?: { error?: string } })?.value;
|
||||||
|
standardsConfigLoadError =
|
||||||
|
value?.error ??
|
||||||
|
(err instanceof Error ? err.message : "Unknown error");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
localStorage.setItem("parameters", JSON.stringify(input));
|
localStorage.setItem("input", JSON.stringify(input));
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<section class="w-full flex justify-between gap-2 pt-10 items-center">
|
{#if !(input.standardsConfig && allStandards)}
|
||||||
|
<div class="w-full flex justify-center pt-10">
|
||||||
|
{#if standardsConfigLoadError}
|
||||||
|
<div role="alert" class="alert alert-error max-w-lg">
|
||||||
|
<span>
|
||||||
|
Failed to load the standards configuration: {standardsConfigLoadError}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
<span class="loading loading-spinner loading-lg"></span>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
{@const standardsConfig = input.standardsConfig}
|
||||||
|
<section class="w-full flex justify-between gap-2 pt-10 items-center">
|
||||||
<fieldset class="fieldset bg-base-200 p-6 max-w-lg">
|
<fieldset class="fieldset bg-base-200 p-6 max-w-lg">
|
||||||
<legend class="fieldset-legend text-lg font-semibold"> Data </legend>
|
<legend class="fieldset-legend text-lg font-semibold">
|
||||||
|
Data
|
||||||
|
</legend>
|
||||||
|
|
||||||
<div class="flex gap-4">
|
<div class="flex gap-4">
|
||||||
<fieldset class="fieldset bg-base-300 p-3 max-w-xl">
|
<fieldset class="fieldset bg-base-300 p-3 max-w-xl">
|
||||||
@@ -92,7 +122,9 @@
|
|||||||
min="1"
|
min="1"
|
||||||
max="100"
|
max="100"
|
||||||
placeholder="5"
|
placeholder="5"
|
||||||
bind:value={input.params.global.maxLevel}
|
bind:value={
|
||||||
|
standardsConfig.params.global.maxLevel
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
@@ -108,8 +140,9 @@
|
|||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
bind:checked={
|
bind:checked={
|
||||||
input.params.activity[selected.activity]
|
standardsConfig.params.activity[
|
||||||
.enableGeneration
|
selected.activity
|
||||||
|
].enableGeneration
|
||||||
}
|
}
|
||||||
class="toggle toggle-lg m-auto"
|
class="toggle toggle-lg m-auto"
|
||||||
/>
|
/>
|
||||||
@@ -124,10 +157,11 @@
|
|||||||
step=".05"
|
step=".05"
|
||||||
placeholder=".1"
|
placeholder=".1"
|
||||||
bind:value={
|
bind:value={
|
||||||
input.params.activity[selected.activity]
|
standardsConfig.params.activity[
|
||||||
.weightModifier
|
selected.activity
|
||||||
|
].weightModifier
|
||||||
}
|
}
|
||||||
disabled={!selected.params.activity[
|
disabled={!standardsConfig.params.activity[
|
||||||
selected.activity
|
selected.activity
|
||||||
].enableGeneration}
|
].enableGeneration}
|
||||||
/>
|
/>
|
||||||
@@ -157,10 +191,11 @@
|
|||||||
max="1"
|
max="1"
|
||||||
step=".05"
|
step=".05"
|
||||||
bind:value={
|
bind:value={
|
||||||
input.params.activity[selected.activity]
|
standardsConfig.params.activity[
|
||||||
.difficultyModifier
|
selected.activity
|
||||||
|
].difficultyModifier
|
||||||
}
|
}
|
||||||
disabled={!selected.params.activity[
|
disabled={!standardsConfig.params.activity[
|
||||||
selected.activity
|
selected.activity
|
||||||
].enableGeneration}
|
].enableGeneration}
|
||||||
/>
|
/>
|
||||||
@@ -174,10 +209,11 @@
|
|||||||
max="1"
|
max="1"
|
||||||
step=".05"
|
step=".05"
|
||||||
bind:value={
|
bind:value={
|
||||||
input.params.activity[selected.activity]
|
standardsConfig.params.activity[
|
||||||
.ageModifier
|
selected.activity
|
||||||
|
].ageModifier
|
||||||
}
|
}
|
||||||
disabled={!selected.params.activity[
|
disabled={!standardsConfig.params.activity[
|
||||||
selected.activity
|
selected.activity
|
||||||
].enableGeneration}
|
].enableGeneration}
|
||||||
/>
|
/>
|
||||||
@@ -191,16 +227,20 @@
|
|||||||
max="100"
|
max="100"
|
||||||
step="1"
|
step="1"
|
||||||
bind:value={
|
bind:value={
|
||||||
input.params.activity[selected.activity].peakAge
|
standardsConfig.params.activity[
|
||||||
|
selected.activity
|
||||||
|
].peakAge
|
||||||
}
|
}
|
||||||
disabled={!selected.params.activity[
|
disabled={!standardsConfig.params.activity[
|
||||||
selected.activity
|
selected.activity
|
||||||
].enableGeneration}
|
].enableGeneration}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<fieldset class="fieldset bg-base-200 p-3 max-w-xl">
|
<fieldset class="fieldset bg-base-200 p-3 max-w-xl">
|
||||||
<legend class="fieldset-legend text-sm font-semibold">
|
<legend
|
||||||
|
class="fieldset-legend text-sm font-semibold"
|
||||||
|
>
|
||||||
Stretch
|
Stretch
|
||||||
</legend>
|
</legend>
|
||||||
<label>
|
<label>
|
||||||
@@ -212,10 +252,11 @@
|
|||||||
max="10"
|
max="10"
|
||||||
step="1"
|
step="1"
|
||||||
bind:value={
|
bind:value={
|
||||||
input.params.activity[selected.activity]
|
standardsConfig.params.activity[
|
||||||
.stretch.lower
|
selected.activity
|
||||||
|
].stretch.lower
|
||||||
}
|
}
|
||||||
disabled={!selected.params.activity[
|
disabled={!standardsConfig.params.activity[
|
||||||
selected.activity
|
selected.activity
|
||||||
].enableGeneration}
|
].enableGeneration}
|
||||||
/>
|
/>
|
||||||
@@ -229,10 +270,11 @@
|
|||||||
max="10"
|
max="10"
|
||||||
step="1"
|
step="1"
|
||||||
bind:value={
|
bind:value={
|
||||||
input.params.activity[selected.activity]
|
standardsConfig.params.activity[
|
||||||
.stretch.upper
|
selected.activity
|
||||||
|
].stretch.upper
|
||||||
}
|
}
|
||||||
disabled={!selected.params.activity[
|
disabled={!standardsConfig.params.activity[
|
||||||
selected.activity
|
selected.activity
|
||||||
].enableGeneration}
|
].enableGeneration}
|
||||||
/>
|
/>
|
||||||
@@ -288,11 +330,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
{/if}
|
{/if}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
|
|
||||||
<div role="tablist" class="tabs tabs-border">
|
<div role="tablist" class="tabs tabs-border">
|
||||||
<button
|
<button
|
||||||
role="tab"
|
role="tab"
|
||||||
class="tab"
|
class="tab"
|
||||||
@@ -310,12 +352,16 @@
|
|||||||
>
|
>
|
||||||
Players
|
Players
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if activeTab === "standards"}
|
{#if activeTab === "standards"}
|
||||||
<StandardsTable {selected} {allStandards} />
|
<StandardsTable
|
||||||
{/if}
|
selected={{ ...selected, standardsConfig }}
|
||||||
|
{allStandards}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if activeTab === "players"}
|
{#if activeTab === "players"}
|
||||||
<PlayersTable {allStandards} />
|
<PlayersTable {allStandards} />
|
||||||
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,79 @@
|
|||||||
|
{
|
||||||
|
"global": {
|
||||||
|
"maxLevel": 100
|
||||||
|
},
|
||||||
|
"activity": {
|
||||||
|
"BackSquat": {
|
||||||
|
"enableGeneration": true,
|
||||||
|
"weightModifier": 0,
|
||||||
|
"weightSkew": 0,
|
||||||
|
"ageModifier": 0,
|
||||||
|
"difficultyModifier": 0.3,
|
||||||
|
"peakAge": 0,
|
||||||
|
"stretch": {
|
||||||
|
"upper": 0,
|
||||||
|
"lower": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"BenchPress": {
|
||||||
|
"enableGeneration": true,
|
||||||
|
"weightModifier": 0,
|
||||||
|
"weightSkew": 0,
|
||||||
|
"ageModifier": 0,
|
||||||
|
"difficultyModifier": 0.05,
|
||||||
|
"peakAge": 0,
|
||||||
|
"stretch": {
|
||||||
|
"upper": 1,
|
||||||
|
"lower": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Deadlift": {
|
||||||
|
"enableGeneration": true,
|
||||||
|
"weightModifier": 0,
|
||||||
|
"weightSkew": 0,
|
||||||
|
"ageModifier": 0,
|
||||||
|
"difficultyModifier": -0.05,
|
||||||
|
"peakAge": 0,
|
||||||
|
"stretch": {
|
||||||
|
"upper": 1,
|
||||||
|
"lower": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Run": {
|
||||||
|
"enableGeneration": true,
|
||||||
|
"weightModifier": 0.1,
|
||||||
|
"weightSkew": 0,
|
||||||
|
"ageModifier": 0,
|
||||||
|
"difficultyModifier": 0.35,
|
||||||
|
"peakAge": 0,
|
||||||
|
"stretch": {
|
||||||
|
"upper": 1,
|
||||||
|
"lower": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"BroadJump": {
|
||||||
|
"enableGeneration": true,
|
||||||
|
"weightModifier": -0.1,
|
||||||
|
"weightSkew": 0,
|
||||||
|
"ageModifier": -0.25,
|
||||||
|
"difficultyModifier": -0.15,
|
||||||
|
"peakAge": 23,
|
||||||
|
"stretch": {
|
||||||
|
"upper": 3,
|
||||||
|
"lower": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ConeDrill": {
|
||||||
|
"enableGeneration": true,
|
||||||
|
"weightModifier": -0.1,
|
||||||
|
"weightSkew": 0,
|
||||||
|
"ageModifier": -0.25,
|
||||||
|
"difficultyModifier": 0.15,
|
||||||
|
"peakAge": 23,
|
||||||
|
"stretch": {
|
||||||
|
"upper": 0,
|
||||||
|
"lower": 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,8 +10,8 @@ import {
|
|||||||
type Player,
|
type Player,
|
||||||
} from "@blade-and-brawn/domain";
|
} from "@blade-and-brawn/domain";
|
||||||
import { levenbergMarquardt as LM } from "ml-levenberg-marquardt";
|
import { levenbergMarquardt as LM } from "ml-levenberg-marquardt";
|
||||||
import defaultStandardsParamsJson from "./data/standards/default-params.json" with { type: "json" };
|
import defaultStandardsParamsJson from "./data/standards/fallback-params.json" with { type: "json" };
|
||||||
import defaultStandardsDataJson from "./data/standards/default-data.json" with { type: "json" };
|
import defaultStandardsDataJson from "./data/standards/fallback-data.json" with { type: "json" };
|
||||||
import { getAvgWeight } from "./avg-weights";
|
import { getAvgWeight } from "./avg-weights";
|
||||||
import { StandardsDataSchema, StandardsParamsSchema, type LevelCalculatorOutput, type Levels, type NumberMetric, type Standard, type StandardsConfig, type StandardsData } from "./models";
|
import { StandardsDataSchema, StandardsParamsSchema, type LevelCalculatorOutput, type Levels, type NumberMetric, type Standard, type StandardsConfig, type StandardsData } from "./models";
|
||||||
import { Value } from "@sinclair/typebox/value";
|
import { Value } from "@sinclair/typebox/value";
|
||||||
@@ -36,7 +36,7 @@ const metricPriority = (m: NumberMetric) => {
|
|||||||
|
|
||||||
Value.Assert(StandardsDataSchema, defaultStandardsDataJson);
|
Value.Assert(StandardsDataSchema, defaultStandardsDataJson);
|
||||||
Value.Assert(StandardsParamsSchema, defaultStandardsParamsJson);
|
Value.Assert(StandardsParamsSchema, defaultStandardsParamsJson);
|
||||||
export const DEFAULT_STANDARDS_CONFIG: StandardsConfig = {
|
export const FALLBACK_STANDARDS_CONFIG: StandardsConfig = {
|
||||||
data: defaultStandardsDataJson,
|
data: defaultStandardsDataJson,
|
||||||
params: defaultStandardsParamsJson
|
params: defaultStandardsParamsJson
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user