diff --git a/gorge.html b/gorge.html index 13ae08a..e9fea58 100644 --- a/gorge.html +++ b/gorge.html @@ -26,6 +26,7 @@
+
Resources
diff --git a/gorge.js b/gorge.js index 6d0981d..45fee21 100644 --- a/gorge.js +++ b/gorge.js @@ -25,6 +25,28 @@ let shiftHeld = false; let mouseTarget = undefined; +const numberModes = { + words: { + name: "Words", + render: numberText, + next: "scientific" + }, + scientific: { + name: "Scientific", + render: numberScientific, + next: "full", + }, + full: { + name: "Full", + render: numberFull, + next: "words" + } +} + +deepFreeze(numberModes); + +let numberMode = numberModes["words"]; + const activePowerups = []; function tickPowerups(delta) { @@ -177,7 +199,13 @@ function updateAll() { updateProductivity(); updateClickBonus(); updateClickVictim(); + updateOptions(); +} + +function updateOptions() { + cache.optionButtons.numbers.innerText = "Number mode: " + numberMode.name; } + // update stuff function updateDisplay() { @@ -489,6 +517,12 @@ function initializeCaches() { }); cache.resourceLabels = resourceLabels; + + const optionButtons = {}; + + optionButtons.numbers = document.querySelector("#numbers"); + + cache.optionButtons = optionButtons; } const states = {}; @@ -603,6 +637,8 @@ function registerListeners() { document.querySelector("#reset").addEventListener("click", reset); + document.querySelector("#numbers").addEventListener("click", cycleNumbers); + document.querySelector("#upgrades").addEventListener("click", switchShowOwnedUpgrades); document.addEventListener("keydown", e => { @@ -1051,7 +1087,7 @@ function prodSummary(id) { let list = []; list.push( - { "text": "Each " + buildings[id].name + " produces " + render(belongings[id].count == 0 ? 0 : contributions[id].food / belongings[id].count, 3) + " food/sec" } + { "text": "Each " + buildings[id].name + " produces " + render(belongings[id].count == 0 ? 0 : contributions[id].food / belongings[id].count, 3) + " food/sec" } ); list.push( @@ -1178,3 +1214,8 @@ function load() { function reset() { window.localStorage.clear(); } + +function cycleNumbers() { + numberMode = numberModes[numberMode.next]; + updateOptions(); +} diff --git a/numbers.js b/numbers.js index 53ddf83..cfa10af 100644 --- a/numbers.js +++ b/numbers.js @@ -1,5 +1,5 @@ function render(val, places = 1, smallPlaces = 0) { - return numberText(val, places, smallPlaces); + return numberMode.render(val, places, smallPlaces); } function numberText(val, places = 1, smallPlaces = 0) { @@ -45,3 +45,11 @@ _numberWords = { 19: "novemdecillion", 20: "vigintillion", } + +function numberScientific(val, places = 1, smallPlaces) { + return val.toExponential(places) +} + +function numberFull(val, places = 1, smallPlaces) { + return round(val, places); +}