diff --git a/docs/index.html b/docs/index.html index a50703a..72e2b65 100644 --- a/docs/index.html +++ b/docs/index.html @@ -46,6 +46,7 @@ + diff --git a/docs/js/index.js b/docs/js/index.js index f215d71..7191562 100644 --- a/docs/js/index.js +++ b/docs/js/index.js @@ -113,7 +113,7 @@ function renderThing() { gl.uniformMatrix4fv(matBuffer, false, new Float32Array(MDN.perspectiveMatrix(Math.PI * 100 / 180, ratio, 0.01, 1000))); - hud.textContent = `${Math.floor(nothingness * 100) / 100} nil; ${Math.floor((nGain + getBonus) * 60 * 100) / 100} nil/sec` + hud.textContent = `${numify(nothingness)} nil; ${numify((nGain + getBonus) * 60)} nil/sec` gl.uniform1f(sizeBuffer, -Math.log(nothingness)); diff --git a/docs/js/num.js b/docs/js/num.js new file mode 100644 index 0000000..cf25cbe --- /dev/null +++ b/docs/js/num.js @@ -0,0 +1,24 @@ +let illions = [ + "", "k", "M", "B", "T", "qd", "Qn", "sx", "Sp", "O", "N", "de", "Ud", "DD", "tdD", "qdD", "QnD", "sxD", "SpD", "OcD", "NvD", "Vgn", "UVg", "DVg", "TVg", "qtV", "QnV", "SeV", "SPG", "OVG", "NVG", "TGN", "UTG", "DTG", "tsTG", "qtTG", "QnTG", "ssTG", "SpTG", "OcTG", "NoTG", "QdDR", "uQDR", "dQDR", "tQDR", "qdQDR", "QnQDR", "sxQDR", "SpQDR", "OQDDr", "NQDDr", "qQGNT", "uQGNT", "dQGNT", "tQGNT", "qdQGNT", "QnQGNT", "sxQGNT", "SpQGNT", "OQQGNT", "NQQGNT", "SXGNTL" +]; + +function numify(x) { + x = x * 1; + + let il = Math.log(x) / Math.log(1000); + il = Math.floor(il); + let base = x / (1000 ** il); + base = base.toString(); + base = base.slice(0,Math.min(base.length,5)) + if (il in illions && !isNaN(x) && Math.abs(x) != Infinity) { + return `${base}${illions[il]}` + } else if (x == 0 || isNaN(x) || Math.abs(x) == Infinity) { + return `${x}`; + } else if (x < 0) { + return `-${numify(x)}` + } else if (x < 1) { + return `1/${numify(1 / x)}` + } else if (il > illions.length - 1) { + return `10^${numify(Math.log10(x))}` + } +} \ No newline at end of file diff --git a/docs/js/upgrade.js b/docs/js/upgrade.js index 86d06cf..23168de 100644 --- a/docs/js/upgrade.js +++ b/docs/js/upgrade.js @@ -37,7 +37,7 @@ upgrades = [ let hud2 = document.querySelector('.hud'); function updateText(button, price, name, cc) { - button.textContent = `Buy ${name} (${cc}x) for ${price} nil` + button.textContent = `Buy ${name} (${cc}x) for ${numify(price)} nil` } for (let upgrade of upgrades) {