From d69855a52bce52cf62c7e6cd588fe1d1255e2156 Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Sat, 21 Jul 2018 23:31:22 -0500 Subject: [PATCH] Fixed display of prod upgrades, adjusted numbers --- constants.js | 13 +++++++------ gorge.js | 2 +- util.js | 4 ++++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/constants.js b/constants.js index 47528e9..ea1514e 100644 --- a/constants.js +++ b/constants.js @@ -119,7 +119,8 @@ const upgrade_types = { return productivity * 2; }, "desc": function(effect) { - return "2x food production from " + effect.target; + console.log(effect); + return round(effect.amount, 2) + "x food production from " + buildings[effect.target].plural; } }, "prod-all": { @@ -127,7 +128,7 @@ const upgrade_types = { return productivity * effect.amount; }, "desc": function(effect) { - return Math.round((effect.amount - 1) * 100) + "% increase to food production"; + return round((effect.amount - 1) * 100) + "% increase to food production"; } } } @@ -137,7 +138,7 @@ const upgrades = { "name": "Bigger Micros", "desc": "A macro micro? Certainly more filling.", "cost": { - "food": buildings.micro.cost * 5 + "food": buildings.micro.cost * 10 }, "effect": { "type": "prod", @@ -159,11 +160,11 @@ const upgrades = { "effect": { "type": "prod", "target": "micro", - "amount": 2, + "amount": 2.25, }, "prereqs": { "buildings": { - "micro": 10 + "micro": 5 }, "upgrades": [ "micro-prod-1" @@ -196,7 +197,7 @@ const upgrades = { "effect": { "type": "prod", "target": "anthro", - "amount": 2, + "amount": 2.25, }, "prereqs": { "buildings": { diff --git a/gorge.js b/gorge.js index 6cbfd79..8669ae0 100644 --- a/gorge.js +++ b/gorge.js @@ -100,7 +100,7 @@ function addResources() { function displayResources() { document.getElementById("resource-food").innerText = "Food: " + render(resources.food); - document.getElementById("productivity").innerText = (Math.round(calculateProductivity() * 10) / 10) + " food/sec"; + document.getElementById("productivity").innerText = round(calculateProductivity(), 1) + " food/sec"; } function displayBuildings() { diff --git a/util.js b/util.js index 21c7021..fd8d11a 100644 --- a/util.js +++ b/util.js @@ -14,3 +14,7 @@ function removeChildren(element) { element.removeChild(element.lastChild); } } + +function round(val, places) { + return Math.round(val * Math.pow(10, places)) / Math.pow(10, places); +}