202 lines
8.3 KiB
Svelte
202 lines
8.3 KiB
Svelte
<script lang="ts">
|
|
import type { ComputedSeries } from '$lib/chart';
|
|
import * as race from '$lib/race';
|
|
import RaceLenSlider from '$lib/RaceLenSlider.svelte';
|
|
import StatChart from '$lib/StatChart.svelte';
|
|
import CalcInfo from '../CalcInfo.svelte';
|
|
|
|
const skillSpeeds = [0.45, 0.35, 0.25, 0.15] as const;
|
|
|
|
let rawSpeed = $state(1200);
|
|
let rawGuts = $state(1200);
|
|
let speedBonus = $state(0);
|
|
let gutsBonus = $state(0);
|
|
let style = $state(race.RunningStyle.FrontRunner);
|
|
let distanceApt = $state(race.AptitudeLevel.S);
|
|
let mood = $state(race.Mood.Normal);
|
|
let isCareer: boolean = $state(false);
|
|
|
|
let raceLen = $state(2000);
|
|
let surface = $state(race.Surface.Turf);
|
|
let conditions = $state(race.GroundConditions.Firm);
|
|
let threshMod = $state(1);
|
|
|
|
let opponentStyle = $state(race.RunningStyle.PaceChaser);
|
|
|
|
const baseSpeed = $derived(race.baseStat(mood, rawSpeed));
|
|
const baseGuts = $derived(race.baseStat(mood, rawGuts));
|
|
const adjSpeed = $derived(race.adjustedStat(race.Stat.Speed, baseSpeed, isCareer, surface, conditions, threshMod));
|
|
const adjGuts = $derived(race.adjustedStat(race.Stat.Guts, baseGuts, isCareer));
|
|
const speed = $derived(race.finalStat(adjSpeed, speedBonus));
|
|
const guts = $derived(race.finalStat(adjGuts, gutsBonus));
|
|
|
|
const distanceType = $derived(race.distance(raceLen));
|
|
|
|
const spurtSpeed = $derived(race.spurtSpeed(speed, guts, style, distanceApt, raceLen));
|
|
const duelBonus = $derived(race.duelSpeedMod(guts));
|
|
|
|
function invspd(spd: number, style: race.RunningStyle, apt: race.AptitudeLevel): number {
|
|
const f = race.inverseSpurtSpeed(spd, guts, style, apt, raceLen);
|
|
const a = race.adjustedStatFromFinal(f, speedBonus);
|
|
const b = race.baseStatFromAdjusted(race.Stat.Speed, a, isCareer, surface, conditions, race.AptitudeLevel.A, threshMod);
|
|
const r = race.rawStatFromBase(b, mood);
|
|
return Math.ceil(r);
|
|
}
|
|
|
|
const sProf = $derived([
|
|
invspd(spurtSpeed, race.RunningStyle.FrontRunner, race.AptitudeLevel.S),
|
|
invspd(spurtSpeed, race.RunningStyle.PaceChaser, race.AptitudeLevel.S),
|
|
invspd(spurtSpeed, race.RunningStyle.LateSurger, race.AptitudeLevel.S),
|
|
invspd(spurtSpeed, race.RunningStyle.EndCloser, race.AptitudeLevel.S),
|
|
invspd(spurtSpeed, race.RunningStyle.Runaway, race.AptitudeLevel.S),
|
|
]);
|
|
const aProf = $derived([
|
|
invspd(spurtSpeed, race.RunningStyle.FrontRunner, race.AptitudeLevel.A),
|
|
invspd(spurtSpeed, race.RunningStyle.PaceChaser, race.AptitudeLevel.A),
|
|
invspd(spurtSpeed, race.RunningStyle.LateSurger, race.AptitudeLevel.A),
|
|
invspd(spurtSpeed, race.RunningStyle.EndCloser, race.AptitudeLevel.A),
|
|
invspd(spurtSpeed, race.RunningStyle.Runaway, race.AptitudeLevel.A),
|
|
]);
|
|
const skillProf = $derived(skillSpeeds.map((v) => [v, invspd(spurtSpeed + v, opponentStyle, race.AptitudeLevel.S)]));
|
|
|
|
const speedChart: Array<ComputedSeries | null> = $derived([
|
|
{ label: `${race.Distance[distanceType]} S`, y: (x) => race.spurtSpeed(x, guts, style, race.AptitudeLevel.S, raceLen) },
|
|
{
|
|
label: `${race.Distance[distanceType]} ${race.AptitudeLevel[distanceApt]} + Dueling`,
|
|
y: (x) => race.spurtSpeed(x, guts, style, distanceApt, raceLen) + duelBonus,
|
|
},
|
|
distanceApt !== race.AptitudeLevel.S
|
|
? {
|
|
label: `${race.Distance[distanceType]} ${race.AptitudeLevel[distanceApt]}`,
|
|
y: (x) => race.spurtSpeed(x, guts, style, distanceApt, raceLen),
|
|
}
|
|
: null,
|
|
]);
|
|
const gutsChart: Array<ComputedSeries | null> = $derived([
|
|
{ label: `${race.Distance[distanceType]} S`, y: (x) => race.spurtSpeed(speed, x, style, race.AptitudeLevel.S, raceLen) },
|
|
{
|
|
label: `${race.Distance[distanceType]} ${race.AptitudeLevel[distanceApt]} + Dueling`,
|
|
y: (x) => race.spurtSpeed(speed, x, style, distanceApt, raceLen) + race.duelSpeedMod(x),
|
|
},
|
|
distanceApt !== race.AptitudeLevel.S
|
|
? {
|
|
label: `${race.Distance[distanceType]} ${race.AptitudeLevel[distanceApt]}`,
|
|
y: (x) => race.spurtSpeed(speed, x, style, distanceApt, raceLen),
|
|
}
|
|
: null,
|
|
]);
|
|
|
|
const range: [number, number] = [20, 27.5];
|
|
</script>
|
|
|
|
<h1 class="text-4xl">Spurt Speed Calculator</h1>
|
|
<form class="mx-auto mt-8 flex max-w-3xl flex-col gap-4">
|
|
<div class="mx-auto grid max-w-4xl grid-cols-1 gap-2 rounded-md border p-2 text-center shadow-md md:grid-cols-4">
|
|
<div>
|
|
<label for="speedStat">Speed</label>
|
|
<input type="number" id="speedStat" required bind:value={rawSpeed} class="w-full" />
|
|
</div>
|
|
<div>
|
|
<label for="gutsStat">Guts</label>
|
|
<input type="number" id="gutsStat" required bind:value={rawGuts} class="w-full" />
|
|
</div>
|
|
<div>
|
|
<label for="style">Style</label>
|
|
<select id="style" required bind:value={style} class="w-full">
|
|
{#each race.RUNNING_STYLES as [name, style] (style)}
|
|
<option value={style}>{name}</option>
|
|
{/each}
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label for="distanceApt">{race.Distance[distanceType]}</label>
|
|
<select id="distanceApt" required bind:value={distanceApt} class="w-full">
|
|
{#each race.APTITUDE_LEVELS as apt (apt)}
|
|
<option value={apt}>{race.AptitudeLevel[apt]}</option>
|
|
{/each}
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label for="speedBonus">Speed Greens</label>
|
|
<input type="number" id="speedBonus" required bind:value={speedBonus} class="w-full" />
|
|
</div>
|
|
<div>
|
|
<label for="gutsBonus">Guts Greens</label>
|
|
<input type="number" id="gutsBonus" required bind:value={gutsBonus} class="w-full" />
|
|
</div>
|
|
<div>
|
|
<label for="mood">Mood</label>
|
|
<select id="mood" required bind:value={mood} class="w-full">
|
|
{#each race.MOODS as mood (mood)}
|
|
<option value={mood}>{race.Mood[mood]}</option>
|
|
{/each}
|
|
</select>
|
|
</div>
|
|
<div class="m-4 self-center">
|
|
<label for="isCareer" class="mr-1 align-middle">In Career</label>
|
|
<input type="checkbox" id="isCareer" role="switch" bind:checked={isCareer} class="min-h-6 min-w-6 align-middle" />
|
|
</div>
|
|
</div>
|
|
<div class="mx-auto flex max-w-2xl flex-col gap-4 rounded-md border p-2 text-center shadow-md md:flex-row">
|
|
<div class="my-auto grow">
|
|
<RaceLenSlider bind:value={raceLen} />
|
|
</div>
|
|
<div class="mx-auto my-auto w-32 flex-none">
|
|
<select id="surface" required bind:value={surface} class="w-full">
|
|
<option value={race.Surface.Turf}>Turf</option>
|
|
<option value={race.Surface.Dirt}>Dirt</option>
|
|
</select>
|
|
</div>
|
|
<div class="mx-auto my-auto w-32 flex-none">
|
|
<select id="conditions" required bind:value={conditions} class="w-full">
|
|
<option value={race.GroundConditions.Firm}>Firm</option>
|
|
<option value={race.GroundConditions.Good}>Good</option>
|
|
<option value={race.GroundConditions.Soft}>Soft</option>
|
|
<option value={race.GroundConditions.Heavy}>Heavy</option>
|
|
</select>
|
|
</div>
|
|
<div class="my-auto flex flex-none flex-col">
|
|
<label for="threshMod">Stat Threshold Mod</label>
|
|
<input type="number" id="threshMod" bind:value={threshMod} min="1.0" max="1.2" step="0.025" class="my-auto flex-1" />
|
|
</div>
|
|
</div>
|
|
</form>
|
|
|
|
<div class="mx-auto mt-8 flex max-w-3xl flex-col md:flex-row">
|
|
<CalcInfo title="Target Spurt Speed" class="flex-1">{spurtSpeed.toFixed(3)} m/s</CalcInfo>
|
|
<CalcInfo title="Dueling Bonus" class="flex-1">+{duelBonus.toFixed(3)} m/s</CalcInfo>
|
|
</div>
|
|
{#each [[race.AptitudeLevel.A, aProf] as const, [race.AptitudeLevel.S, sProf] as const] as [level, inv] (level)}
|
|
<div class="mx-auto max-w-3xl">
|
|
<span class="mt-8 block w-full">
|
|
With {race.Distance[distanceType]}
|
|
{race.AptitudeLevel[level]}, the equivalent speed is
|
|
</span>
|
|
<div class="flex flex-col md:flex-row">
|
|
{#each race.RUNNING_STYLES as [styleName, s] (s)}
|
|
<CalcInfo title={styleName} class={['flex-1', { 'border-2': s === style }]}>{inv[s]}</CalcInfo>
|
|
{/each}
|
|
</div>
|
|
</div>
|
|
{/each}
|
|
<div class="mx-auto max-w-3xl">
|
|
<span class="mt-8 block w-full">
|
|
While a speed skill is active, the equivalent speed for a {race.Distance[distanceType]} S
|
|
<select id="opponentStyle" required bind:value={opponentStyle}>
|
|
{#each race.RUNNING_STYLES as [name, style] (style)}
|
|
<option value={style}>{name}</option>
|
|
{/each}
|
|
</select>
|
|
is
|
|
</span>
|
|
<div class="flex flex-col md:flex-row">
|
|
{#each skillProf as [v, inv] (v)}
|
|
<CalcInfo title={`+${v.toFixed(2)}`} class="flex-1">{inv}</CalcInfo>
|
|
{/each}
|
|
</div>
|
|
</div>
|
|
<div class="mx-auto grid h-96 grid-cols-1 py-4 md:grid-cols-2">
|
|
<StatChart stat={race.Stat.Speed} y={speedChart} yLabel="Spurt Speed (m/s)" xRule={rawSpeed} {range} />
|
|
<StatChart stat={race.Stat.Guts} y={gutsChart} yLabel="Spurt Speed (m/s)" xRule={rawGuts} {range} />
|
|
</div>
|