Standards levelign fix

This commit is contained in:
Dominic Ferrando
2025-10-17 19:19:44 -04:00
parent 5d06e3bd8d
commit bd87791ed9
3 changed files with 17 additions and 23 deletions
+3 -15
View File
@@ -1,12 +1,10 @@
<script lang="ts"> <script lang="ts">
import { import {
Standards, Standards,
type ActivityStandards,
type Metrics, type Metrics,
type Standard, type Standard,
type StandardsConfig, type StandardsConfig,
} from "$lib/services/calculator/main"; } from "$lib/services/calculator/main";
import allStandardsRaw from "$lib/data/standards.json" assert { type: "json" };
import { import {
Activity, Activity,
cmToIn, cmToIn,
@@ -26,17 +24,6 @@
const { selected, allStandards }: Props = $props(); const { selected, allStandards }: Props = $props();
const allAnchorStandards = $derived.by(() => {
const standardsCfg = structuredClone(selected.cfg);
for (const activityCfg of Object.values(standardsCfg.activity)) {
activityCfg.disableGeneration = true;
}
return new Standards(
allStandardsRaw as ActivityStandards,
standardsCfg,
);
});
const getLvlValue = ( const getLvlValue = (
activity: Activity, activity: Activity,
standard: Standard, standard: Standard,
@@ -46,7 +33,8 @@
const unit = allStandards.byActivity(activity).getMetadata().unit; const unit = allStandards.byActivity(activity).getMetadata().unit;
switch (unit) { switch (unit) {
case "ms": case "ms":
return msToTime(rawValue, activity === Activity.ConeDrill); const seconds = (rawValue / 1000).toFixed(1);
return `${seconds}`;
case "cm": { case "cm": {
const totalInches = cmToIn(rawValue); const totalInches = cmToIn(rawValue);
const feet = Math.floor(totalInches / 12); const feet = Math.floor(totalInches / 12);
@@ -65,7 +53,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.cfg.activity[selected.activity].disableGeneration && allStandards {#if selected.cfg.activity[selected.activity].enableGeneration && allStandards
.byActivity(selected.activity) .byActivity(selected.activity)
.getMetadata().generators.length} .getMetadata().generators.length}
(Generated data: {allStandards (Generated data: {allStandards
+2 -2
View File
@@ -5294,7 +5294,7 @@
"2": 8700, "2": 8700,
"3": 7800, "3": 7800,
"4": 7000, "4": 7000,
"5": 6500 "5": 6000
} }
}, },
{ {
@@ -5308,7 +5308,7 @@
"2": 9600, "2": 9600,
"3": 8700, "3": 8700,
"4": 7800, "4": 7800,
"5": 7200 "5": 6700
} }
} }
] ]
+12 -6
View File
@@ -5,10 +5,10 @@ import { Activity, Attribute, Gender, getAvgWeight, kgToLb, lbToKg, type Activit
// http://lonkilgore.com/resources/Lon_Kilgore_Strength_Standard_Tables-Copyright-2023.pdf // http://lonkilgore.com/resources/Lon_Kilgore_Strength_Standard_Tables-Copyright-2023.pdf
// 1 mile run: // 1 mile run:
// https://runninglevel.com/running-times/1-mile-times // https://runninglevel.com/running-times/1-mile-times
// Dash:
// https://marathonhandbook.com/average-100-meter-time/
// Broad Jump: // Broad Jump:
// https://nrpt.co.uk/training/tests/power/broad.htm // https://nrpt.co.uk/training/tests/power/broad.htm
// 3 Cone drill:
// https://nflsavant.com/combine.php?utm_source=chatgpt.com
export type LevelCalculatorOutput = { export type LevelCalculatorOutput = {
player: number, player: number,
@@ -213,11 +213,17 @@ export class Standards {
// prepare data // prepare data
this.activityStandards = structuredClone(activityStandards); this.activityStandards = structuredClone(activityStandards);
for (const activity of Object.keys(this.activityStandards) as Activity[]) { for (const activity of Object.keys(this.activityStandards) as Activity[]) {
// expand/compress
for (const standard of this.activityStandards[activity].standards) { for (const standard of this.activityStandards[activity].standards) {
const expandedLevels = this.expandLevels(standard.levels, 5); // expand
const compressedLevels = this.compressLevels(expandedLevels, this.cfg.global.maxLevel); let i = 1;
standard.levels = compressedLevels; while (Object.keys(standard.levels).length < this.cfg.global.maxLevel) {
standard.levels = this.expandLevels(standard.levels, i++);
}
// compress
if (Object.keys(standard.levels).length > this.cfg.global.maxLevel) {
standard.levels = this.compressLevels(standard.levels, this.cfg.global.maxLevel);
}
// apply skew config // apply skew config
for (const level in standard.levels) { for (const level in standard.levels) {