Changed loops to be more concise

This commit is contained in:
Daniel Ferri 2021-05-11 20:16:18 +02:00
parent f8a085af7a
commit 1b57c1f7e0

@ -382,22 +382,16 @@ Bladeburner.prototype.process = function() {
this.stamina = Math.min(this.maxStamina, this.stamina); this.stamina = Math.min(this.maxStamina, this.stamina);
// Count increase for contracts/operations // Count increase for contracts/operations
for (var contractName in this.contracts) { for (let contract of Object.values(this.contracts)) {
if (this.contracts.hasOwnProperty(contractName)) {
var contract = this.contracts[contractName];
contract.count += (seconds * contract.countGrowth/BladeburnerConstants.ActionCountGrowthPeriod); contract.count += (seconds * contract.countGrowth/BladeburnerConstants.ActionCountGrowthPeriod);
} }
} for (let op of Object.values(this.operations)) {
for (var operationName in this.operations) {
if (this.operations.hasOwnProperty(operationName)) {
var op = this.operations[operationName];
op.count += (seconds * op.countGrowth/BladeburnerConstants.ActionCountGrowthPeriod); op.count += (seconds * op.countGrowth/BladeburnerConstants.ActionCountGrowthPeriod);
} }
}
// Chaos goes down very slowly // Chaos goes down very slowly
for (var i = 0; i < BladeburnerConstants.CityNames.length; ++i) { for (let cityName of BladeburnerConstants.CityNames) {
var city = this.cities[BladeburnerConstants.CityNames[i]]; var city = this.cities[cityName];
if (!(city instanceof City)) {throw new Error("Invalid City object when processing passive chaos reduction in Bladeburner.process");} if (!(city instanceof City)) {throw new Error("Invalid City object when processing passive chaos reduction in Bladeburner.process");}
city.chaos -= (0.0001 * seconds); city.chaos -= (0.0001 * seconds);
city.chaos = Math.max(0, city.chaos); city.chaos = Math.max(0, city.chaos);