From af0aabb2a6d3e18969f8b52d573b879b81d3a39c Mon Sep 17 00:00:00 2001 From: xangelo Date: Tue, 24 May 2022 12:43:59 -0400 Subject: [PATCH] barracks improve training time --- src/repository/city.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/repository/city.ts b/src/repository/city.ts index 9c2153c..56b57d0 100644 --- a/src/repository/city.ts +++ b/src/repository/city.ts @@ -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; } -- 2.25.1