zenno: format & lint fixes
This commit is contained in:
@@ -1,27 +1,28 @@
|
||||
<script lang="ts">
|
||||
import { skills, ZERO_SKILL, type Skill } from "./data/skill";
|
||||
import { skills, ZERO_SKILL, type Skill } from './data/skill';
|
||||
|
||||
interface CommonProps {
|
||||
hint?: string;
|
||||
mention?: boolean;
|
||||
}
|
||||
interface CommonProps {
|
||||
hint?: string;
|
||||
mention?: boolean;
|
||||
}
|
||||
|
||||
type Props = CommonProps & ({skill: number, name?: never} | {name: string, skill?: never});
|
||||
type Props = CommonProps & ({ skill: number; name?: never } | { name: string; skill?: never });
|
||||
|
||||
let {hint, mention, skill, name}: Props = $props();
|
||||
let { hint, mention, skill, name }: Props = $props();
|
||||
|
||||
const s: Readonly<Skill> = $derived.by(() => {
|
||||
const l = skill != null ? skills.global.filter((s) => s.skill_id === skill) : skills.global.filter((s) => s.name.includes(name!));
|
||||
if (name != null) {
|
||||
console.warn(`skills specified as ${name} (${hint}):`, l);
|
||||
}
|
||||
if (l.length === 0) {
|
||||
return ZERO_SKILL;
|
||||
}
|
||||
return l[0];
|
||||
});
|
||||
const s: Readonly<Skill> = $derived.by(() => {
|
||||
const l =
|
||||
skill != null ? skills.global.filter((s) => s.skill_id === skill) : skills.global.filter((s) => s.name.includes(name!));
|
||||
if (name != null) {
|
||||
console.warn(`skills specified as ${name} (${hint}):`, l);
|
||||
}
|
||||
if (l.length === 0) {
|
||||
return ZERO_SKILL;
|
||||
}
|
||||
return l[0];
|
||||
});
|
||||
|
||||
const spanClass = $derived(mention ? 'italic' : 'font-bold')
|
||||
const spanClass = $derived(mention ? 'italic' : 'font-bold');
|
||||
</script>
|
||||
|
||||
<span class={spanClass}>{s.name}</span>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import skillGlobal from '../../../../global/skill.json'
|
||||
import groupGlobal from '../../../../global/skill-group.json'
|
||||
import skillGlobal from '../../../../global/skill.json';
|
||||
import groupGlobal from '../../../../global/skill-group.json';
|
||||
|
||||
/**
|
||||
* Skill data.
|
||||
@@ -120,7 +120,7 @@ export interface Ability {
|
||||
/**
|
||||
* Skill groups.
|
||||
* Skills in a skill group replace each other when purchased.
|
||||
*
|
||||
*
|
||||
* As a special case, horsegen lists both unique skills and their inherited
|
||||
* versions in the skill groups for both.
|
||||
*/
|
||||
@@ -132,7 +132,7 @@ export interface SkillGroup {
|
||||
/**
|
||||
* Base skill in the skill group, if any.
|
||||
* Either a common (white) skill or an Uma's own unique.
|
||||
*
|
||||
*
|
||||
* Some skill groups, e.g. for G1 Averseness, have no base skill.
|
||||
*/
|
||||
skill1?: number;
|
||||
@@ -153,7 +153,7 @@ export interface SkillGroup {
|
||||
}
|
||||
|
||||
export const skills = {
|
||||
global: skillGlobal as Skill[],
|
||||
global: skillGlobal as Skill[],
|
||||
} as const;
|
||||
|
||||
export const skillGroups = {
|
||||
@@ -162,8 +162,8 @@ export const skillGroups = {
|
||||
|
||||
export const ZERO_SKILL: Readonly<Skill> = {
|
||||
skill_id: 0,
|
||||
name: "invalid skill",
|
||||
description: "an invalid skill was specified",
|
||||
name: 'invalid skill',
|
||||
description: 'an invalid skill was specified',
|
||||
group: 0,
|
||||
rarity: 1,
|
||||
group_rate: 1,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import * as math from "mathjs";
|
||||
import * as math from 'mathjs';
|
||||
|
||||
export function binomPMF(p: number, n: number, k: number): number {
|
||||
// Operate in log domain for precision.
|
||||
const lc = math.lgamma(n+1) - math.lgamma(k+1) - math.lgamma(n-k+1);
|
||||
const lpk = k * math.log(p);
|
||||
const lr = (n - k) * math.log(1 - p);
|
||||
return math.exp(lc + lpk + lr);
|
||||
// Operate in log domain for precision.
|
||||
const lc = math.lgamma(n + 1) - math.lgamma(k + 1) - math.lgamma(n - k + 1);
|
||||
const lpk = k * math.log(p);
|
||||
const lr = (n - k) * math.log(1 - p);
|
||||
return math.exp(lc + lpk + lr);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user