barracks improve training time
authorxangelo <git@xangelo.ca>
Tue, 24 May 2022 16:43:59 +0000 (12:43 -0400)
committerxangelo <git@xangelo.ca>
Tue, 24 May 2022 16:43:59 +0000 (12:43 -0400)
src/repository/city.ts

index 9c2153c263cb79655c7ce9c91c3c386ee3394b14..56b57d030bd8f5a7b82edd73d76f08dccf74fcdb 100644 (file)
@@ -269,7 +269,11 @@ where l.sector_id = ?`, [sector_id]);
 
         await this.save(city);
 
-        const due = Duration.fromObject({ hours: unit.time});
+        // barracks can drop this by 0.01% for each barrack.
+        const barracksOffset = _.round((this.barracksImprovement(city) * unit.time) + unit.time, 2);
+
+        const due = Duration.fromObject({ hours: barracksOffset});
+
         const queue = await this.unitTrainigQueue.create(
             city.owner, 
             DateTime.now().plus({ milliseconds: due.as('milliseconds') }).toMillis(), 
@@ -295,6 +299,10 @@ where l.sector_id = ?`, [sector_id]);
         return power
     }
 
+    barracksImprovement(city: City): number {
+      return city.barracks * 0.0001;
+    }
+
     maxPopulation(city: City): number {
       return city.homes * 25;
     }