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
+1 -1
View File
@@ -112,7 +112,7 @@ export abstract class Person {
* Updates this object's multipliers for the given augmentation
*/
applyAugmentation(aug: Augmentation): void {
for (const mult in aug.mults) {
for (const mult of Object.keys(aug.mults)) {
if ((this as any)[mult] == null) {
console.warn(`Augmentation has unrecognized multiplier property: ${mult}`);
} else {
@@ -1484,7 +1484,7 @@ export function finishCrime(this: IPlayer, cancelled: boolean): string {
if (determineCrimeSuccess(this, this.crimeType)) {
//Handle Karma and crime statistics
let crime = null;
for (const i in Crimes) {
for (const i of Object.keys(Crimes)) {
if (Crimes[i].type == this.crimeType) {
crime = Crimes[i];
break;
@@ -2556,15 +2556,15 @@ export function setBitNodeNumber(this: IPlayer, n: number): void {
}
export function queueAugmentation(this: IPlayer, name: string): void {
for (const i in this.queuedAugmentations) {
if (this.queuedAugmentations[i].name == name) {
for (const aug of this.queuedAugmentations) {
if (aug.name == name) {
console.warn(`tried to queue ${name} twice, this may be a bug`);
return;
}
}
for (const i in this.augmentations) {
if (this.augmentations[i].name == name) {
for (const aug of this.augmentations) {
if (aug.name == name) {
console.warn(`tried to queue ${name} twice, this may be a bug`);
return;
}
+1 -1
View File
@@ -37,7 +37,7 @@ export function purchaseResleeve(r: Resleeve, p: IPlayer): boolean {
p.charisma_exp = r.charisma_exp;
// Reset Augmentation "owned" data
for (const augKey in Augmentations) {
for (const augKey of Object.keys(Augmentations)) {
Augmentations[augKey].owned = false;
}
+1 -1
View File
@@ -42,7 +42,7 @@ export function findSleevePurchasableAugs(sleeve: Sleeve, p: IPlayer): Augmentat
if (p.inGang()) {
const fac = p.getGangFaction();
for (const augName in Augmentations) {
for (const augName of Object.keys(Augmentations)) {
const aug = Augmentations[augName];
if (!isAvailableForSleeve(aug)) {
continue;