zenno/race/mspeed: use qualified import for race mechanics

This commit is contained in:
2026-11-27 09:10:59 -05:00
parent a10bd30bbb
commit 0a8971900d
+54 -48
View File
@@ -1,20 +1,6 @@
<script lang="ts">
import type { ComputedSeries } from '$lib/chart';
import {
acceleration,
APTITUDE_LEVELS,
AptitudeLevel,
deceleration,
HORSE_LENGTH,
moveLaneModifier,
Phase,
RunningStyle,
skillDuration,
speedGain,
spotStruggleDuration,
spotStruggleSpeed,
Stat,
} from '$lib/race';
import * as race from '$lib/race';
import StatChart from '$lib/StatChart.svelte';
import { resolve } from '$app/paths';
import SpeedDur from './SpeedDur.svelte';
@@ -22,67 +8,79 @@
let rawPower = $state(1200);
let rawGuts = $state(1200);
let raceLen = $state(1600);
let surfApt = $state(AptitudeLevel.A);
let frontApt = $state(AptitudeLevel.A);
let surfApt = $state(race.AptitudeLevel.A);
let frontApt = $state(race.AptitudeLevel.A);
let isRunaway = $state(false);
let isCareer = $state(false);
let raceLen = $state(2000);
const careerMod = $derived(isCareer ? 400 : 0);
const powerStat = $derived(rawPower + careerMod);
const gutsStat = $derived(rawGuts + careerMod);
const style = $derived(isRunaway ? RunningStyle.Runaway : RunningStyle.FrontRunner);
const style = $derived(isRunaway ? race.RunningStyle.Runaway : race.RunningStyle.FrontRunner);
const phases = [Phase.EarlyRace, Phase.MidRace, Phase.LateRace] as const;
const accel = $derived(phases.map((p) => acceleration(powerStat, style, surfApt, p)));
const decel = phases.map((p) => deceleration(p));
const phases = [race.Phase.EarlyRace, race.Phase.MidRace, race.Phase.LateRace] as const;
const accel = $derived(phases.map((p) => race.acceleration(powerStat, style, surfApt, p)));
const decel = phases.map((p) => race.deceleration(p));
const ssBoost = $derived(spotStruggleSpeed(gutsStat));
const ssDur = $derived(spotStruggleDuration(gutsStat, frontApt));
const ssBoost = $derived(race.spotStruggleSpeed(gutsStat));
const ssDur = $derived(race.spotStruggleDuration(gutsStat, frontApt));
const lcBoost = $derived(moveLaneModifier(powerStat));
const lcDur = $derived(Math.min(skillDuration(3, raceLen), 6));
const lcBoost = $derived(race.moveLaneModifier(powerStat));
const lcDur = $derived(Math.min(race.skillDuration(3, raceLen), 6));
const uniques = [
['Operation Cacao', 0.35, 5, Phase.MidRace],
["All Charged! It's Go Time! (Tokyo turf)", 0.45, 5, Phase.LateRace],
['Operation Cacao', 0.35, 5, race.Phase.MidRace],
["All Charged! It's Go Time! (Tokyo turf)", 0.45, 5, race.Phase.LateRace],
] as const;
const skills = [
['Fast-Paced', 0.15, 3, Phase.MidRace],
['Professor of Curvature (mid race)', 0.35, 2.4, Phase.MidRace],
["All Charged! It's Go Time! (inherited)", 0.25, 3, Phase.LateRace],
['Fast-Paced', 0.15, 3, race.Phase.MidRace],
['Professor of Curvature (mid race)', 0.35, 2.4, race.Phase.MidRace],
["All Charged! It's Go Time! (inherited)", 0.25, 3, race.Phase.LateRace],
] as const;
const ssY: Array<ComputedSeries | null> = $derived([
{
label: 'Aptitude S',
y: (x) => speedGain(spotStruggleSpeed(x), spotStruggleDuration(x, AptitudeLevel.S), accel[0], decel[0]) / HORSE_LENGTH,
y: (x) =>
race.speedGain(race.spotStruggleSpeed(x), race.spotStruggleDuration(x, race.AptitudeLevel.S), accel[0], decel[0]) /
race.HORSE_LENGTH,
},
{
label: 'Aptitude A',
y: (x) => speedGain(spotStruggleSpeed(x), spotStruggleDuration(x, AptitudeLevel.A), accel[0], decel[0]) / HORSE_LENGTH,
y: (x) =>
race.speedGain(race.spotStruggleSpeed(x), race.spotStruggleDuration(x, race.AptitudeLevel.A), accel[0], decel[0]) /
race.HORSE_LENGTH,
},
frontApt < AptitudeLevel.A
frontApt < race.AptitudeLevel.A
? {
label: `Aptitude ${AptitudeLevel[frontApt]}`,
y: (x) => speedGain(spotStruggleSpeed(x), spotStruggleDuration(x, frontApt), accel[0], decel[0]) / HORSE_LENGTH,
label: `Aptitude ${race.AptitudeLevel[frontApt]}`,
y: (x) =>
race.speedGain(race.spotStruggleSpeed(x), race.spotStruggleDuration(x, frontApt), accel[0], decel[0]) /
race.HORSE_LENGTH,
}
: null,
]);
const lcY: Array<ComputedSeries | null> = $derived([
{
label: 'Ideal Lane Combo',
y: (x) => speedGain(moveLaneModifier(x), lcDur, acceleration(x, style, surfApt, Phase.EarlyRace), decel[0]) / HORSE_LENGTH,
y: (x) =>
race.speedGain(race.moveLaneModifier(x), lcDur, race.acceleration(x, style, surfApt, race.Phase.EarlyRace), decel[0]) /
race.HORSE_LENGTH,
},
]);
const pcRuler = $derived({
y: speedGain(0.35, skillDuration(2.4, raceLen), accel[1], decel[1]) / HORSE_LENGTH,
y: race.speedGain(0.35, race.skillDuration(2.4, raceLen), accel[1], decel[1]) / race.HORSE_LENGTH,
label: 'Professor of Curvature',
});
const ssYRule = $derived([pcRuler, { y: speedGain(lcBoost, lcDur, accel[0], decel[0]) / HORSE_LENGTH, label: 'Lane Combo' }]);
const ssYRule = $derived([
pcRuler,
{ y: race.speedGain(lcBoost, lcDur, accel[0], decel[0]) / race.HORSE_LENGTH, label: 'Lane Combo' },
]);
const lcYRule = $derived([
pcRuler,
{ y: speedGain(ssBoost, ssDur, accel[0], decel[1]) / HORSE_LENGTH, label: 'Spot Struggle' },
{ y: race.speedGain(ssBoost, ssDur, accel[0], decel[1]) / race.HORSE_LENGTH, label: 'Spot Struggle' },
]);
</script>
@@ -99,16 +97,16 @@
<div class="m-4 md:col-span-2">
<label for="surfaceApt">Surface Aptitude</label>
<select id="surfaceApt" required bind:value={surfApt} class="w-full">
{#each APTITUDE_LEVELS as apt (apt)}
<option value={apt}>{AptitudeLevel[apt]}</option>
{#each race.APTITUDE_LEVELS as apt (apt)}
<option value={apt}>{race.AptitudeLevel[apt]}</option>
{/each}
</select>
</div>
<div class="m-4 md:col-span-2">
<label for="frontApt">Front Runner Aptitude</label>
<select id="frontApt" required bind:value={frontApt} class="w-full">
{#each APTITUDE_LEVELS as apt (apt)}
<option value={apt}>{AptitudeLevel[apt]}</option>
{#each race.APTITUDE_LEVELS as apt (apt)}
<option value={apt}>{race.AptitudeLevel[apt]}</option>
{/each}
</select>
</div>
@@ -154,20 +152,28 @@
<span class="mt-8 block w-full text-center text-lg">Unique Skills</span>
<div class="mx-auto flex flex-col place-items-center md:flex-row md:justify-center">
{#each uniques as [name, boost, dur, phase] (name)}
<SpeedDur speed={boost} dur={skillDuration(dur, raceLen)} accel={accel[phase]} decel={decel[phase]}>{name}</SpeedDur>
<SpeedDur speed={boost} dur={race.skillDuration(dur, raceLen)} accel={accel[phase]} decel={decel[phase]}>{name}</SpeedDur>
{/each}
</div>
<span class="mt-8 block w-full text-center text-lg">Inherited Uniques &amp; Other Skills</span>
<div class="mx-auto flex flex-col place-items-center md:flex-row md:justify-center">
{#each skills as [name, boost, dur, phase] (name)}
<SpeedDur speed={boost} dur={skillDuration(dur, raceLen)} accel={accel[phase]} decel={decel[phase]}>{name}</SpeedDur>
<SpeedDur speed={boost} dur={race.skillDuration(dur, raceLen)} accel={accel[phase]} decel={decel[phase]}>{name}</SpeedDur>
{/each}
</div>
<div class="mx-auto grid h-96 grid-cols-1 py-4 md:grid-cols-2">
<StatChart class="flex-1" stat={Stat.Guts} y={ssY} yLabel="Lengths Gained" range={[0, 2]} xRule={gutsStat} yRule={ssYRule} />
<StatChart
class="flex-1"
stat={Stat.Power}
stat={race.Stat.Guts}
y={ssY}
yLabel="Lengths Gained"
range={[0, 2]}
xRule={gutsStat}
yRule={ssYRule}
/>
<StatChart
class="flex-1"
stat={race.Stat.Power}
y={lcY}
yLabel="Lengths Gained"
range={[0, 1.1]}