Selaa lähdekoodia

Added new helper effect; adjusted number rendering

tags/v0.0.1
Fen Dweller 7 vuotta sitten
vanhempi
commit
002d52c5c2
No known key found for this signature in database GPG Key ID: E80B35A6F11C3656
3 muutettua tiedostoa jossa 47 lisäystä ja 6 poistoa
  1. +31
    -0
      constants.js
  2. +9
    -2
      gorge.js
  3. +7
    -4
      numbers.js

+ 31
- 0
constants.js Näytä tiedosto

@@ -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.",


+ 9
- 2
gorge.js Näytä tiedosto

@@ -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"});


+ 7
- 4
numbers.js Näytä tiedosto

@@ -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",


Loading…
Peruuta
Tallenna