auto-merge PR #45

This commit was merged in pull request #45.
This commit is contained in:
2026-04-10 19:01:58 +00:00

38
game.js
View File

@@ -737,6 +737,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"
@@ -1534,7 +1542,11 @@ function tickSprint(dt) {
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';
};
@@ -1748,13 +1760,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());