zenno/doc/fans: updates for new info
This commit is contained in:
@@ -41,6 +41,30 @@
|
||||
[18, 1],
|
||||
] as const;
|
||||
|
||||
const margins = [
|
||||
['Nose', 0],
|
||||
['Head', 0],
|
||||
['Neck', 0],
|
||||
['1/2 L', 0.5],
|
||||
['3/4 L', 0.75],
|
||||
['1 L', 1],
|
||||
['1 1/4 L', 1.25],
|
||||
['1 1/2 L', 1.5],
|
||||
['1 3/4 L', 1.75],
|
||||
['2 L', 2],
|
||||
['2 1/2 L', 2.5],
|
||||
['3 L', 3],
|
||||
['3 1/2 L', 3.5],
|
||||
['4 L', 4],
|
||||
['5 L', 5],
|
||||
['6 L', 6],
|
||||
['7 L', 7],
|
||||
['8 L', 8],
|
||||
['9 L', 9],
|
||||
['10 L', 10],
|
||||
['Distance', 11],
|
||||
] as const;
|
||||
|
||||
const marginBonus = [
|
||||
['Nose – 3/4 L', 0, 9],
|
||||
['1 L – 2.5 L', 2, 6],
|
||||
@@ -107,7 +131,11 @@
|
||||
</div>
|
||||
<div>
|
||||
<label for="calc-margin">{marginType} (L)</label>
|
||||
<input id="calc-margin" class="max-w-32" type="number" min="0" step="0.25" bind:value={margin} />
|
||||
<select id="calc-margin" bind:value={margin}>
|
||||
{#each margins as [name, v] (name)}
|
||||
<option value={v}>{name}</option>
|
||||
{/each}
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label for="calc-skills">Activated Skills</label>
|
||||
@@ -157,7 +185,7 @@
|
||||
<table class="mx-auto mb-4 border text-center">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" class="px-2">Actual<br />Margin Within</th>
|
||||
<th scope="col" class="px-2">Margin Within</th>
|
||||
<th scope="col" class="px-2">Bonus for Winner</th>
|
||||
<th scope="col" class="px-2">Bonus for Podium</th>
|
||||
</tr>
|
||||
@@ -174,7 +202,10 @@
|
||||
</table>
|
||||
|
||||
<Sec h={2} id="skills">Fans from Skill Activations</Sec>
|
||||
<p>The trainee receives a bonus percentage of base fans according to the number of skills she activated during the race.</p>
|
||||
<p>
|
||||
The trainee receives a bonus percentage of base fans according to the number of skills she activated during the race. Negative
|
||||
(purple) skills count toward this count.
|
||||
</p>
|
||||
<table class="mx-auto mb-4 border text-center">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -218,7 +249,10 @@
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>(Trackblazer/MANT) If glowsticks were used for the race, apply their multiplier and round down.</li>
|
||||
<li>
|
||||
(Trackblazer/MANT) If glowsticks were used for the race, apply their multiplier, then round by the same
|
||||
five-significant-figures procedure.
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
<Sec h={2} id="data">Data</Sec>
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { expect, test } from 'vitest';
|
||||
import * as fans from './fans';
|
||||
|
||||
interface FansGainedCase {
|
||||
b: number;
|
||||
fb: number;
|
||||
ord: number;
|
||||
m: number;
|
||||
s: number;
|
||||
gs?: number;
|
||||
want: number;
|
||||
}
|
||||
|
||||
test.for<FansGainedCase>([
|
||||
{ b: 700, fb: 88, ord: 1, m: 1, s: 0, want: 1342 },
|
||||
{ b: 10500, fb: 105, ord: 1, m: 1, s: 0, want: 21956 },
|
||||
{ b: 2000, fb: 88, ord: 10, m: 10, s: 1, want: 191 },
|
||||
{ b: 30000, fb: 75, ord: 1, m: 5, s: 4, gs: 50, want: 85838 },
|
||||
{ b: 30000, fb: 95, ord: 1, m: 9, s: 8, gs: 50, want: 100040 },
|
||||
{ b: 30000, fb: 105, ord: 1, m: 5, s: 5, gs: 50, want: 100550 },
|
||||
])('%j', (c) => {
|
||||
const baseFans = fans.baseFans(c.b, c.ord);
|
||||
const marginFans = fans.marginFans(baseFans, c.ord, c.m);
|
||||
const skillFans = fans.skillFans(baseFans, c.s);
|
||||
const itemBonus = c.gs ?? 0;
|
||||
const got = fans.gained(baseFans, marginFans, skillFans, c.fb, itemBonus);
|
||||
expect(got).toBe(c.want);
|
||||
});
|
||||
@@ -53,6 +53,16 @@ export function skillFans(baseFans: number, skillsActivated: number): number {
|
||||
return Math.floor(baseFans * b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Round a number to five significant figures.
|
||||
* @param x Number to round
|
||||
* @returns x rounded to five significant figures
|
||||
*/
|
||||
function fivesf(x: number): number {
|
||||
const s = x.toPrecision(5);
|
||||
return Math.floor(parseFloat(s));
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate fan gain from a career race.
|
||||
* @param baseFans Base fans from the race and finish order
|
||||
@@ -64,10 +74,7 @@ export function skillFans(baseFans: number, skillsActivated: number): number {
|
||||
*/
|
||||
export function gained(baseFans: number, marginFans: number, skillFans: number, fanBonus: number, itemBonus?: number): number {
|
||||
const f = baseFans + marginFans + skillFans;
|
||||
const s = Math.fround(f * Math.fround(1 + fanBonus / 100));
|
||||
const p = Math.exp((4 - Math.floor(Math.log10(s))) * Math.LN10);
|
||||
// Add half a significant figure to account for precision.
|
||||
const d = Math.floor(Math.round(s * p + 5e-6) / p + 5e-6);
|
||||
const d = fivesf(Math.fround(f * Math.fround(1 + fanBonus / 100)));
|
||||
const b = itemBonus ?? 0;
|
||||
return Math.floor(d * (1 + b / 100));
|
||||
return fivesf(d * (1 + b / 100));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user