diff --git a/src/game-logic/game-logic.service.ts b/src/game-logic/game-logic.service.ts index b37c55b..10f8359 100644 --- a/src/game-logic/game-logic.service.ts +++ b/src/game-logic/game-logic.service.ts @@ -56,6 +56,7 @@ export class GameLogicService { homeSystem.population = empire.resources.population; homeSystem.upgrade = 'upgraded'; homeSystem.capacity *= SYSTEM_UPGRADES.upgraded.capacity_multiplier; + homeSystem.health = SYSTEM_UPGRADES.upgraded.health; if (member?.empire?.homeSystem) { homeSystem.type = member.empire.homeSystem; } @@ -176,6 +177,8 @@ export class GameLogicService { this.processDistricts(system, systemUpkeepPaid, popCoverage, empire, systemVariables, aggregates); this.processBuildings(system, systemUpkeepPaid, popCoverage, empire, systemVariables, aggregates); + this.healSystem(system, empire, systemVariables); + this.deductJoblessUpkeep(system, empire, systemVariables, aggregates); if (popUpkeepPaid) { @@ -293,6 +296,14 @@ export class GameLogicService { } } + private healSystem(system: SystemDocument, empire: EmpireDocument, variables: Record) { + const maxHealth = this.systemLogicService.maxHealthOrDefense(system, empire, 'health', variables); + if (system.health < maxHealth) { + const healingRate = 0.1; + system.health = Math.min(maxHealth, system.health + healingRate * maxHealth); + } + } + private deductJoblessUpkeep(system: SystemDocument, empire: EmpireDocument, variables: Record, aggregates?: Partial>) { const totalJobs = this.getJobs(system); const joblessPops = system.population - totalJobs; diff --git a/src/system/system-logic.service.ts b/src/system/system-logic.service.ts index 9991de1..d5b32b4 100644 --- a/src/system/system-logic.service.ts +++ b/src/system/system-logic.service.ts @@ -203,7 +203,7 @@ export class SystemLogicService { } const baseValue = relevantVariables[upgradeVariable]; - const fortressCount = system.buildings.filter(b => b === 'fortress').length; + const fortressCount = system.buildings.countIf(b => b === 'fortress'); const fortressBonus = fortressCount * relevantVariables[fortressVariable]; const total = baseValue + fortressBonus; if (aggregate) {