From: xangelo Date: Tue, 24 May 2022 16:43:59 +0000 (-0400) Subject: barracks improve training time X-Git-Url: https://git.xangelo.ca/?a=commitdiff_plain;h=af0aabb2a6d3e18969f8b52d573b879b81d3a39c;p=browser-rts.git barracks improve training time --- 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; }