final commit including final db schema
[browser-rts.git] / src / tasks / tick.ts
index e448713e53dca01231a85c26b3b757915e4d9b72..d12f1af2d05187b152f30e8cf94bf20ff1e915d3 100644 (file)
@@ -27,12 +27,29 @@ export const tick = new Task<Tick>('tick', async (task, job) => {
                )
                 + farms * 50
        ),
-       population = max(
-               min(
-                       population + round(coalesce(food/food, 0) * population*0.08),
-                       farms * 70
-               ),
-               population
+  energy = min(
+    max(
+      energy - (
+        farms * 40 + 
+        barracks * 60 + 
+        special_attacker_trainer * 100 + 
+        special_defender_trainer * 80 + 
+        homes * 10 + 
+        warehouses * 30 + 
+        solar_panels * 10 +
+        accumulators * 100
+      ),
+      0
+    ),
+    accumulators * 150
+  ),
+  alloys = min(
+    (alloys + mining_facilities * 20),
+    ore_refinery * 75
+  ),
+       population = min(
+               (population + round(population * 0.08)),
+               homes * 25
        )`;
 
        try {