From 2fc26e4ee3e14091fdf2505d832e166d90044d63 Mon Sep 17 00:00:00 2001 From: xangelo Date: Tue, 24 May 2022 14:03:02 -0400 Subject: [PATCH] sp*trainer buildings now boost training time for those units --- src/repository/city.ts | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/repository/city.ts b/src/repository/city.ts index 56b57d0..d54a55c 100644 --- a/src/repository/city.ts +++ b/src/repository/city.ts @@ -270,9 +270,18 @@ where l.sector_id = ?`, [sector_id]); await this.save(city); // 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}); + let additionalOffset = 0; + if(unit.slug === 'sp_attackers') { + additionalOffset = (this.spAttackerTraininerBoost(city) * unit.time); + } + else if(unit.slug === 'sp_defenders') { + additionalOffset = (this.spDefenderTraininerBoost(city) * unit.time); + } + + const barracksOffset = _.round((this.barracksImprovement(city) * unit.time) + unit.time - additionalOffset, 2); + + const due = Duration.fromObject({ hours: barracksOffset }); const queue = await this.unitTrainigQueue.create( city.owner, @@ -303,6 +312,14 @@ where l.sector_id = ?`, [sector_id]); return city.barracks * 0.0001; } + spAttackerTraininerBoost(city: City): number { + return city.special_attacker_trainer * 0.002; + } + + spDefenderTraininerBoost(city: City): number { + return city.special_defender_trainer * 0.002; + } + maxPopulation(city: City): number { return city.homes * 25; } -- 2.25.1