From: xangelo Date: Tue, 24 May 2022 18:03:02 +0000 (-0400) Subject: sp*trainer buildings now boost training time for those units X-Git-Url: https://git.xangelo.ca/?a=commitdiff_plain;h=2fc26e4ee3e14091fdf2505d832e166d90044d63;p=browser-rts.git sp*trainer buildings now boost training time for those units --- 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; }