Refactor for ... in loops

This commit is contained in:
nickofolas 2022-01-15 18:45:03 -06:00
parent d5c3d89613
commit ab841f7530
54 changed files with 128 additions and 130 deletions

@ -22,12 +22,12 @@ export function loadGlobalAliases(saveString: string): void {
// Prints all aliases to terminal // Prints all aliases to terminal
export function printAliases(): void { export function printAliases(): void {
for (const name in Aliases) { for (const name of Object.keys(Aliases)) {
if (Aliases.hasOwnProperty(name)) { if (Aliases.hasOwnProperty(name)) {
Terminal.print("alias " + name + "=" + Aliases[name]); Terminal.print("alias " + name + "=" + Aliases[name]);
} }
} }
for (const name in GlobalAliases) { for (const name of Object.keys(GlobalAliases)) {
if (GlobalAliases.hasOwnProperty(name)) { if (GlobalAliases.hasOwnProperty(name)) {
Terminal.print("global alias " + name + "=" + GlobalAliases[name]); Terminal.print("global alias " + name + "=" + GlobalAliases[name]);
} }

@ -526,7 +526,7 @@ export class Augmentation {
// Adds this Augmentation to all Factions // Adds this Augmentation to all Factions
addToAllFactions(): void { addToAllFactions(): void {
for (const fac in Factions) { for (const fac of Object.keys(Factions)) {
if (Factions.hasOwnProperty(fac)) { if (Factions.hasOwnProperty(fac)) {
const facObj: Faction | null = Factions[fac]; const facObj: Faction | null = Factions[fac];
if (facObj == null) { if (facObj == null) {

@ -112,7 +112,7 @@ function getRandomBonus(): any {
} }
function initAugmentations(): void { function initAugmentations(): void {
for (const name in Factions) { for (const name of Object.keys(Factions)) {
if (Factions.hasOwnProperty(name)) { if (Factions.hasOwnProperty(name)) {
Factions[name].augmentations = []; Factions[name].augmentations = [];
} }
@ -2498,7 +2498,7 @@ function initAugmentations(): void {
CONSTANTS.MultipleAugMultiplier * [1, 0.96, 0.94, 0.93][SourceFileFlags[11]], CONSTANTS.MultipleAugMultiplier * [1, 0.96, 0.94, 0.93][SourceFileFlags[11]],
Player.queuedAugmentations.length, Player.queuedAugmentations.length,
); );
for (const name in Augmentations) { for (const name of Object.keys(Augmentations)) {
if (Augmentations.hasOwnProperty(name)) { if (Augmentations.hasOwnProperty(name)) {
Augmentations[name].baseCost *= mult; Augmentations[name].baseCost *= mult;
} }
@ -2525,7 +2525,7 @@ function applyAugmentation(aug: IPlayerOwnedAugmentation, reapply = false): void
const augObj = Augmentations[aug.name]; const augObj = Augmentations[aug.name];
// Apply multipliers // Apply multipliers
for (const mult in augObj.mults) { for (const mult of Object.keys(augObj.mults)) {
const v = Player.getMult(mult) * augObj.mults[mult]; const v = Player.getMult(mult) * augObj.mults[mult];
Player.setMult(mult, v); Player.setMult(mult, v);
} }

@ -17,7 +17,7 @@ function calculateAugmentedStats(): any {
const augP: any = {}; const augP: any = {};
for (const aug of Player.queuedAugmentations) { for (const aug of Player.queuedAugmentations) {
const augObj = Augmentations[aug.name]; const augObj = Augmentations[aug.name];
for (const mult in augObj.mults) { for (const mult of Object.keys(augObj.mults)) {
const v = augP[mult] ? augP[mult] : 1; const v = augP[mult] ? augP[mult] : 1;
augP[mult] = v * augObj.mults[mult]; augP[mult] = v * augObj.mults[mult];
} }

@ -578,7 +578,7 @@ export function initBitNodeMultipliers(p: IPlayer): void {
if (p.bitNodeN == null) { if (p.bitNodeN == null) {
p.bitNodeN = 1; p.bitNodeN = 1;
} }
for (const mult in BitNodeMultipliers) { for (const mult of Object.keys(BitNodeMultipliers)) {
if (BitNodeMultipliers.hasOwnProperty(mult)) { if (BitNodeMultipliers.hasOwnProperty(mult)) {
BitNodeMultipliers[mult] = 1; BitNodeMultipliers[mult] = 1;
} }

@ -117,7 +117,7 @@ export class Action implements IAction {
// Check to make sure weights are summed properly // Check to make sure weights are summed properly
let sum = 0; let sum = 0;
for (const weight in this.weights) { for (const weight of Object.keys(this.weights)) {
if (this.weights.hasOwnProperty(weight)) { if (this.weights.hasOwnProperty(weight)) {
sum += this.weights[weight]; sum += this.weights[weight];
} }
@ -131,7 +131,7 @@ export class Action implements IAction {
); );
} }
for (const decay in this.decays) { for (const decay of Object.keys(this.decays)) {
if (this.decays.hasOwnProperty(decay)) { if (this.decays.hasOwnProperty(decay)) {
if (this.decays[decay] > 1) { if (this.decays[decay] > 1) {
throw new Error( throw new Error(
@ -240,7 +240,7 @@ export class Action implements IAction {
} }
let difficulty = this.getDifficulty(); let difficulty = this.getDifficulty();
let competence = 0; let competence = 0;
for (const stat in this.weights) { for (const stat of Object.keys(this.weights)) {
if (this.weights.hasOwnProperty(stat)) { if (this.weights.hasOwnProperty(stat)) {
const playerStatLvl = Player.queryStatFromString(stat); const playerStatLvl = Player.queryStatFromString(stat);
const key = "eff" + stat.charAt(0).toUpperCase() + stat.slice(1); const key = "eff" + stat.charAt(0).toUpperCase() + stat.slice(1);

@ -135,7 +135,7 @@ export class Bladeburner implements IBladeburner {
// Can't start a BlackOp if you haven't done the one before it // Can't start a BlackOp if you haven't done the one before it
const blackops = []; const blackops = [];
for (const nm in BlackOperations) { for (const nm of Object.keys(BlackOperations)) {
if (BlackOperations.hasOwnProperty(nm)) { if (BlackOperations.hasOwnProperty(nm)) {
blackops.push(nm); blackops.push(nm);
} }
@ -1074,7 +1074,7 @@ export class Bladeburner implements IBladeburner {
updateSkillMultipliers(): void { updateSkillMultipliers(): void {
this.resetSkillMultipliers(); this.resetSkillMultipliers();
for (const skillName in this.skills) { for (const skillName of Object.keys(this.skills)) {
if (this.skills.hasOwnProperty(skillName)) { if (this.skills.hasOwnProperty(skillName)) {
const skill = Skills[skillName]; const skill = Skills[skillName];
if (skill == null) { if (skill == null) {

@ -12,7 +12,7 @@ interface IProps {
export function BlackOpList(props: IProps): React.ReactElement { export function BlackOpList(props: IProps): React.ReactElement {
let blackops: BlackOperation[] = []; let blackops: BlackOperation[] = [];
for (const blackopName in BlackOperations) { for (const blackopName of Object.keys(BlackOperations)) {
if (BlackOperations.hasOwnProperty(blackopName)) { if (BlackOperations.hasOwnProperty(blackopName)) {
blackops.push(BlackOperations[blackopName]); blackops.push(BlackOperations[blackopName]);
} }

@ -12,7 +12,7 @@ interface IProps {
export function GeneralActionList(props: IProps): React.ReactElement { export function GeneralActionList(props: IProps): React.ReactElement {
const actions: Action[] = []; const actions: Action[] = [];
for (const name in GeneralActions) { for (const name of Object.keys(GeneralActions)) {
if (GeneralActions.hasOwnProperty(name)) { if (GeneralActions.hasOwnProperty(name)) {
actions.push(GeneralActions[name]); actions.push(GeneralActions[name]);
} }

@ -157,7 +157,7 @@ export function SlotMachine(props: IProps): React.ReactElement {
function step(): void { function step(): void {
let stoppedOne = false; let stoppedOne = false;
const copy = index.slice(); const copy = index.slice();
for (const i in copy) { for (let i = 0; i < copy.length; i++) {
if (copy[i] === locks[i] && !stoppedOne) continue; if (copy[i] === locks[i] && !stoppedOne) continue;
copy[i] = (copy[i] + 1) % symbols.length; copy[i] = (copy[i] + 1) % symbols.length;
stoppedOne = true; stoppedOne = true;

@ -26,7 +26,7 @@ export function initCompanies(): void {
}); });
// Reset data // Reset data
for (const companyName in Companies) { for (const companyName of Object.keys(Companies)) {
const company = Companies[companyName]; const company = Companies[companyName];
const oldCompany = oldCompanies[companyName]; const oldCompany = oldCompanies[companyName];
if (!(oldCompany instanceof Company)) { if (!(oldCompany instanceof Company)) {

@ -307,7 +307,7 @@ export class Corporation {
if (upgN === 1) { if (upgN === 1) {
for (let i = 0; i < this.divisions.length; ++i) { for (let i = 0; i < this.divisions.length; ++i) {
const industry = this.divisions[i]; const industry = this.divisions[i];
for (const city in industry.warehouses) { for (const city of Object.keys(industry.warehouses)) {
const warehouse = industry.warehouses[city]; const warehouse = industry.warehouses[city];
if (warehouse === 0) continue; if (warehouse === 0) continue;
if (industry.warehouses.hasOwnProperty(city) && warehouse instanceof Warehouse) { if (industry.warehouses.hasOwnProperty(city) && warehouse instanceof Warehouse) {

@ -378,7 +378,7 @@ export class Industry implements IIndustry {
updateWarehouseSizeUsed(warehouse: Warehouse): void { updateWarehouseSizeUsed(warehouse: Warehouse): void {
warehouse.updateMaterialSizeUsed(); warehouse.updateMaterialSizeUsed();
for (const prodName in this.products) { for (const prodName of Object.keys(this.products)) {
if (this.products.hasOwnProperty(prodName)) { if (this.products.hasOwnProperty(prodName)) {
const prod = this.products[prodName]; const prod = this.products[prodName];
if (prod === undefined) continue; if (prod === undefined) continue;
@ -414,7 +414,7 @@ export class Industry implements IIndustry {
// Process offices (and the employees in them) // Process offices (and the employees in them)
let employeeSalary = 0; let employeeSalary = 0;
for (const officeLoc in this.offices) { for (const officeLoc of Object.keys(this.offices)) {
const office = this.offices[officeLoc]; const office = this.offices[officeLoc];
if (office === 0) continue; if (office === 0) continue;
if (office instanceof OfficeSpace) { if (office instanceof OfficeSpace) {
@ -470,7 +470,7 @@ export class Industry implements IIndustry {
if (this.warehouses[CorporationConstants.Cities[i]] instanceof Warehouse) { if (this.warehouses[CorporationConstants.Cities[i]] instanceof Warehouse) {
const wh = this.warehouses[CorporationConstants.Cities[i]]; const wh = this.warehouses[CorporationConstants.Cities[i]];
if (wh === 0) continue; if (wh === 0) continue;
for (const name in reqMats) { for (const name of Object.keys(reqMats)) {
if (reqMats.hasOwnProperty(name)) { if (reqMats.hasOwnProperty(name)) {
wh.materials[name].processMarket(); wh.materials[name].processMarket();
} }
@ -493,7 +493,7 @@ export class Industry implements IIndustry {
// Process change in demand and competition for this industry's products // Process change in demand and competition for this industry's products
processProductMarket(marketCycles = 1): void { processProductMarket(marketCycles = 1): void {
// Demand gradually decreases, and competition gradually increases // Demand gradually decreases, and competition gradually increases
for (const name in this.products) { for (const name of Object.keys(this.products)) {
if (this.products.hasOwnProperty(name)) { if (this.products.hasOwnProperty(name)) {
const product = this.products[name]; const product = this.products[name];
if (product === undefined) continue; if (product === undefined) continue;
@ -531,7 +531,7 @@ export class Industry implements IIndustry {
} }
const warehouse = this.warehouses[city]; const warehouse = this.warehouses[city];
if (warehouse === 0) continue; if (warehouse === 0) continue;
for (const matName in warehouse.materials) { for (const matName of Object.keys(warehouse.materials)) {
if (warehouse.materials.hasOwnProperty(matName)) { if (warehouse.materials.hasOwnProperty(matName)) {
const mat = warehouse.materials[matName]; const mat = warehouse.materials[matName];
mat.imp = 0; mat.imp = 0;
@ -552,7 +552,7 @@ export class Industry implements IIndustry {
switch (this.state) { switch (this.state) {
case "PURCHASE": { case "PURCHASE": {
/* Process purchase of materials */ /* Process purchase of materials */
for (const matName in warehouse.materials) { for (const matName of Object.keys(warehouse.materials)) {
if (!warehouse.materials.hasOwnProperty(matName)) continue; if (!warehouse.materials.hasOwnProperty(matName)) continue;
const mat = warehouse.materials[matName]; const mat = warehouse.materials[matName];
let buyAmt = 0; let buyAmt = 0;
@ -574,7 +574,7 @@ export class Industry implements IIndustry {
// smart supply // smart supply
const smartBuy: { [key: string]: number | undefined } = {}; const smartBuy: { [key: string]: number | undefined } = {};
for (const matName in warehouse.materials) { for (const matName of Object.keys(warehouse.materials)) {
if (!warehouse.materials.hasOwnProperty(matName)) continue; if (!warehouse.materials.hasOwnProperty(matName)) continue;
if (!warehouse.smartSupplyEnabled || !Object.keys(this.reqMats).includes(matName)) continue; if (!warehouse.smartSupplyEnabled || !Object.keys(this.reqMats).includes(matName)) continue;
const mat = warehouse.materials[matName]; const mat = warehouse.materials[matName];
@ -591,7 +591,7 @@ export class Industry implements IIndustry {
// Find which material were trying to create the least amount of product with. // Find which material were trying to create the least amount of product with.
let worseAmt = 1e99; let worseAmt = 1e99;
for (const matName in smartBuy) { for (const matName of Object.keys(smartBuy)) {
const buyAmt = smartBuy[matName]; const buyAmt = smartBuy[matName];
if (buyAmt === undefined) throw new Error(`Somehow smartbuy matname is undefined`); if (buyAmt === undefined) throw new Error(`Somehow smartbuy matname is undefined`);
const reqMat = this.reqMats[matName]; const reqMat = this.reqMats[matName];
@ -601,7 +601,7 @@ export class Industry implements IIndustry {
} }
// Align all the materials to the smallest amount. // Align all the materials to the smallest amount.
for (const matName in smartBuy) { for (const matName of Object.keys(smartBuy)) {
const reqMat = this.reqMats[matName]; const reqMat = this.reqMats[matName];
if (reqMat === undefined) throw new Error(`reqMat "${matName}" is undefined`); if (reqMat === undefined) throw new Error(`reqMat "${matName}" is undefined`);
smartBuy[matName] = worseAmt * reqMat; smartBuy[matName] = worseAmt * reqMat;
@ -609,7 +609,7 @@ export class Industry implements IIndustry {
// Calculate the total size of all things were trying to buy // Calculate the total size of all things were trying to buy
let totalSize = 0; let totalSize = 0;
for (const matName in smartBuy) { for (const matName of Object.keys(smartBuy)) {
const buyAmt = smartBuy[matName]; const buyAmt = smartBuy[matName];
if (buyAmt === undefined) throw new Error(`Somehow smartbuy matname is undefined`); if (buyAmt === undefined) throw new Error(`Somehow smartbuy matname is undefined`);
totalSize += buyAmt * MaterialSizes[matName]; totalSize += buyAmt * MaterialSizes[matName];
@ -618,7 +618,7 @@ export class Industry implements IIndustry {
// Shrink to the size of available space. // Shrink to the size of available space.
const freeSpace = warehouse.size - warehouse.sizeUsed; const freeSpace = warehouse.size - warehouse.sizeUsed;
if (totalSize > freeSpace) { if (totalSize > freeSpace) {
for (const matName in smartBuy) { for (const matName of Object.keys(smartBuy)) {
const buyAmt = smartBuy[matName]; const buyAmt = smartBuy[matName];
if (buyAmt === undefined) throw new Error(`Somehow smartbuy matname is undefined`); if (buyAmt === undefined) throw new Error(`Somehow smartbuy matname is undefined`);
smartBuy[matName] = Math.floor((buyAmt * freeSpace) / totalSize); smartBuy[matName] = Math.floor((buyAmt * freeSpace) / totalSize);
@ -626,7 +626,7 @@ export class Industry implements IIndustry {
} }
// Use the materials already in the warehouse if the option is on. // Use the materials already in the warehouse if the option is on.
for (const matName in smartBuy) { for (const matName of Object.keys(smartBuy)) {
if (!warehouse.smartSupplyUseLeftovers[matName]) continue; if (!warehouse.smartSupplyUseLeftovers[matName]) continue;
const mat = warehouse.materials[matName]; const mat = warehouse.materials[matName];
const buyAmt = smartBuy[matName]; const buyAmt = smartBuy[matName];
@ -635,7 +635,7 @@ export class Industry implements IIndustry {
} }
// buy them // buy them
for (const matName in smartBuy) { for (const matName of Object.keys(smartBuy)) {
const mat = warehouse.materials[matName]; const mat = warehouse.materials[matName];
const buyAmt = smartBuy[matName]; const buyAmt = smartBuy[matName];
if (buyAmt === undefined) throw new Error(`Somehow smartbuy matname is undefined`); if (buyAmt === undefined) throw new Error(`Somehow smartbuy matname is undefined`);
@ -672,7 +672,7 @@ export class Industry implements IIndustry {
for (let tmp = 0; tmp < this.prodMats.length; ++tmp) { for (let tmp = 0; tmp < this.prodMats.length; ++tmp) {
totalMatSize += MaterialSizes[this.prodMats[tmp]]; totalMatSize += MaterialSizes[this.prodMats[tmp]];
} }
for (const reqMatName in this.reqMats) { for (const reqMatName of Object.keys(this.reqMats)) {
const normQty = this.reqMats[reqMatName]; const normQty = this.reqMats[reqMatName];
if (normQty === undefined) continue; if (normQty === undefined) continue;
totalMatSize -= MaterialSizes[reqMatName] * normQty; totalMatSize -= MaterialSizes[reqMatName] * normQty;
@ -692,7 +692,7 @@ export class Industry implements IIndustry {
// Make sure we have enough resource to make our materials // Make sure we have enough resource to make our materials
let producableFrac = 1; let producableFrac = 1;
for (const reqMatName in this.reqMats) { for (const reqMatName of Object.keys(this.reqMats)) {
if (this.reqMats.hasOwnProperty(reqMatName)) { if (this.reqMats.hasOwnProperty(reqMatName)) {
const reqMat = this.reqMats[reqMatName]; const reqMat = this.reqMats[reqMatName];
if (reqMat === undefined) continue; if (reqMat === undefined) continue;
@ -709,7 +709,7 @@ export class Industry implements IIndustry {
// Make our materials if they are producable // Make our materials if they are producable
if (producableFrac > 0 && prod > 0) { if (producableFrac > 0 && prod > 0) {
for (const reqMatName in this.reqMats) { for (const reqMatName of Object.keys(this.reqMats)) {
const reqMat = this.reqMats[reqMatName]; const reqMat = this.reqMats[reqMatName];
if (reqMat === undefined) continue; if (reqMat === undefined) continue;
const reqMatQtyNeeded = reqMat * prod * producableFrac; const reqMatQtyNeeded = reqMat * prod * producableFrac;
@ -726,7 +726,7 @@ export class Industry implements IIndustry {
Math.pow(warehouse.materials["AICores"].qty, this.aiFac) / 10e3; Math.pow(warehouse.materials["AICores"].qty, this.aiFac) / 10e3;
} }
} else { } else {
for (const reqMatName in this.reqMats) { for (const reqMatName of Object.keys(this.reqMats)) {
if (this.reqMats.hasOwnProperty(reqMatName)) { if (this.reqMats.hasOwnProperty(reqMatName)) {
warehouse.materials[reqMatName].prd = 0; warehouse.materials[reqMatName].prd = 0;
} }
@ -742,7 +742,7 @@ export class Industry implements IIndustry {
//If this doesn't produce any materials, then it only creates //If this doesn't produce any materials, then it only creates
//Products. Creating products will consume materials. The //Products. Creating products will consume materials. The
//Production of all consumed materials must be set to 0 //Production of all consumed materials must be set to 0
for (const reqMatName in this.reqMats) { for (const reqMatName of Object.keys(this.reqMats)) {
warehouse.materials[reqMatName].prd = 0; warehouse.materials[reqMatName].prd = 0;
} }
} }
@ -750,7 +750,7 @@ export class Industry implements IIndustry {
case "SALE": case "SALE":
/* Process sale of materials */ /* Process sale of materials */
for (const matName in warehouse.materials) { for (const matName of Object.keys(warehouse.materials)) {
if (warehouse.materials.hasOwnProperty(matName)) { if (warehouse.materials.hasOwnProperty(matName)) {
const mat = warehouse.materials[matName]; const mat = warehouse.materials[matName];
if (mat.sCost < 0 || mat.sllman[0] === false) { if (mat.sCost < 0 || mat.sllman[0] === false) {
@ -881,7 +881,7 @@ export class Industry implements IIndustry {
break; break;
case "EXPORT": case "EXPORT":
for (const matName in warehouse.materials) { for (const matName of Object.keys(warehouse.materials)) {
if (warehouse.materials.hasOwnProperty(matName)) { if (warehouse.materials.hasOwnProperty(matName)) {
const mat = warehouse.materials[matName]; const mat = warehouse.materials[matName];
mat.totalExp = 0; //Reset export mat.totalExp = 0; //Reset export
@ -993,7 +993,7 @@ export class Industry implements IIndustry {
//Create products //Create products
if (this.state === "PRODUCTION") { if (this.state === "PRODUCTION") {
for (const prodName in this.products) { for (const prodName of Object.keys(this.products)) {
const prod = this.products[prodName]; const prod = this.products[prodName];
if (prod === undefined) continue; if (prod === undefined) continue;
if (!prod.fin) { if (!prod.fin) {
@ -1025,7 +1025,7 @@ export class Industry implements IIndustry {
} }
//Produce Products //Produce Products
for (const prodName in this.products) { for (const prodName of Object.keys(this.products)) {
if (this.products.hasOwnProperty(prodName)) { if (this.products.hasOwnProperty(prodName)) {
const prod = this.products[prodName]; const prod = this.products[prodName];
if (prod instanceof Product && prod.fin) { if (prod instanceof Product && prod.fin) {
@ -1067,7 +1067,7 @@ export class Industry implements IIndustry {
//Calculate net change in warehouse storage making the Products will cost //Calculate net change in warehouse storage making the Products will cost
let netStorageSize = product.siz; let netStorageSize = product.siz;
for (const reqMatName in product.reqMats) { for (const reqMatName of Object.keys(product.reqMats)) {
if (product.reqMats.hasOwnProperty(reqMatName)) { if (product.reqMats.hasOwnProperty(reqMatName)) {
const normQty = product.reqMats[reqMatName]; const normQty = product.reqMats[reqMatName];
netStorageSize -= MaterialSizes[reqMatName] * normQty; netStorageSize -= MaterialSizes[reqMatName] * normQty;
@ -1084,7 +1084,7 @@ export class Industry implements IIndustry {
//Make sure we have enough resources to make our Products //Make sure we have enough resources to make our Products
let producableFrac = 1; let producableFrac = 1;
for (const reqMatName in product.reqMats) { for (const reqMatName of Object.keys(product.reqMats)) {
if (product.reqMats.hasOwnProperty(reqMatName)) { if (product.reqMats.hasOwnProperty(reqMatName)) {
const req = product.reqMats[reqMatName] * prod; const req = product.reqMats[reqMatName] * prod;
if (warehouse.materials[reqMatName].qty < req) { if (warehouse.materials[reqMatName].qty < req) {
@ -1095,7 +1095,7 @@ export class Industry implements IIndustry {
//Make our Products if they are producable //Make our Products if they are producable
if (producableFrac > 0 && prod > 0) { if (producableFrac > 0 && prod > 0) {
for (const reqMatName in product.reqMats) { for (const reqMatName of Object.keys(product.reqMats)) {
if (product.reqMats.hasOwnProperty(reqMatName)) { if (product.reqMats.hasOwnProperty(reqMatName)) {
const reqMatQtyNeeded = product.reqMats[reqMatName] * prod * producableFrac; const reqMatQtyNeeded = product.reqMats[reqMatName] * prod * producableFrac;
warehouse.materials[reqMatName].qty -= reqMatQtyNeeded; warehouse.materials[reqMatName].qty -= reqMatQtyNeeded;
@ -1114,7 +1114,7 @@ export class Industry implements IIndustry {
case "SALE": { case "SALE": {
//Process sale of Products //Process sale of Products
product.pCost = 0; //Estimated production cost product.pCost = 0; //Estimated production cost
for (const reqMatName in product.reqMats) { for (const reqMatName of Object.keys(product.reqMats)) {
if (product.reqMats.hasOwnProperty(reqMatName)) { if (product.reqMats.hasOwnProperty(reqMatName)) {
product.pCost += product.reqMats[reqMatName] * warehouse.materials[reqMatName].bCost; product.pCost += product.reqMats[reqMatName] * warehouse.materials[reqMatName].bCost;
} }
@ -1250,7 +1250,7 @@ export class Industry implements IIndustry {
} }
discontinueProduct(product: Product): void { discontinueProduct(product: Product): void {
for (const productName in this.products) { for (const productName of Object.keys(this.products)) {
if (this.products.hasOwnProperty(productName)) { if (this.products.hasOwnProperty(productName)) {
if (product === this.products[productName]) { if (product === this.products[productName]) {
delete this.products[productName]; delete this.products[productName];
@ -1354,7 +1354,7 @@ export class Industry implements IIndustry {
// Since ResearchTree data isnt saved, we'll update the Research Tree data // Since ResearchTree data isnt saved, we'll update the Research Tree data
// based on the stored 'researched' property in the Industry object // based on the stored 'researched' property in the Industry object
if (Object.keys(researchTree.researched).length !== Object.keys(this.researched).length) { if (Object.keys(researchTree.researched).length !== Object.keys(this.researched).length) {
for (const research in this.researched) { for (const research of Object.keys(this.researched)) {
researchTree.research(research); researchTree.research(research);
} }
} }

@ -103,7 +103,7 @@ export class OfficeSpace {
calculateEmployeeProductivity(corporation: ICorporation, industry: IIndustry): void { calculateEmployeeProductivity(corporation: ICorporation, industry: IIndustry): void {
//Reset //Reset
for (const name in this.employeeProd) { for (const name of Object.keys(this.employeeProd)) {
this.employeeProd[name] = 0; this.employeeProd[name] = 0;
} }

@ -198,7 +198,7 @@ export class Product {
//Calculate the product's required materials //Calculate the product's required materials
//For now, just set it to be the same as the requirements to make materials //For now, just set it to be the same as the requirements to make materials
for (const matName in industry.reqMats) { for (const matName of Object.keys(industry.reqMats)) {
if (industry.reqMats.hasOwnProperty(matName)) { if (industry.reqMats.hasOwnProperty(matName)) {
const reqMat = industry.reqMats[matName]; const reqMat = industry.reqMats[matName];
if (reqMat === undefined) continue; if (reqMat === undefined) continue;
@ -209,7 +209,7 @@ export class Product {
//Calculate the product's size //Calculate the product's size
//For now, just set it to be the same size as the requirements to make materials //For now, just set it to be the same size as the requirements to make materials
this.siz = 0; this.siz = 0;
for (const matName in industry.reqMats) { for (const matName of Object.keys(industry.reqMats)) {
const reqMat = industry.reqMats[matName]; const reqMat = industry.reqMats[matName];
if (reqMat === undefined) continue; if (reqMat === undefined) continue;
this.siz += MaterialSizes[matName] * reqMat; this.siz += MaterialSizes[matName] * reqMat;

@ -85,7 +85,7 @@ export class Warehouse {
// Re-calculate how much space is being used by this Warehouse // Re-calculate how much space is being used by this Warehouse
updateMaterialSizeUsed(): void { updateMaterialSizeUsed(): void {
this.sizeUsed = 0; this.sizeUsed = 0;
for (const matName in this.materials) { for (const matName of Object.keys(this.materials)) {
const mat = this.materials[matName]; const mat = this.materials[matName];
if (MaterialSizes.hasOwnProperty(matName)) { if (MaterialSizes.hasOwnProperty(matName)) {
this.sizeUsed += mat.qty * MaterialSizes[matName]; this.sizeUsed += mat.qty * MaterialSizes[matName];

@ -215,7 +215,7 @@ function Upgrades(props: { office: OfficeSpace; rerender: () => void }): React.R
const corp = useCorporation(); const corp = useCorporation();
const division = useDivision(); const division = useDivision();
const upgrades = []; const upgrades = [];
for (const index in IndustryUpgrades) { for (const index of Object.keys(IndustryUpgrades)) {
const upgrade = IndustryUpgrades[index]; const upgrade = IndustryUpgrades[index];
// AutoBrew research disables the Coffee upgrade // AutoBrew research disables the Coffee upgrade

@ -81,7 +81,7 @@ function WarehouseRoot(props: IProps): React.ReactElement {
// Create React components for materials // Create React components for materials
const mats = []; const mats = [];
for (const matName in props.warehouse.materials) { for (const matName of Object.keys(props.warehouse.materials)) {
if (!(props.warehouse.materials[matName] instanceof Material)) continue; if (!(props.warehouse.materials[matName] instanceof Material)) continue;
// Only create UI for materials that are relevant for the industry // Only create UI for materials that are relevant for the industry
if (!isRelevantMaterial(matName, division)) continue; if (!isRelevantMaterial(matName, division)) continue;
@ -99,7 +99,7 @@ function WarehouseRoot(props: IProps): React.ReactElement {
// Create React components for products // Create React components for products
const products = []; const products = [];
if (division.makesProducts && Object.keys(division.products).length > 0) { if (division.makesProducts && Object.keys(division.products).length > 0) {
for (const productName in division.products) { for (const productName of Object.keys(division.products)) {
const product = division.products[productName]; const product = division.products[productName];
if (!(product instanceof Product)) continue; if (!(product instanceof Product)) continue;
products.push( products.push(
@ -109,14 +109,14 @@ function WarehouseRoot(props: IProps): React.ReactElement {
} }
const breakdownItems: JSX.Element[] = []; const breakdownItems: JSX.Element[] = [];
for (const matName in props.warehouse.materials) { for (const matName of Object.keys(props.warehouse.materials)) {
const mat = props.warehouse.materials[matName]; const mat = props.warehouse.materials[matName];
if (!MaterialSizes.hasOwnProperty(matName)) continue; if (!MaterialSizes.hasOwnProperty(matName)) continue;
if (mat.qty === 0) continue; if (mat.qty === 0) continue;
breakdownItems.push(<>{matName}: {numeralWrapper.format(mat.qty * MaterialSizes[matName], "0,0.0")}</>); breakdownItems.push(<>{matName}: {numeralWrapper.format(mat.qty * MaterialSizes[matName], "0,0.0")}</>);
} }
for (const prodName in division.products) { for (const prodName of Object.keys(division.products)) {
const prod = division.products[prodName]; const prod = division.products[prodName];
if (prod === undefined) continue; if (prod === undefined) continue;
breakdownItems.push(<>{prodName}: {numeralWrapper.format(prod.data[props.warehouse.loc][0] * prod.siz, "0,0.0")}</>); breakdownItems.push(<>{prodName}: {numeralWrapper.format(prod.data[props.warehouse.loc][0] * prod.siz, "0,0.0")}</>);

@ -60,7 +60,7 @@ export function SmartSupplyModal(props: IProps): React.ReactElement {
// Create React components for materials // Create React components for materials
const mats = []; const mats = [];
for (const matName in props.warehouse.materials) { for (const matName of Object.keys(props.warehouse.materials)) {
if (!(props.warehouse.materials[matName] instanceof Material)) continue; if (!(props.warehouse.materials[matName] instanceof Material)) continue;
if (!Object.keys(division.reqMats).includes(matName)) continue; if (!Object.keys(division.reqMats).includes(matName)) continue;
mats.push(<Leftover key={matName} warehouse={props.warehouse} matName={matName} />); mats.push(<Leftover key={matName} warehouse={props.warehouse} matName={matName} />);

@ -7,7 +7,7 @@ import { dialogBoxCreate } from "../ui/React/DialogBox";
export function determineCrimeSuccess(p: IPlayer, type: string): boolean { export function determineCrimeSuccess(p: IPlayer, type: string): boolean {
let chance = 0; let chance = 0;
let found = false; let found = false;
for (const i in Crimes) { for (const i of Object.keys(Crimes)) {
const crime = Crimes[i]; const crime = Crimes[i];
if (crime.type == type) { if (crime.type == type) {
chance = crime.successRate(p); chance = crime.successRate(p);

@ -21,7 +21,7 @@ export function checkIfConnectedToDarkweb(): void {
} }
export function listAllDarkwebItems(): void { export function listAllDarkwebItems(): void {
for (const key in DarkWebItems) { for (const key of Object.keys(DarkWebItems)) {
const item = DarkWebItems[key]; const item = DarkWebItems[key];
const cost = Player.getHomeComputer().programs.includes(item.program) ? ( const cost = Player.getHomeComputer().programs.includes(item.program) ? (
@ -44,7 +44,7 @@ export function buyDarkwebItem(itemName: string): void {
// find the program that matches, if any // find the program that matches, if any
let item: DarkWebItem | null = null; let item: DarkWebItem | null = null;
for (const key in DarkWebItems) { for (const key of Object.keys(DarkWebItems)) {
const i = DarkWebItems[key]; const i = DarkWebItems[key];
if (i.program.toLowerCase() == itemName) { if (i.program.toLowerCase() == itemName) {
item = i; item = i;
@ -93,7 +93,7 @@ export function buyAllDarkwebItems(): void {
const itemsToBuy: DarkWebItem[] = []; const itemsToBuy: DarkWebItem[] = [];
let cost = 0; let cost = 0;
for (const key in DarkWebItems) { for (const key of Object.keys(DarkWebItems)) {
const item = DarkWebItems[key]; const item = DarkWebItems[key];
if (!Player.hasProgram(item.program)) { if (!Player.hasProgram(item.program)) {
itemsToBuy.push(item); itemsToBuy.push(item);

@ -46,25 +46,25 @@ export function Companies(): React.ReactElement {
} }
function tonsOfRepCompanies(): void { function tonsOfRepCompanies(): void {
for (const c in AllCompanies) { for (const c of Object.keys(AllCompanies)) {
AllCompanies[c].playerReputation = bigNumber; AllCompanies[c].playerReputation = bigNumber;
} }
} }
function resetAllRepCompanies(): void { function resetAllRepCompanies(): void {
for (const c in AllCompanies) { for (const c of Object.keys(AllCompanies)) {
AllCompanies[c].playerReputation = 0; AllCompanies[c].playerReputation = 0;
} }
} }
function tonsOfFavorCompanies(): void { function tonsOfFavorCompanies(): void {
for (const c in AllCompanies) { for (const c of Object.keys(AllCompanies)) {
AllCompanies[c].favor = bigNumber; AllCompanies[c].favor = bigNumber;
} }
} }
function resetAllFavorCompanies(): void { function resetAllFavorCompanies(): void {
for (const c in AllCompanies) { for (const c of Object.keys(AllCompanies)) {
AllCompanies[c].favor = 0; AllCompanies[c].favor = 0;
} }
} }

@ -36,7 +36,7 @@ export function Factions(props: IProps): React.ReactElement {
} }
function receiveAllInvites(): void { function receiveAllInvites(): void {
for (const i in AllFaction) { for (const i of Object.keys(AllFaction)) {
props.player.receiveInvite(AllFaction[i].name); props.player.receiveInvite(AllFaction[i].name);
} }
} }
@ -74,25 +74,25 @@ export function Factions(props: IProps): React.ReactElement {
} }
function tonsOfRep(): void { function tonsOfRep(): void {
for (const i in AllFaction) { for (const i of Object.keys(AllFaction)) {
AllFaction[i].playerReputation = bigNumber; AllFaction[i].playerReputation = bigNumber;
} }
} }
function resetAllRep(): void { function resetAllRep(): void {
for (const i in AllFaction) { for (const i of Object.keys(AllFaction)) {
AllFaction[i].playerReputation = 0; AllFaction[i].playerReputation = 0;
} }
} }
function tonsOfFactionFavor(): void { function tonsOfFactionFavor(): void {
for (const i in AllFaction) { for (const i of Object.keys(AllFaction)) {
AllFaction[i].favor = bigNumber; AllFaction[i].favor = bigNumber;
} }
} }
function resetAllFactionFavor(): void { function resetAllFactionFavor(): void {
for (const i in AllFaction) { for (const i of Object.keys(AllFaction)) {
AllFaction[i].favor = 0; AllFaction[i].favor = 0;
} }
} }

@ -28,7 +28,7 @@ export function Programs(props: IProps): React.ReactElement {
} }
function addAllPrograms(): void { function addAllPrograms(): void {
for (const i in AllPrograms) { for (const i of Object.keys(AllPrograms)) {
if (!props.player.hasProgram(AllPrograms[i].name)) { if (!props.player.hasProgram(AllPrograms[i].name)) {
props.player.getHomeComputer().programs.push(AllPrograms[i].name); props.player.getHomeComputer().programs.push(AllPrograms[i].name);
} }

@ -38,7 +38,7 @@ export function StockMarket(): React.ReactElement {
}; };
} }
for (const name in SM) { for (const name of Object.keys(SM)) {
if (SM.hasOwnProperty(name)) { if (SM.hasOwnProperty(name)) {
const stock = SM[name]; const stock = SM[name];
if (stock instanceof Stock && match(stock.symbol)) { if (stock instanceof Stock && match(stock.symbol)) {

@ -34,8 +34,7 @@ export function joinFaction(faction: Faction): void {
const factionInfo = faction.getInfo(); const factionInfo = faction.getInfo();
//Determine what factions you are banned from now that you have joined this faction //Determine what factions you are banned from now that you have joined this faction
for (const i in factionInfo.enemies) { for (const enemy of factionInfo.enemies) {
const enemy = factionInfo.enemies[i];
if (Factions[enemy] instanceof Faction) { if (Factions[enemy] instanceof Faction) {
Factions[enemy].isBanned = true; Factions[enemy].isBanned = true;
} }
@ -121,7 +120,7 @@ export function purchaseAugmentation(aug: Augmentation, fac: Faction, sing = fal
} }
} }
for (const name in Augmentations) { for (const name of Object.keys(Augmentations)) {
if (Augmentations.hasOwnProperty(name)) { if (Augmentations.hasOwnProperty(name)) {
Augmentations[name].baseCost *= CONSTANTS.MultipleAugMultiplier * [1, 0.96, 0.94, 0.93][SourceFileFlags[11]]; Augmentations[name].baseCost *= CONSTANTS.MultipleAugMultiplier * [1, 0.96, 0.94, 0.93][SourceFileFlags[11]];
} }
@ -170,7 +169,7 @@ export function getNextNeurofluxLevel(): number {
} }
export function processPassiveFactionRepGain(numCycles: number): void { export function processPassiveFactionRepGain(numCycles: number): void {
for (const name in Factions) { for (const name of Object.keys(Factions)) {
if (name === Player.currentWorkFactionName) continue; if (name === Player.currentWorkFactionName) continue;
if (!Factions.hasOwnProperty(name)) continue; if (!Factions.hasOwnProperty(name)) continue;
const faction = Factions[name]; const faction = Factions[name];

@ -34,7 +34,7 @@ export function factionExists(name: string): boolean {
} }
export function initFactions(): void { export function initFactions(): void {
for (const name in FactionInfos) { for (const name of Object.keys(FactionInfos)) {
resetFaction(new Faction(name)); resetFaction(new Faction(name));
} }
} }

@ -44,7 +44,7 @@ export function AugmentationsPage(props: IProps): React.ReactElement {
function getAugs(): string[] { function getAugs(): string[] {
if (isPlayersGang) { if (isPlayersGang) {
const augs: string[] = []; const augs: string[] = [];
for (const augName in Augmentations) { for (const augName of Object.keys(Augmentations)) {
if (augName === AugmentationNames.NeuroFluxGovernor) continue; if (augName === AugmentationNames.NeuroFluxGovernor) continue;
if (augName === AugmentationNames.TheRedPill && player.bitNodeN !== 2) continue; if (augName === AugmentationNames.TheRedPill && player.bitNodeN !== 2) continue;
const aug = Augmentations[augName]; const aug = Augmentations[augName];

@ -158,7 +158,7 @@ export class Gang implements IGang {
// Process power first // Process power first
const gangName = this.facName; const gangName = this.facName;
for (const name in AllGangs) { for (const name of Object.keys(AllGangs)) {
if (AllGangs.hasOwnProperty(name)) { if (AllGangs.hasOwnProperty(name)) {
if (name == gangName) { if (name == gangName) {
AllGangs[name].power += this.calculatePower(); AllGangs[name].power += this.calculatePower();

@ -24,7 +24,7 @@ export class HashManager {
upgrades: IMap<number> = {}; upgrades: IMap<number> = {};
constructor() { constructor() {
for (const name in HashUpgrades) { for (const name of Object.keys(HashUpgrades)) {
this.upgrades[name] = 0; this.upgrades[name] = 0;
} }
} }
@ -85,7 +85,7 @@ export class HashManager {
} }
prestige(): void { prestige(): void {
for (const name in HashUpgrades) { for (const name of Object.keys(HashUpgrades)) {
this.upgrades[name] = 0; this.upgrades[name] = 0;
} }
this.hashes = 0; this.hashes = 0;

@ -220,7 +220,7 @@ for (const metadata of LocationsMetadata) {
const cityName = loc.city; const cityName = loc.city;
if (cityName === null) { if (cityName === null) {
// Generic location, add to all cities // Generic location, add to all cities
for (const city in Cities) { for (const city of Object.keys(Cities)) {
Cities[city].addLocation(loc.name); Cities[city].addLocation(loc.name);
} }
} else { } else {

@ -132,10 +132,10 @@ function ASCIICity(props: IProps): React.ReactElement {
const elems: JSX.Element[] = []; const elems: JSX.Element[] = [];
const lines = props.city.asciiArt.split("\n"); const lines = props.city.asciiArt.split("\n");
for (const i in lines) { for (const line of lines) {
elems.push( elems.push(
<Typography key={i} sx={{ lineHeight: "1em", whiteSpace: "pre" }}> <Typography key={line} sx={{ lineHeight: "1em", whiteSpace: "pre" }}>
{lineElems(lines[i])} {lineElems(line)}
</Typography>, </Typography>,
); );
} }

@ -762,7 +762,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
}, },
disableLog: function (fn: any): any { disableLog: function (fn: any): any {
if (fn === "ALL") { if (fn === "ALL") {
for (fn in possibleLogs) { for (fn of Object.keys(possibleLogs)) {
workerScript.disableLogs[fn] = true; workerScript.disableLogs[fn] = true;
} }
workerScript.log("disableLog", () => `Disabled logging for all functions`); workerScript.log("disableLog", () => `Disabled logging for all functions`);
@ -775,7 +775,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
}, },
enableLog: function (fn: any): any { enableLog: function (fn: any): any {
if (fn === "ALL") { if (fn === "ALL") {
for (fn in possibleLogs) { for (fn of Object.keys(possibleLogs)) {
delete workerScript.disableLogs[fn]; delete workerScript.disableLogs[fn];
} }
workerScript.log("enableLog", () => `Enabled logging for all functions`); workerScript.log("enableLog", () => `Enabled logging for all functions`);
@ -1302,8 +1302,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
updateDynamicRam("ps", getRamCost(Player, "ps")); updateDynamicRam("ps", getRamCost(Player, "ps"));
const server = safeGetServer(hostname, "ps"); const server = safeGetServer(hostname, "ps");
const processes = []; const processes = [];
for (const i in server.runningScripts) { for (const script of server.runningScripts) {
const script = server.runningScripts[i];
processes.push({ processes.push({
filename: script.filename, filename: script.filename,
threads: script.threads, threads: script.threads,

@ -101,7 +101,7 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
helper.updateDynamicRam("getOtherGangInformation", getRamCost(player, "gang", "getOtherGangInformation")); helper.updateDynamicRam("getOtherGangInformation", getRamCost(player, "gang", "getOtherGangInformation"));
checkGangApiAccess("getOtherGangInformation"); checkGangApiAccess("getOtherGangInformation");
const cpy: any = {}; const cpy: any = {};
for (const gang in AllGangs) { for (const gang of Object.keys(AllGangs)) {
cpy[gang] = Object.assign({}, AllGangs[gang]); cpy[gang] = Object.assign({}, AllGangs[gang]);
} }

@ -113,7 +113,7 @@ export function NetscriptSingularity(
// If player has a gang with this faction, return all augmentations. // If player has a gang with this faction, return all augmentations.
if (player.hasGangWith(facname)) { if (player.hasGangWith(facname)) {
const res = []; const res = [];
for (const augName in Augmentations) { for (const augName of Object.keys(Augmentations)) {
if (augName === AugmentationNames.NeuroFluxGovernor) continue; if (augName === AugmentationNames.NeuroFluxGovernor) continue;
if (augName === AugmentationNames.TheRedPill && player.bitNodeN !== 2) continue; if (augName === AugmentationNames.TheRedPill && player.bitNodeN !== 2) continue;
const aug = Augmentations[augName]; const aug = Augmentations[augName];
@ -165,7 +165,7 @@ export function NetscriptSingularity(
let augs = []; let augs = [];
if (player.hasGangWith(faction)) { if (player.hasGangWith(faction)) {
for (const augName in Augmentations) { for (const augName of Object.keys(Augmentations)) {
if (augName === AugmentationNames.NeuroFluxGovernor) continue; if (augName === AugmentationNames.NeuroFluxGovernor) continue;
if (augName === AugmentationNames.TheRedPill && player.bitNodeN !== 2) continue; if (augName === AugmentationNames.TheRedPill && player.bitNodeN !== 2) continue;
const tempAug = Augmentations[augName]; const tempAug = Augmentations[augName];

@ -273,7 +273,7 @@ export function NetscriptStockMarket(player: IPlayer, workerScript: WorkerScript
const orders: any = {}; const orders: any = {};
const stockMarketOrders = StockMarket["Orders"]; const stockMarketOrders = StockMarket["Orders"];
for (const symbol in stockMarketOrders) { for (const symbol of Object.keys(stockMarketOrders)) {
const orderBook = stockMarketOrders[symbol]; const orderBook = stockMarketOrders[symbol];
if (orderBook.constructor === Array && orderBook.length > 0) { if (orderBook.constructor === Array && orderBook.length > 0) {
orders[symbol] = []; orders[symbol] = [];

@ -28,7 +28,7 @@ export function toNative(pseudoObj: any): any {
} else { } else {
// Object. // Object.
nativeObj = {}; nativeObj = {};
for (const key in pseudoObj.properties) { for (const key of Object.keys(pseudoObj.properties)) {
const val = pseudoObj.properties[key]; const val = pseudoObj.properties[key];
nativeObj[key] = toNative(val); nativeObj[key] = toNative(val);
} }

@ -221,7 +221,7 @@ function _getScriptUrls(script: Script, scripts: Script[], seen: Script[]): Scri
return urlStack; return urlStack;
} catch (err) { } catch (err) {
// If there is an error, we need to clean up the URLs. // If there is an error, we need to clean up the URLs.
for (const url in urlStack) URL.revokeObjectURL(url); for (const url of urlStack) URL.revokeObjectURL(url.url);
throw err; throw err;
} finally { } finally {
seen.pop(); seen.pop();

@ -116,7 +116,7 @@ function startNetscript2Script(player: IPlayer, workerScript: WorkerScript): Pro
}; };
} }
for (const prop in workerScript.env.vars) { for (const prop of Object.keys(workerScript.env.vars)) {
if (typeof workerScript.env.vars[prop] !== "function") continue; if (typeof workerScript.env.vars[prop] !== "function") continue;
workerScript.env.vars[prop] = wrap(prop, workerScript.env.vars[prop]); workerScript.env.vars[prop] = wrap(prop, workerScript.env.vars[prop]);
} }
@ -175,7 +175,7 @@ function startNetscript1Script(workerScript: WorkerScript): Promise<WorkerScript
const interpreterInitialization = function (int: any, scope: any): void { const interpreterInitialization = function (int: any, scope: any): void {
//Add the Netscript environment //Add the Netscript environment
const ns = NetscriptFunctions(workerScript); const ns = NetscriptFunctions(workerScript);
for (const name in ns) { for (const name of Object.keys(ns)) {
const entry = ns[name]; const entry = ns[name];
if (typeof entry === "function") { if (typeof entry === "function") {
//Async functions need to be wrapped. See JS-Interpreter documentation //Async functions need to be wrapped. See JS-Interpreter documentation

@ -112,7 +112,7 @@ export abstract class Person {
* Updates this object's multipliers for the given augmentation * Updates this object's multipliers for the given augmentation
*/ */
applyAugmentation(aug: Augmentation): void { applyAugmentation(aug: Augmentation): void {
for (const mult in aug.mults) { for (const mult of Object.keys(aug.mults)) {
if ((this as any)[mult] == null) { if ((this as any)[mult] == null) {
console.warn(`Augmentation has unrecognized multiplier property: ${mult}`); console.warn(`Augmentation has unrecognized multiplier property: ${mult}`);
} else { } else {

@ -1484,7 +1484,7 @@ export function finishCrime(this: IPlayer, cancelled: boolean): string {
if (determineCrimeSuccess(this, this.crimeType)) { if (determineCrimeSuccess(this, this.crimeType)) {
//Handle Karma and crime statistics //Handle Karma and crime statistics
let crime = null; let crime = null;
for (const i in Crimes) { for (const i of Object.keys(Crimes)) {
if (Crimes[i].type == this.crimeType) { if (Crimes[i].type == this.crimeType) {
crime = Crimes[i]; crime = Crimes[i];
break; break;
@ -2556,15 +2556,15 @@ export function setBitNodeNumber(this: IPlayer, n: number): void {
} }
export function queueAugmentation(this: IPlayer, name: string): void { export function queueAugmentation(this: IPlayer, name: string): void {
for (const i in this.queuedAugmentations) { for (const aug of this.queuedAugmentations) {
if (this.queuedAugmentations[i].name == name) { if (aug.name == name) {
console.warn(`tried to queue ${name} twice, this may be a bug`); console.warn(`tried to queue ${name} twice, this may be a bug`);
return; return;
} }
} }
for (const i in this.augmentations) { for (const aug of this.augmentations) {
if (this.augmentations[i].name == name) { if (aug.name == name) {
console.warn(`tried to queue ${name} twice, this may be a bug`); console.warn(`tried to queue ${name} twice, this may be a bug`);
return; return;
} }

@ -37,7 +37,7 @@ export function purchaseResleeve(r: Resleeve, p: IPlayer): boolean {
p.charisma_exp = r.charisma_exp; p.charisma_exp = r.charisma_exp;
// Reset Augmentation "owned" data // Reset Augmentation "owned" data
for (const augKey in Augmentations) { for (const augKey of Object.keys(Augmentations)) {
Augmentations[augKey].owned = false; Augmentations[augKey].owned = false;
} }

@ -42,7 +42,7 @@ export function findSleevePurchasableAugs(sleeve: Sleeve, p: IPlayer): Augmentat
if (p.inGang()) { if (p.inGang()) {
const fac = p.getGangFaction(); const fac = p.getGangFaction();
for (const augName in Augmentations) { for (const augName of Object.keys(Augmentations)) {
const aug = Augmentations[augName]; const aug = Augmentations[augName];
if (!isAvailableForSleeve(aug)) { if (!isAvailableForSleeve(aug)) {
continue; continue;

@ -75,14 +75,14 @@ export function prestigeAugmentation(): void {
initForeignServers(Player.getHomeComputer()); initForeignServers(Player.getHomeComputer());
// Gain favor for Companies // Gain favor for Companies
for (const member in Companies) { for (const member of Object.keys(Companies)) {
if (Companies.hasOwnProperty(member)) { if (Companies.hasOwnProperty(member)) {
Companies[member].gainFavor(); Companies[member].gainFavor();
} }
} }
// Gain favor for factions // Gain favor for factions
for (const member in Factions) { for (const member of Object.keys(Factions)) {
if (Factions.hasOwnProperty(member)) { if (Factions.hasOwnProperty(member)) {
Factions[member].gainFavor(); Factions[member].gainFavor();
} }
@ -200,14 +200,14 @@ export function prestigeSourceFile(flume: boolean): void {
homeComp.cpuCores = 1; homeComp.cpuCores = 1;
// Reset favor for Companies // Reset favor for Companies
for (const member in Companies) { for (const member of Object.keys(Companies)) {
if (Companies.hasOwnProperty(member)) { if (Companies.hasOwnProperty(member)) {
Companies[member].favor = 0; Companies[member].favor = 0;
} }
} }
// Reset favor for factions // Reset favor for factions
for (const member in Factions) { for (const member of Object.keys(Factions)) {
if (Factions.hasOwnProperty(member)) { if (Factions.hasOwnProperty(member)) {
Factions[member].favor = 0; Factions[member].favor = 0;
} }
@ -219,7 +219,7 @@ export function prestigeSourceFile(flume: boolean): void {
} }
// Delete all Augmentations // Delete all Augmentations
for (const name in Augmentations) { for (const name of Object.keys(Augmentations)) {
if (Augmentations.hasOwnProperty(name)) { if (Augmentations.hasOwnProperty(name)) {
delete Augmentations[name]; delete Augmentations[name];
} }

@ -6,7 +6,7 @@ import { IPlayer } from "../PersonObjects/IPlayer";
//Returns the programs this player can create. //Returns the programs this player can create.
export function getAvailableCreatePrograms(player: IPlayer): Program[] { export function getAvailableCreatePrograms(player: IPlayer): Program[] {
const programs: Program[] = []; const programs: Program[] = [];
for (const key in Programs) { for (const key of Object.keys(Programs)) {
// Non-creatable program // Non-creatable program
const create = Programs[key].create; const create = Programs[key].create;
if (create == null) continue; if (create == null) continue;

@ -115,7 +115,7 @@ function evaluateVersionCompatibility(ver: string | number): void {
} }
// The "companyName" property of all Companies is renamed to "name" // The "companyName" property of all Companies is renamed to "name"
for (const companyName in Companies) { for (const companyName of Object.keys(Companies)) {
const company: any = Companies[companyName]; const company: any = Companies[companyName];
if (company.name == 0 && company.companyName != null) { if (company.name == 0 && company.companyName != null) {
company.name = company.companyName; company.name = company.companyName;

@ -27,7 +27,7 @@ export function scriptCalculateOfflineProduction(runningScript: RunningScript):
//Data map: [MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken] //Data map: [MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken]
// Grow // Grow
for (const hostname in runningScript.dataMap) { for (const hostname of Object.keys(runningScript.dataMap)) {
if (runningScript.dataMap.hasOwnProperty(hostname)) { if (runningScript.dataMap.hasOwnProperty(hostname)) {
if (runningScript.dataMap[hostname][2] == 0 || runningScript.dataMap[hostname][2] == null) { if (runningScript.dataMap[hostname][2] == 0 || runningScript.dataMap[hostname][2] == null) {
continue; continue;
@ -60,7 +60,7 @@ export function scriptCalculateOfflineProduction(runningScript: RunningScript):
runningScript.offlineExpGained += expGain; runningScript.offlineExpGained += expGain;
// Weaken // Weaken
for (const hostname in runningScript.dataMap) { for (const hostname of Object.keys(runningScript.dataMap)) {
if (runningScript.dataMap.hasOwnProperty(hostname)) { if (runningScript.dataMap.hasOwnProperty(hostname)) {
if (runningScript.dataMap[hostname][3] == 0 || runningScript.dataMap[hostname][3] == null) { if (runningScript.dataMap[hostname][3] == 0 || runningScript.dataMap[hostname][3] == null) {
continue; continue;

@ -20,7 +20,7 @@ import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers";
let AllServers: IMap<Server | HacknetServer> = {}; let AllServers: IMap<Server | HacknetServer> = {};
function GetServerByIP(ip: string): BaseServer | undefined { function GetServerByIP(ip: string): BaseServer | undefined {
for (const key in AllServers) { for (const key of Object.keys(AllServers)) {
const server = AllServers[key]; const server = AllServers[key];
if (server.ip !== ip) continue; if (server.ip !== ip) continue;
return server; return server;
@ -30,7 +30,7 @@ function GetServerByIP(ip: string): BaseServer | undefined {
//Returns server object with corresponding hostname //Returns server object with corresponding hostname
// Relatively slow, would rather not use this a lot // Relatively slow, would rather not use this a lot
function GetServerByHostname(hostname: string): BaseServer | null { function GetServerByHostname(hostname: string): BaseServer | null {
for (const key in AllServers) { for (const key of Object.keys(AllServers)) {
const server = AllServers[key]; const server = AllServers[key];
if (server.hostname == hostname) { if (server.hostname == hostname) {
return server; return server;
@ -58,14 +58,14 @@ export function GetServer(s: string): BaseServer | null {
export function GetAllServers(): BaseServer[] { export function GetAllServers(): BaseServer[] {
const servers: BaseServer[] = []; const servers: BaseServer[] = [];
for (const key in AllServers) { for (const key of Object.keys(AllServers)) {
servers.push(AllServers[key]); servers.push(AllServers[key]);
} }
return servers; return servers;
} }
export function DeleteServer(serverkey: string): void { export function DeleteServer(serverkey: string): void {
for (const key in AllServers) { for (const key of Object.keys(AllServers)) {
const server = AllServers[key]; const server = AllServers[key];
if (server.ip !== serverkey && server.hostname !== serverkey) continue; if (server.ip !== serverkey && server.hostname !== serverkey) continue;
delete AllServers[key]; delete AllServers[key];
@ -194,7 +194,7 @@ export function initForeignServers(homeComputer: Server): void {
} }
export function prestigeAllServers(): void { export function prestigeAllServers(): void {
for (const member in AllServers) { for (const member of Object.keys(AllServers)) {
delete AllServers[member]; delete AllServers[member];
} }
AllServers = {}; AllServers = {};
@ -206,7 +206,7 @@ export function loadAllServers(saveString: string): void {
export function saveAllServers(excludeRunningScripts = false): string { export function saveAllServers(excludeRunningScripts = false): string {
const TempAllServers = JSON.parse(JSON.stringify(AllServers), Reviver); const TempAllServers = JSON.parse(JSON.stringify(AllServers), Reviver);
for (const key in TempAllServers) { for (const key of Object.keys(TempAllServers)) {
const server = TempAllServers[key]; const server = TempAllServers[key];
if (excludeRunningScripts) { if (excludeRunningScripts) {
server.runningScripts = []; server.runningScripts = [];

@ -42,7 +42,7 @@ export function processOrders(
const orderBook = refs.stockMarket["Orders"]; const orderBook = refs.stockMarket["Orders"];
if (orderBook == null) { if (orderBook == null) {
const orders: IOrderBook = {}; const orders: IOrderBook = {};
for (const name in refs.stockMarket) { for (const name of Object.keys(refs.stockMarket)) {
const stock = refs.stockMarket[name]; const stock = refs.stockMarket[name];
if (!(stock instanceof Stock)) { if (!(stock instanceof Stock)) {
continue; continue;

@ -55,7 +55,7 @@ export function placeOrder(
const order = new Order(stock.symbol, shares, price, type, position); const order = new Order(stock.symbol, shares, price, type, position);
if (StockMarket["Orders"] == null) { if (StockMarket["Orders"] == null) {
const orders: IOrderBook = {}; const orders: IOrderBook = {};
for (const name in StockMarket) { for (const name of Object.keys(StockMarket)) {
const stk = StockMarket[name]; const stk = StockMarket[name];
if (!(stk instanceof Stock)) { if (!(stk instanceof Stock)) {
continue; continue;
@ -157,7 +157,7 @@ export function deleteStockMarket(): void {
} }
export function initStockMarket(): void { export function initStockMarket(): void {
for (const stk in StockMarket) { for (const stk of Object.keys(StockMarket)) {
if (StockMarket.hasOwnProperty(stk)) { if (StockMarket.hasOwnProperty(stk)) {
delete StockMarket[stk]; delete StockMarket[stk];
} }
@ -169,7 +169,7 @@ export function initStockMarket(): void {
} }
const orders: IOrderBook = {}; const orders: IOrderBook = {};
for (const name in StockMarket) { for (const name of Object.keys(StockMarket)) {
const stock = StockMarket[name]; const stock = StockMarket[name];
if (!(stock instanceof Stock)) { if (!(stock instanceof Stock)) {
continue; continue;
@ -184,7 +184,7 @@ export function initStockMarket(): void {
} }
export function initSymbolToStockMap(): void { export function initSymbolToStockMap(): void {
for (const name in StockSymbols) { for (const name of Object.keys(StockSymbols)) {
if (StockSymbols.hasOwnProperty(name)) { if (StockSymbols.hasOwnProperty(name)) {
const stock = StockMarket[name]; const stock = StockMarket[name];
if (stock == null) { if (stock == null) {
@ -198,7 +198,7 @@ export function initSymbolToStockMap(): void {
} }
function stockMarketCycle(): void { function stockMarketCycle(): void {
for (const name in StockMarket) { for (const name of Object.keys(StockMarket)) {
const stock = StockMarket[name]; const stock = StockMarket[name];
if (!(stock instanceof Stock)) { if (!(stock instanceof Stock)) {
continue; continue;
@ -247,7 +247,7 @@ export function processStockPrices(numCycles = 1): void {
} }
const v = Math.random(); const v = Math.random();
for (const name in StockMarket) { for (const name of Object.keys(StockMarket)) {
const stock = StockMarket[name]; const stock = StockMarket[name];
if (!(stock instanceof Stock)) { if (!(stock instanceof Stock)) {
continue; continue;

@ -5,7 +5,7 @@ export const TickerHeaderFormatData = {
longestSymbol: 0, longestSymbol: 0,
}; };
for (const key in StockSymbols) { for (const key of Object.keys(StockSymbols)) {
TickerHeaderFormatData.longestName = Math.max(key.length, TickerHeaderFormatData.longestName); TickerHeaderFormatData.longestName = Math.max(key.length, TickerHeaderFormatData.longestName);
TickerHeaderFormatData.longestSymbol = Math.max(StockSymbols[key].length, TickerHeaderFormatData.longestSymbol); TickerHeaderFormatData.longestSymbol = Math.max(StockSymbols[key].length, TickerHeaderFormatData.longestSymbol);
} }

@ -66,7 +66,7 @@ export function StockTickers(props: IProps): React.ReactElement {
} }
const tickers: React.ReactElement[] = []; const tickers: React.ReactElement[] = [];
for (const stockMarketProp in props.stockMarket) { for (const stockMarketProp of Object.keys(props.stockMarket)) {
const val = props.stockMarket[stockMarketProp]; const val = props.stockMarket[stockMarketProp];
if (val instanceof Stock) { if (val instanceof Stock) {
// Skip if there's a filter and the stock isnt in that filter // Skip if there's a filter and the stock isnt in that filter

@ -204,7 +204,7 @@ export async function determineAllPossibilitiesForTabCompletion(
if (isCommand("buy")) { if (isCommand("buy")) {
const options = []; const options = [];
for (const i in DarkWebItems) { for (const i of Object.keys(DarkWebItems)) {
const item = DarkWebItems[i]; const item = DarkWebItems[i];
options.push(item.program); options.push(item.program);
} }

@ -169,7 +169,7 @@ const Engine: {
}, },
decrementAllCounters: function (numCycles = 1) { decrementAllCounters: function (numCycles = 1) {
for (const counterName in Engine.Counters) { for (const counterName of Object.keys(Engine.Counters)) {
const counter = Engine.Counters[counterName]; const counter = Engine.Counters[counterName];
if (counter === undefined) throw new Error("counter should not be undefined"); if (counter === undefined) throw new Error("counter should not be undefined");
Engine.Counters[counterName] = counter - numCycles; Engine.Counters[counterName] = counter - numCycles;