Fix for >1200 stats, add inputs for spurt speed details. Fixes #35. For #27.
This commit is contained in:
+35
-8
@@ -302,6 +302,33 @@ export function finalStat(adjStat: number, skillPassive: number): number {
|
||||
return statClamp(adjStat + skillPassive);
|
||||
}
|
||||
|
||||
export function adjustedStatFromFinal(finalStat: number, skillPassive: number): number {
|
||||
return finalStat - skillPassive;
|
||||
}
|
||||
|
||||
export function baseStatFromAdjusted(stat: Stat, adjStat: number, career: boolean, surface: Surface, conditions: GroundConditions, styleApt: AptitudeLevel, thresholdMod: number): number {
|
||||
const careerMod = career ? 400 : 0;
|
||||
switch (stat) {
|
||||
case Stat.Speed:
|
||||
return (adjStat - speedStatGroundMod[surface][conditions] - careerMod) / thresholdMod;
|
||||
case Stat.Stamina:
|
||||
return adjStat - careerMod;
|
||||
case Stat.Power:
|
||||
return adjStat - powerStatGroundMod[surface][conditions] - careerMod;
|
||||
case Stat.Guts:
|
||||
return adjStat - careerMod;
|
||||
case Stat.Wit:
|
||||
return (adjStat - careerMod) / strategyProficiencyMod[styleApt];
|
||||
}
|
||||
}
|
||||
|
||||
export function rawStatFromBase(baseStat: number, mood: Mood): number {
|
||||
// Round to half-integers in case we have a component above 1200.
|
||||
const s = Math.round(2 * baseStat / MOOD_COEF[mood]) / 2;
|
||||
const r = math.min(s, 1200) + math.max(s - 1200, 0) * 2;
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Running styles for strategy–phase coefficients.
|
||||
* Runaway is distinguished as a separate style even though it is
|
||||
@@ -589,10 +616,10 @@ export function spurtSpeed(
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the speed stat which produces a given target speed in the last spurt.
|
||||
* Calculate the final speed stat which produces a given target speed in the last spurt.
|
||||
* Inverse of spurtSpeed.
|
||||
* @param spurtSpeed Target speed in the last spurt in m/s
|
||||
* @param gutsStat Uma's guts stat. No accounting for mood or stat thresholds.
|
||||
* @param guts Uma's guts stat. No accounting for mood or stat thresholds.
|
||||
* @param style Running style
|
||||
* @param distance Distance aptitude
|
||||
* @param raceLen Length of the race in meters
|
||||
@@ -600,19 +627,19 @@ export function spurtSpeed(
|
||||
*/
|
||||
export function inverseSpurtSpeed(
|
||||
spurtSpeed: number,
|
||||
gutsStat: number,
|
||||
guts: number,
|
||||
style: RunningStyle,
|
||||
distance: AptitudeLevel,
|
||||
raceLen: number,
|
||||
): number {
|
||||
// spurtSpeed = base * (1.05*spc + 0.0105) + 0.0041*sqrt(500*speedStat)*dpm + pow(450*gutsStat, 0.597)*0.0001
|
||||
// spurtSpeed - base * (1.05*spc + 0.0105) - pow(450*gutsStat, 0.597)*0.0001 = 0.0041*sqrt(500*speedStat)*dpm
|
||||
// (spurtSpeed - base * (1.05*spc + 0.0105) - pow(450*gutsStat, 0.597)*0.0001)²/(0.0041²*dpm²*500) = speedStat
|
||||
// (spurtSpeed - base * (1.05*spc + 0.0105) - pow(450*gutsStat, 0.597)*0.0001)²/(0.008405*dpm²) = speedStat
|
||||
// spurtSpeed = base * (1.05*spc + 0.0105) + 0.0041*sqrt(500*speed)*dpm + pow(450*guts, 0.597)*0.0001
|
||||
// spurtSpeed - base * (1.05*spc + 0.0105) - pow(450*guts, 0.597)*0.0001 = 0.0041*sqrt(500*speed)*dpm
|
||||
// (spurtSpeed - base * (1.05*spc + 0.0105) - pow(450*guts, 0.597)*0.0001)²/(0.0041²*dpm²*500) = speed
|
||||
// (spurtSpeed - base * (1.05*spc + 0.0105) - pow(450*guts, 0.597)*0.0001)²/(0.008405*dpm²) = speed
|
||||
const spc = speedStrategyPhaseCoeff[style][Phase.LateRace];
|
||||
const dpm = distanceProficiencyMod[distance];
|
||||
const base = baseSpeed(raceLen);
|
||||
const nr = spurtSpeed - base * (1.05 * spc + 0.0105) - Math.pow(450 * gutsStat, 0.597) * 0.0001;
|
||||
const nr = spurtSpeed - base * (1.05 * spc + 0.0105) - Math.pow(450 * guts, 0.597) * 0.0001;
|
||||
const r = (nr * nr) / (0.008405 * dpm * dpm);
|
||||
return Math.round(r);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user