diff --git a/constants.js b/constants.js index 2df72f2..5b561dc 100644 --- a/constants.js +++ b/constants.js @@ -129,6 +129,14 @@ const effect_types = { "desc": function(effect) { return round((effect.amount - 1) * 100) + "% increase to food production"; } + }, + "helper": { + "apply": function(effect, productivity, helperCount) { + return productivity * (1 + effect.amount * helperCount); + }, + "desc": function(effect) { + return "+" + round(effect.amount * 100) + "% food/sec from " + buildings[effect.helped].name + " for every " + buildings[effect.helper].name + " owned."; + } } } @@ -215,6 +223,29 @@ const upgrades = { ] } }, + "anthro-help-micro-1": { + "name": "Servants", + "desc": "Why bother walking anywhere, really?", + "cost": { + "food": buildings.anthro.cost * 25 + buildings.micro.cost * 50 + }, + "effects": [ + { + "type": "helper", + "helper": "anthro", + "helped": "micro", + "amount": 0.01 + } + ], + "prereqs": { + "buildings": { + "anthro": 10 + }, + "upgrades": [ + "anthro-prod-1" + ] + } + }, "prod-1": { "name": "Sloth Metabolism", "desc": "Burn those calories. Eventually.", diff --git a/gorge.js b/gorge.js index 301a15a..4eaa384 100644 --- a/gorge.js +++ b/gorge.js @@ -43,6 +43,13 @@ function productivityMultiplierOf(type) { } } + for (let effect of effects["helper"]) { + + if (ownedUpgrades[effect.parent] && effect.helped == type) { + base = effect.apply(base, belongings[effect.helper].count); + } + } + return base; } @@ -111,8 +118,8 @@ function renderResources() { for (const [key, value] of Object.entries(resources)) { - let line1 = render(value, 3) + " " + resourceTypes[key].name; - let line2 = render(currentProductivity[key]) + " " + resourceTypes[key].name + "/sec"; + let line1 = render(value, 3, 0) + " " + resourceTypes[key].name; + let line2 = render(currentProductivity[key], 1, 1) + " " + resourceTypes[key].name + "/sec"; list.push({"text": line1, "class": "resource-quantity"}); list.push({"text": line2, "class": "resource-rate"}); diff --git a/numbers.js b/numbers.js index d83c850..a93d85a 100644 --- a/numbers.js +++ b/numbers.js @@ -1,8 +1,12 @@ -function render(val, places=1) { - return numberText(val, places); +function render(val, places=1, smallPlaces = 0) { + return numberText(val, places, smallPlaces); } -function numberText(val, places=1) { +function numberText(val, places=1, smallPlaces = 0) { + if (val < 1000) { + return round(val, smallPlaces); + } + let power = Math.floor(Math.log10(val)); let order = Math.floor(power / 3); @@ -13,7 +17,6 @@ function numberText(val, places=1) { } _numberWords = { - 0: "", 1: "thousand", 2: "million", 3: "billion",