zenno: update stat charts for new limits
This commit is contained in:
@@ -55,39 +55,37 @@
|
||||
let width = $state(0);
|
||||
let height = $state(0);
|
||||
|
||||
let expand = $state(false);
|
||||
|
||||
const xLabel = $derived(Stat[stat]);
|
||||
const xLabel = $derived(`Raw ${Stat[stat]}`);
|
||||
const xLines = $derived([xRule].flat(1));
|
||||
const xMin = $derived(xRange?.[0] ?? 200);
|
||||
const xMax = $derived.by(() => {
|
||||
if (xRange?.[1] != null) {
|
||||
return xRange[1];
|
||||
}
|
||||
if (expand) {
|
||||
return 2000;
|
||||
}
|
||||
return 100 * Math.ceil(Math.max(1200, ...xLines) / 100);
|
||||
return 100 * Math.ceil(Math.max(2000, ...xLines) / 100);
|
||||
});
|
||||
const xVal = $derived(d3.range(xMin, xMax + 1, 5)); // +1 because d3.range does not include the max
|
||||
const thrX = 1200;
|
||||
|
||||
function adj(x: number): number {
|
||||
return Math.min(x, 1200) + 0.5 * (Math.max(x, 1200) - 1200);
|
||||
}
|
||||
const series = $derived([y].flat(1).filter((s) => s != null));
|
||||
const areas = $derived([yArea].flat(1).filter((s) => s != null));
|
||||
const vals = $derived(series.flatMap(({ y, label }) => xVal.map((x) => ({ x, y: y(x), label }))));
|
||||
const areaVals = $derived(areas.flatMap(({ y1, y2, label }) => xVal.map((x) => ({ x, y1: y1(x), y2: y2(x), label }))));
|
||||
const vals = $derived(series.flatMap(({ y, label }) => xVal.map((x) => ({ x, y: y(adj(x), x), label }))));
|
||||
const areaVals = $derived(areas.flatMap(({ y1, y2, label }) => xVal.map((x) => ({ x, y1: y1(adj(x), x), y2: y2(adj(x), x), label }))));
|
||||
const yRange: [number, number] = $derived.by(() => {
|
||||
if (range != null) {
|
||||
if (range.length === 2) {
|
||||
return range;
|
||||
}
|
||||
return [range[0], expand ? range[2] : range[1]];
|
||||
return [range[0], range[2]];
|
||||
}
|
||||
const l = d3.min(vals, ({ y }) => y) ?? 0;
|
||||
const r = d3.max(vals, ({ y }) => y) ?? 1;
|
||||
return [l, r];
|
||||
});
|
||||
const yLines = $derived(xLines.flatMap((x) => series.map(({ y, label }) => ({ y: y(x), label }))));
|
||||
const yLines = $derived(xLines.flatMap((x) => series.map(({ y, label }) => ({ y: y(adj(x), x), label }))));
|
||||
|
||||
const makeChart: Attachment = (el) => {
|
||||
$effect(() => {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
export interface ComputedSeries {
|
||||
y: (x: number) => number;
|
||||
y: (base: number, raw: number) => number;
|
||||
label: string;
|
||||
}
|
||||
|
||||
export interface ComputedAreas {
|
||||
y1: (x: number) => number;
|
||||
y2: (x: number) => number;
|
||||
y1: (base: number, raw: number) => number;
|
||||
y2: (base: number, raw: number) => number;
|
||||
label: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -519,7 +519,8 @@ export function speedGain(speedBonus: number, dur: number, accel: number | null,
|
||||
* @returns Probability per candidate to accept
|
||||
*/
|
||||
export function reducedSpurtChance(witStat: number): number {
|
||||
return 0.15 + 0.0005 * witStat;
|
||||
// 1900 wit style S exceeds 100% chance if we don't explicitly cap.
|
||||
return Math.min(0.15 + 0.0005 * witStat, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user