burn: add educational number scale tooltips to resources and stats

This commit is contained in:
Alexander Whitestone
2026-04-10 08:26:27 -04:00
parent 6081844387
commit 13e77a12f2

38
game.js
View File

@@ -729,6 +729,14 @@ function fmt(n) {
return (n / Math.pow(10, scale * 3)).toFixed(1) + abbrev;
}
// getScaleName() — Returns the full name of the number scale (e.g. "quadrillion")
// Educational: helps players understand what the abbreviations mean
function getScaleName(n) {
if (n < 1000) return '';
const scale = Math.floor(Math.log10(n) / 3);
return scale < NUMBER_NAMES.length ? NUMBER_NAMES[scale] : '';
}
// spellf() — Converts numbers to full English word form
// Educational: shows the actual names of number scales
// Examples: spellf(1500) => "one thousand five hundred"
@@ -1483,7 +1491,11 @@ function doOps(action) {
function renderResources() {
const set = (id, val, rate) => {
const el = document.getElementById(id);
if (el) el.textContent = fmt(val);
if (el) {
el.textContent = fmt(val);
// Show full spelled-out number on hover for educational value
el.title = val >= 1000 ? spellf(Math.floor(val)) : '';
}
const rEl = document.getElementById(id + '-rate');
if (rEl) rEl.textContent = (rate >= 0 ? '+' : '') + fmt(rate) + '/s';
};
@@ -1692,13 +1704,23 @@ function renderProjects() {
}
function renderStats() {
const set = (id, v) => { const el = document.getElementById(id); if (el) el.textContent = v; };
set('st-code', fmt(G.totalCode));
set('st-compute', fmt(G.totalCompute));
set('st-knowledge', fmt(G.totalKnowledge));
set('st-users', fmt(G.totalUsers));
set('st-impact', fmt(G.totalImpact));
set('st-rescues', fmt(G.totalRescues));
const set = (id, v, raw) => {
const el = document.getElementById(id);
if (el) {
el.textContent = v;
// Show scale name on hover for educational reference
if (raw !== undefined && raw >= 1000) {
const name = getScaleName(raw);
if (name) el.title = name;
}
}
};
set('st-code', fmt(G.totalCode), G.totalCode);
set('st-compute', fmt(G.totalCompute), G.totalCompute);
set('st-knowledge', fmt(G.totalKnowledge), G.totalKnowledge);
set('st-users', fmt(G.totalUsers), G.totalUsers);
set('st-impact', fmt(G.totalImpact), G.totalImpact);
set('st-rescues', fmt(G.totalRescues), G.totalRescues);
set('st-clicks', G.totalClicks.toString());
set('st-phase', G.phase.toString());
set('st-buildings', Object.values(G.buildings).reduce((a, b) => a + b, 0).toString());