zenno: format & lint fixes

This commit is contained in:
2026-05-24 18:06:51 -04:00
parent 0f14ece4da
commit bae79a5320
6 changed files with 433 additions and 326 deletions
+37 -12
View File
@@ -1,8 +1,8 @@
// Umamusume race mechanics adapted from KuromiAK's doc:
// https://docs.google.com/document/d/15VzW9W2tXBBTibBRbZ8IVpW6HaMX8H0RP03kq6Az7Xg/edit?usp=sharing
import * as math from "mathjs";
import { binomPMF } from "./prob";
import * as math from 'mathjs';
import { binomPMF } from './prob';
/**
* Fundamental stats of umas.
@@ -115,7 +115,13 @@ const distanceProficiencyMod = [0.1, 0.2, 0.4, 0.6, 0.8, 0.9, 1.0, 1.05] as cons
* @param style Horse's running style
* @param phase Phase of the current section
*/
export function sectionSpeed(raceLen: number, baseWit: number, witStat: number, style: RunningStyle, phase: Exclude<Phase, Phase.LateRace>): [number, number];
export function sectionSpeed(
raceLen: number,
baseWit: number,
witStat: number,
style: RunningStyle,
phase: Exclude<Phase, Phase.LateRace>,
): [number, number];
/**
* Calculate the range of section speed values for a horse not spurting during late race.
* @param raceLen Length of the race in meters
@@ -126,19 +132,38 @@ export function sectionSpeed(raceLen: number, baseWit: number, witStat: number,
* @param distance Hores's distance proficiency aptitude
* @param phase Phase.LateRace
*/
export function sectionSpeed(raceLen: number, speedStat: number, baseWit: number, witStat: number, style: RunningStyle, distance: AptitudeLevel, phase: Phase.LateRace): [number, number];
export function sectionSpeed(raceLen: number, speedStatOrBaseWit: number, baseWitOrWitStat: number, witStatOrStyle: number | RunningStyle, styleOrPhase: RunningStyle | Phase, distance?: AptitudeLevel, lateRace?: Phase.LateRace): [number, number] {
export function sectionSpeed(
raceLen: number,
speedStat: number,
baseWit: number,
witStat: number,
style: RunningStyle,
distance: AptitudeLevel,
phase: Phase.LateRace,
): [number, number];
export function sectionSpeed(
raceLen: number,
speedStatOrBaseWit: number,
baseWitOrWitStat: number,
witStatOrStyle: number | RunningStyle,
styleOrPhase: RunningStyle | Phase,
distance?: AptitudeLevel,
lateRace?: Phase.LateRace,
): [number, number] {
const speedStat = lateRace !== undefined ? speedStatOrBaseWit : 0;
const baseWit = lateRace !== undefined ? baseWitOrWitStat : speedStatOrBaseWit;
const witStat = lateRace !== undefined ? witStatOrStyle : baseWitOrWitStat;
const style = lateRace !== undefined ? styleOrPhase as RunningStyle : witStatOrStyle as RunningStyle;
const phase = lateRace !== undefined ? lateRace : styleOrPhase as Phase;
const style = lateRace !== undefined ? (styleOrPhase as RunningStyle) : (witStatOrStyle as RunningStyle);
const phase = lateRace !== undefined ? lateRace : (styleOrPhase as Phase);
const base = baseSpeed(raceLen);
const baseTarget = base * speedStrategyPhaseCoeff[style][phase];
const late = phase === Phase.LateRace ? (math.sqrt(500 * speedStat) as number) * distanceProficiencyMod[distance ?? AptitudeLevel.A] * 0.002 : 0;
const u = witStat / 550000 * math.log10(baseWit * 0.1);
const late =
phase === Phase.LateRace
? (math.sqrt(500 * speedStat) as number) * distanceProficiencyMod[distance ?? AptitudeLevel.A] * 0.002
: 0;
const u = (witStat / 550000) * math.log10(baseWit * 0.1);
const l = u - 0.0065;
return [baseTarget + late + base*l, baseTarget + late + base*u];
return [baseTarget + late + base * l, baseTarget + late + base * u];
}
/**
@@ -302,7 +327,7 @@ export function spotStruggleDuration(gutsStat: number, frontAptitude: AptitudeLe
* @returns Speed modifier for running uphill, a negative value
*/
export function uphillMod(powerStat: number, slopePer: number): number {
return slopePer * -200/powerStat;
return (slopePer * -200) / powerStat;
}
/**
@@ -323,7 +348,7 @@ export function moveLaneModifier(powerStat: number): number {
* @returns Probability of exactly n skills out of N passing wit checks
*/
export function skillWitCheck(baseWit: number, N?: number, n?: number): number {
const p = Math.max(0.2, 1 - 90/baseWit);
const p = Math.max(0.2, 1 - 90 / baseWit);
return binomPMF(p, N ?? 1, n ?? 1);
}