initial commit

This commit is contained in:
Kamal Tufekcic 2026-07-05 12:14:39 +03:00
commit 2d966b8198
28 changed files with 2901 additions and 0 deletions

185
wwwroot/css/site.css Normal file
View file

@ -0,0 +1,185 @@
/* Dark-only, function over form: one small sheet, no framework, no webfonts, no animation. */
:root {
--bg: #101318;
--panel: #181d24;
--panel2: #1f2630;
--line: #2a323d;
--text: #d7dde4;
--muted: #8b95a1;
--accent: #62c47f;
--accent2: #d9a94a;
--bad: #d06a5f;
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
margin: 0;
background: var(--bg);
color: var(--text);
font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
/* sticky footer: short pages pin the footer to the viewport bottom instead of hugging the content */
display: flex;
flex-direction: column;
min-height: 100vh;
}
/* width:100% matters: main/footer are flex items whose auto margins would otherwise cancel stretch (shrink-wrap) */
/* 1440: the simulator's player-state row needs >=1408 to stay on one line */
.wrap { width: 100%; max-width: 1440px; margin: 0 auto; padding: 0 16px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
header { border-bottom: 1px solid var(--line); background: var(--panel); }
header nav { display: flex; gap: 18px; align-items: center; height: 52px; }
header nav a { color: var(--text); }
header nav a:hover { color: var(--accent); text-decoration: none; }
.brand { font-weight: 700; font-size: 17px; margin-right: 12px; }
.brand span { color: var(--accent); }
main { flex: 1; padding: 36px 16px 48px; }
footer {
margin-top: auto;
border-top: 1px solid var(--line);
padding: 14px 16px;
color: var(--muted);
font-size: 13px;
display: flex;
justify-content: space-between;
flex-wrap: wrap;
gap: 8px;
}
footer a { color: var(--muted); }
h1 { font-size: 24px; margin: 0 0 6px; }
h2 { font-size: 18px; margin: 28px 0 10px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
p, li { color: var(--text); max-width: 75ch; }
.muted { color: var(--muted); }
small, .small { font-size: 13px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; margin-top: 16px; }
.card {
background: var(--panel);
border: 1px solid var(--line);
border-radius: 8px;
padding: 14px 16px;
display: flex;
flex-direction: column;
gap: 8px;
}
.card h3 { margin: 0; font-size: 16px; }
.card .row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.badge {
display: inline-block;
padding: 1px 8px;
border-radius: 10px;
font-size: 12px;
background: var(--panel2);
border: 1px solid var(--line);
color: var(--muted);
white-space: nowrap;
}
.badge.mode { color: var(--accent); border-color: var(--accent); }
.badge.off { color: var(--bad); border-color: var(--bad); }
.btn {
display: inline-block;
background: var(--accent);
color: #0c1210;
font-weight: 600;
padding: 6px 14px;
border-radius: 6px;
border: 0;
}
.btn:hover { filter: brightness(1.1); text-decoration: none; }
code[title] { text-decoration: underline dotted var(--muted); cursor: help; }
code, kbd, .connect {
font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
font-size: 13px;
background: var(--panel2);
border: 1px solid var(--line);
border-radius: 4px;
padding: 1px 6px;
}
.connect { display: inline-block; padding: 5px 10px; user-select: all; }
table { border-collapse: collapse; width: 100%; margin: 10px 0 20px; }
.tablewrap { overflow-x: auto; }
th, td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
tr:hover td { background: var(--panel); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.notice {
background: var(--panel);
border: 1px solid var(--accent2);
border-radius: 8px;
padding: 10px 14px;
color: var(--text);
margin: 12px 0;
}
.notice.err { border-color: var(--bad); }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; }
/* ---- theory curves (small multiples; recessive grid, 2px series, shared crosshair) ---- */
figure { margin: 16px 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
svg.panel { display: block; width: 100%; height: auto; touch-action: none; }
.panel .grid { stroke: var(--line); stroke-width: 1; }
.panel .grid.one { stroke-dasharray: 4 4; stroke: var(--muted); opacity: 0.6; }
.panel .series { fill: none; stroke-width: 2; stroke-linejoin: round; }
.panel .cross { stroke: var(--text); stroke-width: 1; opacity: 0.45; }
.panel .ptitle { fill: var(--text); font-size: 12px; font-weight: 600; }
.panel .tick { fill: var(--muted); font-size: 11px; text-anchor: end; font-variant-numeric: tabular-nums; }
.panel .tick.mid { text-anchor: middle; }
.readout { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; padding-bottom: 10px; font-variant-numeric: tabular-nums; }
.readout input[type="range"] { width: 220px; accent-color: var(--accent); vertical-align: middle; }
.readout .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; }
figcaption { text-align: center; padding-top: 6px; }
.panel .simt { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 3 3; }
/* ---- simulator ---- */
.sim input[type="number"] {
width: 78px;
background: var(--panel2);
border: 1px solid var(--line);
border-radius: 4px;
color: var(--text);
padding: 3px 6px;
text-align: right;
font-variant-numeric: tabular-nums;
}
.sim input[type="checkbox"] { accent-color: var(--accent); }
.sim fieldset {
border: 1px solid var(--line);
border-radius: 8px;
background: var(--panel);
margin: 0 0 16px;
padding: 10px 14px 14px;
}
.sim legend { color: var(--muted); font-size: 13px; font-weight: 600; padding: 0 6px; }
.sim .fields { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.sim .fields label { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.simout {
display: flex;
flex-wrap: wrap;
gap: 8px 26px;
align-items: baseline;
background: var(--panel);
border: 1px solid var(--accent);
border-radius: 8px;
padding: 10px 14px;
margin: 0 0 16px;
font-variant-numeric: tabular-nums;
}
.simout b { font-size: 18px; }
.simout .lbl { color: var(--muted); font-size: 12px; display: block; }
.sim td input[type="number"] { width: 64px; }
.sim .modified { outline: 1px solid var(--accent2); }
/* handicap knobs: semantic groups as a grid of boxes; inside each, label|input rows */
.kgroups { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.kgroup { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px 10px; }
.kgroup h4 { margin: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.kgroup label { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 3px 0; font-size: 14px; }

272
wwwroot/js/theory.js Normal file
View file

@ -0,0 +1,272 @@
// Theory page: live curves + the simulator. Seeded from the server's effective config (#sim-data); every formula
// below MIRRORS the plugin's Domain layer (file noted per function). The VALUES always come from the server payload —
// only the formula shapes are duplicated here, and those change rarely. Abilities/crits/headshots are deliberately
// excluded (parity with the in-game HUD's base readout).
(function () {
"use strict";
const seedEl = document.getElementById("sim-data");
if (!seedEl) return;
let seed;
try { seed = JSON.parse(seedEl.textContent); } catch { return; }
if (!seed?.Curves?.T || seed.Curves.T.length < 2) return;
// Geometry mirrors TheoryModel constants (viewBox units).
const L = 46, R = 10, W = 720, T = 10, PLOTH = 134, PLOT = W - L - R;
const N = seed.Curves.T.length;
const clamp = function (v, a, b) { return Math.max(a, Math.min(b, v)); };
const clamp01 = function (v) { return clamp(v, 0, 1); };
const lerp = function (a, b, t) { return a + (b - a) * t; };
// HandicapModel.Ease: sign-preserving curve easing.
function ease(t, curve) { return t >= 0 ? Math.pow(t, curve) : -Math.pow(-t, curve); }
// HandicapModel.ComputeT + ResolvedHandicap's guard denominators. Returns the RAW post-floor t (the chart's
// x-axis); callers ease it before the band lerps — ease(raw) is exactly what the live ComputeT returns.
function computeRawT(h, p) {
if (!h.Enabled) return 0;
const kdNerfDenom = Math.max(0.01, h.KdMaxNerf - h.KdNeutral);
const kdBuffDenom = Math.max(0.01, h.KdNeutral - h.KdMinBuff);
const hsDenom = Math.max(0.01, h.HsMaxNerf);
const streakDenom = Math.max(1, h.StreakMaxNerf);
const levelDenom = Math.max(1, h.LevelMaxNerf);
const wsum = h.KdWeight + h.HsWeight + h.StreakWeight + h.LevelWeight + h.ProgressWeight;
let kdN = 0, buff = 0;
if (p.kills + p.deaths >= 3) {
const r = p.kills / Math.max(1, p.deaths);
kdN = clamp01((r - h.KdNeutral) / kdNerfDenom);
buff = clamp01((h.KdNeutral - r) / kdBuffDenom);
}
const hsRate = p.kills >= h.HsMinKills ? p.hsk / Math.max(1, p.kills) : 0;
let n = wsum <= 0 ? 0 :
(h.KdWeight * kdN + h.HsWeight * clamp01(hsRate / hsDenom) + h.StreakWeight * clamp01(p.streak / streakDenom)
+ h.LevelWeight * clamp01(p.level / levelDenom) + h.ProgressWeight * clamp01(p.progress)) / wsum;
let t = clamp(h.MasterDifficulty * (n - buff), -1, 1);
if (p.floor > t) t = Math.min(p.floor, 1);
return t;
}
// HandicapModel.DealFromT/TakeFromT/XpFromT (takes the EASED t; team multipliers ride on deal/take only).
function bands(eased, h, teamDeal, teamTake) {
return {
deal: (eased >= 0 ? lerp(1, h.MDealFloor, eased) : lerp(1, h.MDealCeiling, -eased)) * teamDeal,
take: (eased >= 0 ? lerp(1, h.MTakeCeiling, eased) : lerp(1, h.MTakeFloor, -eased)) * teamTake,
xp: eased >= 0 ? lerp(1, h.XpCeiling, eased) : lerp(1, h.XpFloor, -eased),
};
}
// ---- state ----
const h = {}; // live handicap knobs (seeded from server)
const player = { level: 0, prestige: 0, kills: 0, deaths: 0, hsk: 0, streak: 0, progress: 0, floor: -1, prestigeBoost: seed.PrestigeBoostPercent };
const invested = {}; // stat key -> levels
const cards = {}; // card key -> picks
const statDefs = {}; // key -> {Base, PerLevel}
seed.Stats.forEach(function (s) { statDefs[s.Key] = s; invested[s.Key] = 0; });
seed.Cards.forEach(function (c) { cards[c.Key] = 0; });
const curves = { deal: [], take: [], xp: [] }; // resampled from live knobs
// StatResolver.Eff + EffRun: base + invested*perLevel (+ stat-keyed card picks x PerPick — card key == stat key).
function effRun(key) {
const d = statDefs[key];
let v = d ? d.Base + (invested[key] || 0) * d.PerLevel : 0;
const card = seed.Cards.find(function (c) { return c.Key === key && !c.IsTeam; });
if (card) v += (cards[key] || 0) * card.PerPick;
return v;
}
// SurvivalDriver team cards: compounding per shared squad level ((1±PerPick/100)^picks).
function teamMults() {
let deal = 1, take = 1;
seed.Cards.forEach(function (c) {
if (!c.IsTeam) return;
if (c.Key === "global_deal") deal = Math.pow(1 + c.PerPick / 100, cards[c.Key] || 0);
if (c.Key === "global_take") take = Math.pow(1 - c.PerPick / 100, cards[c.Key] || 0);
});
return { deal: deal, take: take };
}
// ---- curves: resample the 201 points from the LIVE knobs (HandicapModel.BandsFromT + Api.cs's loop, client-side;
// the disabled short-circuit mirrors BandsFromT's own) ----
function resample() {
curves.deal = []; curves.take = []; curves.xp = [];
for (let i = 0; i < N; i++) {
const t = -1 + i * (2 / (N - 1));
let b = bands(ease(clamp(t, -1, 1), h.Curve), h, 1, 1);
if (!h.Enabled) b = { deal: 1, take: 1, xp: 1 };
curves.deal.push(b.deal); curves.take.push(b.take); curves.xp.push(b.xp);
}
}
function yScale(vals) { // TheoryModel.BuildPanel's ymax rule
const max = Math.max.apply(null, vals);
const step = max <= 2 ? 0.5 : max <= 5 ? 1 : 2;
return Math.max(step, Math.ceil(max / step) * step);
}
function redrawPanels() {
panels.forEach(function (svg) {
const vals = curves[svg.dataset.key];
const ymax = yScale(vals);
const pts = [];
for (let i = 0; i < vals.length; i++) {
const x = L + i / (vals.length - 1) * PLOT;
const y = T + PLOTH * (1 - vals[i] / ymax);
pts.push(x.toFixed(1) + "," + y.toFixed(1));
}
svg.querySelector(".series").setAttribute("points", pts.join(" "));
const oneY = T + PLOTH * (1 - 1 / ymax);
const one = svg.querySelector(".grid.one");
one.setAttribute("y1", oneY); one.setAttribute("y2", oneY);
const ymaxLbl = svg.querySelector(".tick.ymax");
ymaxLbl.textContent = (Math.round(ymax * 10) / 10).toString();
svg.querySelectorAll(".tick").forEach(function (tk) {
if (tk.textContent === "×1") tk.setAttribute("y", oneY + 4);
});
svg._ymax = ymax;
});
}
// ---- readouts ----
const $ = function (id) { return document.getElementById(id); };
const panels = Array.prototype.slice.call(document.querySelectorAll("svg.panel"));
const slider = $("tslider");
function fmt(v) { return "×" + v.toFixed(2); }
function recompute() {
resample();
redrawPanels();
const rawT = computeRawT(h, player);
const tm = teamMults();
let b = bands(ease(rawT, h.Curve), h, tm.deal, tm.take);
if (!h.Enabled) b = { deal: tm.deal, take: tm.take, xp: 1 };
$("sim-t").textContent = rawT.toFixed(2);
$("sim-deal").textContent = fmt(b.deal);
$("sim-take").textContent = fmt(b.take);
$("sim-xpband").textContent = fmt(b.xp);
// Hud.EffectiveMultipliers parity (headshot:false, crit:false, no actives):
$("sim-out").textContent = fmt((1 + effRun("damage") / 100) * b.deal);
$("sim-in").textContent = fmt(b.take);
$("sim-hs").textContent = fmt(1 + effRun("hs_damage") / 100);
// ProgressionModel.PrestigeXpMultiplier: 1 + prestige * boost%/100.
$("sim-xp").textContent = fmt((1 + effRun("xp_boost") / 100) * (1 + player.prestige * (player.prestigeBoost / 100)) * b.xp);
// effective column per stat
seed.Stats.forEach(function (s) {
const el = $("eff-" + s.Key);
if (el) el.textContent = (Math.round(effRun(s.Key) * 100) / 100).toString();
});
// the simulated player's position on the raw-t axis
const x = L + (rawT + 1) / 2 * PLOT;
panels.forEach(function (svg) {
const m = svg.querySelector(".simt");
m.setAttribute("x1", x); m.setAttribute("x2", x);
});
updateCross(Number.parseFloat(slider.value));
}
// ---- slider / hover crosshair (explores the CURRENT — possibly edited — curves) ----
function updateCross(t) {
t = clamp(t, -1, 1);
const i = Math.round((t + 1) / 2 * (N - 1));
$("tval").textContent = "t = " + t.toFixed(2);
const x = L + (t + 1) / 2 * PLOT;
panels.forEach(function (svg) {
const cross = svg.querySelector(".cross");
cross.setAttribute("x1", x); cross.setAttribute("x2", x);
const ro = $("ro-" + svg.dataset.key);
if (ro) ro.textContent = fmt(curves[svg.dataset.key][i]);
});
}
slider.addEventListener("input", function () { updateCross(Number.parseFloat(slider.value)); });
panels.forEach(function (svg) {
svg.addEventListener("pointermove", function (ev) {
const rect = svg.getBoundingClientRect();
const vx = (ev.clientX - rect.left) * (W / rect.width);
let t = ((vx - L) / PLOT) * 2 - 1;
slider.value = t.toFixed(2);
updateCross(t);
});
});
// ---- input wiring + seeding ----
function seedInputs() {
Object.keys(seed.Handicap).forEach(function (k) { h[k] = seed.Handicap[k]; });
h.Enabled = !!h.Enabled;
document.querySelectorAll("[data-h]").forEach(function (el) {
const k = el.dataset.h;
if (el.type === "checkbox") el.checked = !!seed.Handicap[k];
else el.value = seed.Handicap[k];
el.classList.remove("modified");
});
document.querySelectorAll("[data-sim]").forEach(function (el) {
const k = el.dataset.sim;
player[k] = k === "floor" ? -1 : k === "prestigeBoost" ? seed.PrestigeBoostPercent : 0;
el.value = player[k];
el.classList.remove("modified");
});
document.querySelectorAll("[data-stat]").forEach(function (el) { invested[el.dataset.stat] = 0; el.value = 0; el.classList.remove("modified"); });
document.querySelectorAll("[data-card]").forEach(function (el) { cards[el.dataset.card] = 0; el.value = 0; el.classList.remove("modified"); });
}
function markModified(el, isDefault) { el.classList.toggle("modified", !isDefault); }
// Out-of-range typed values are clamped AND written back to the field, so the display always shows the number the
// sim actually used (silent clamping in a theorycrafting tool is a lie). Partial input ("", "-") is left alone.
function clampedInt(el) {
const raw = Number.parseInt(el.value, 10);
const v = clamp(Number.isNaN(raw) ? 0 : raw, 0, Number.parseInt(el.max, 10) || 0);
if (!Number.isNaN(raw) && raw !== v) el.value = v;
return v;
}
document.querySelectorAll("[data-h]").forEach(function (el) {
el.addEventListener("input", function () {
const k = el.dataset.h;
if (el.type === "checkbox") { h[k] = el.checked; markModified(el, el.checked === !!seed.Handicap[k]); }
else {
let v = Number.parseFloat(el.value) || 0;
// The plugin defines Curve's valid domain as > 0 (Pow(0, negative) = Infinity would NaN the charts);
// mirror that boundary here — the payload can never seed a bad value, only an edit can.
if (k === "Curve") v = Math.max(v, 0.05);
h[k] = v;
markModified(el, v === seed.Handicap[k]);
}
recompute();
});
});
document.querySelectorAll("[data-sim]").forEach(function (el) {
el.addEventListener("input", function () {
const k = el.dataset.sim;
const dflt = k === "floor" ? -1 : k === "prestigeBoost" ? seed.PrestigeBoostPercent : 0;
const v = Number.parseFloat(el.value);
player[k] = Number.isFinite(v) ? v : dflt; // a cleared field means "default", not 0 (floor 0 is an ACTIVE floor)
markModified(el, player[k] === dflt);
recompute();
});
});
document.querySelectorAll("[data-stat]").forEach(function (el) {
el.addEventListener("input", function () {
invested[el.dataset.stat] = clampedInt(el);
markModified(el, invested[el.dataset.stat] === 0);
recompute();
});
});
document.querySelectorAll("[data-card]").forEach(function (el) {
el.addEventListener("input", function () {
cards[el.dataset.card] = clampedInt(el);
markModified(el, cards[el.dataset.card] === 0);
recompute();
});
});
$("sim-reset").addEventListener("click", function () { seedInputs(); recompute(); });
seedInputs();
recompute();
})();