Skip to content

Commit 8ea57f6

Browse files
committed
CODEBASE: Convert internal enums to const objects 1
1 parent 150c14d commit 8ea57f6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+313
-289
lines changed

src/Achievements/Achievements.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
22
AugmentationName,
33
BladeburnerSkillName,
4-
CityName,
4+
CityNameEnum,
55
CompletedProgramName,
66
CorpUnlockName,
77
FactionName,
@@ -304,7 +304,7 @@ export const achievements: Record<string, Achievement> = {
304304
TRAVEL: {
305305
...achievementData.TRAVEL,
306306
Icon: "TRAVEL",
307-
Condition: () => Player.city !== CityName.Sector12,
307+
Condition: () => Player.city !== CityNameEnum.Sector12,
308308
},
309309
WORKOUT: {
310310
...achievementData.WORKOUT,

src/BitNode/BitNode.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from "react";
22
import { Player } from "@player";
3-
import { CityName, FactionName } from "@enums";
3+
import { CityNameEnum, FactionName } from "@enums";
44
import { BitNodeMultipliers, replaceCurrentNodeMults } from "./BitNodeMultipliers";
55

66
class BitNode {
@@ -406,7 +406,7 @@ export function initBitNodes() {
406406
<br />
407407
<br />
408408
Their leader, Allison "Mother" Stanek is said to have created her own augmentation whose power goes beyond any
409-
other. Find her in {CityName.Chongqing} and gain her trust.
409+
other. Find her in {CityNameEnum.Chongqing} and gain her trust.
410410
<br />
411411
<br />
412412
Destroying this BitNode will give you Source-File 13, or if you already have this Source-File, it will upgrade

src/Bladeburner/Bladeburner.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ import {
1212
BladeburnerMultName,
1313
BladeburnerOperationName,
1414
BladeburnerSkillName,
15-
CityName,
15+
CityNameEnum,
1616
FactionName,
1717
} from "@enums";
18+
import type { CityName } from "@nsdefs";
1819
import { getKeyList } from "../utils/helpers/getKeyList";
1920
import { constructorsForReviver, Generic_toJSON, Generic_fromJSON, IReviverValue } from "../utils/JSONReviver";
2021
import { formatHp, formatNumberNoSuffix, formatSleeveShock } from "../ui/formatNumber";
@@ -83,8 +84,8 @@ export class Bladeburner implements OperationTeam {
8384

8485
action: ActionIdentifier | null = null;
8586

86-
cities = createEnumKeyedRecord(CityName, (name) => new City(name));
87-
city = CityName.Sector12;
87+
cities = createEnumKeyedRecord(CityNameEnum, (name) => new City(name));
88+
city: CityName = CityNameEnum.Sector12;
8889
// Todo: better types for all these Record<string, etc> types. Will need custom types or enums for the named string categories (e.g. skills).
8990
skills: PartialRecord<BladeburnerSkillName, number> = {};
9091
skillMultipliers: PartialRecord<BladeburnerMultName, number> = {};
@@ -524,7 +525,7 @@ export class Bladeburner implements OperationTeam {
524525
}
525526

526527
triggerMigration(sourceCityName: CityName): void {
527-
const cityHelper = getEnumHelper("CityName");
528+
const cityHelper = getEnumHelper("CityNameEnum");
528529
let destCityName = cityHelper.random();
529530
while (destCityName === sourceCityName) destCityName = cityHelper.random();
530531

@@ -562,7 +563,7 @@ export class Bladeburner implements OperationTeam {
562563

563564
randomEvent(): void {
564565
const chance = Math.random();
565-
const cityHelper = getEnumHelper("CityName");
566+
const cityHelper = getEnumHelper("CityNameEnum");
566567

567568
// Choose random source/destination city for events
568569
const sourceCityName = cityHelper.random();
@@ -1186,7 +1187,7 @@ export class Bladeburner implements OperationTeam {
11861187
if (this.logging.general) {
11871188
this.log(`${person.whoAmI()}: Incited violence in the synthoid communities.`);
11881189
}
1189-
for (const cityName of Object.values(CityName)) {
1190+
for (const cityName of Object.values(CityNameEnum)) {
11901191
const city = this.cities[cityName];
11911192
city.changeChaosByCount(10);
11921193
city.changeChaosByCount(city.chaos / Math.log10(city.chaos));
@@ -1351,7 +1352,7 @@ export class Bladeburner implements OperationTeam {
13511352
}
13521353

13531354
// Chaos goes down very slowly
1354-
for (const cityName of Object.values(CityName)) {
1355+
for (const cityName of Object.values(CityNameEnum)) {
13551356
const city = this.cities[cityName];
13561357
if (!city) throw new Error("Invalid city when processing passive chaos reduction in Bladeburner.process");
13571358
city.chaos -= 0.0001 * seconds;

src/Bladeburner/City.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { CityName } from "@enums";
1+
import { CityNameEnum } from "@enums";
2+
import type { CityName } from "@nsdefs";
23
import { BladeburnerConstants } from "./data/Constants";
34
import { getRandomIntInclusive } from "../utils/helpers/getRandomIntInclusive";
45
import { Generic_fromJSON, Generic_toJSON, IReviverValue, constructorsForReviver } from "../utils/JSONReviver";
@@ -12,7 +13,7 @@ export class City {
1213
comms = 0; // Number of communities
1314
chaos = 0;
1415

15-
constructor(name = CityName.Sector12) {
16+
constructor(name: CityName = CityNameEnum.Sector12) {
1617
this.name = name;
1718

1819
// Synthoid population and estimate

src/Bladeburner/data/BlackOperations.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { BlackOperation } from "../Actions/BlackOperation";
2-
import { BladeburnerBlackOpName, CityName, FactionName } from "@enums";
2+
import { BladeburnerBlackOpName, CityNameEnum, FactionName } from "@enums";
33

44
export const BlackOperations: Record<BladeburnerBlackOpName, BlackOperation> = {
55
[BladeburnerBlackOpName.OperationTyphoon]: new BlackOperation({
@@ -103,7 +103,7 @@ export const BlackOperations: Record<BladeburnerBlackOpName, BlackOperation> = {
103103
"their works discuss Synthoids and pose a threat to society. The publications are spreading rapidly in China and " +
104104
"other Eastern countries.\n\n" +
105105
"Samizdat has done a good job of keeping hidden and anonymous. However, we've just received intelligence that " +
106-
`their base of operations is in ${CityName.Ishima}'s underground sewer systems. Your task is to investigate the ` +
106+
`their base of operations is in ${CityNameEnum.Ishima}'s underground sewer systems. Your task is to investigate the ` +
107107
"sewer systems, and eliminate Samizdat. They must never publish anything again.",
108108
}),
109109
[BladeburnerBlackOpName.OperationTitan]: new BlackOperation({
@@ -138,7 +138,7 @@ export const BlackOperations: Record<BladeburnerBlackOpName, BlackOperation> = {
138138
"know, Titan Laboratories' management has no knowledge about this. We don't know what the Synthoids are up to, " +
139139
"but the research that they could be conducting using Titan Laboratories' vast resources is potentially very " +
140140
"dangerous.\n\n" +
141-
`Your goal is to enter and destroy the Bioengineering department's facility in ${CityName.Aevum}. The task is not ` +
141+
`Your goal is to enter and destroy the Bioengineering department's facility in ${CityNameEnum.Aevum}. The task is not ` +
142142
"just to retire the Synthoids there, but also to destroy any information or research at the facility that is " +
143143
"relevant to the Synthoids and their goals.",
144144
}),
@@ -239,7 +239,7 @@ export const BlackOperations: Record<BladeburnerBlackOpName, BlackOperation> = {
239239
desc:
240240
"The CIA has just encountered a new security threat. A new criminal group, lead by a shadowy operative who calls " +
241241
"himself Juggernaut, has been smuggling drugs and weapons (including suspected bioweapons) into " +
242-
`${CityName.Sector12}. We also have reason to believe they tried to break into one of Universal Energy's ` +
242+
`${CityNameEnum.Sector12}. We also have reason to believe they tried to break into one of Universal Energy's ` +
243243
"facilities in order to cause a city-wide blackout. The CIA suspects that Juggernaut is a heavily-augmented " +
244244
"Synthoid, and have thus enlisted our help.\n\n" +
245245
"Your mission is to eradicate Juggernaut and his followers.",
@@ -378,7 +378,7 @@ export const BlackOperations: Record<BladeburnerBlackOpName, BlackOperation> = {
378378
},
379379
isKill: true,
380380
desc:
381-
`A week ago ${FactionName.BladeIndustries} reported a small break-in at one of their ${CityName.Aevum} ` +
381+
`A week ago ${FactionName.BladeIndustries} reported a small break-in at one of their ${CityNameEnum.Aevum} ` +
382382
`Augmentation storage facilities. We figured out that ${FactionName.TheDarkArmy} was behind the heist, and didn't think ` +
383383
"any more of it. However, we've just discovered that several known MK-VI Synthoids were part of that break-in group.\n\n" +
384384
"We cannot have Synthoids upgrading their already-enhanced abilities with Augmentations. Your task is to hunt " +
@@ -416,11 +416,11 @@ export const BlackOperations: Record<BladeburnerBlackOpName, BlackOperation> = {
416416
`${FactionName.TheDarkArmy} was well aware that there were Synthoids amongst their ranks. Even worse, we believe ` +
417417
`that ${FactionName.TheDarkArmy} is working together with other criminal organizations such as ` +
418418
`${FactionName.TheSyndicate} and that they are planning some sort of large-scale takeover of multiple major ` +
419-
`cities, most notably ${CityName.Aevum}. We suspect that Synthoids have infiltrated the ranks of these criminal ` +
419+
`cities, most notably ${CityNameEnum.Aevum}. We suspect that Synthoids have infiltrated the ranks of these criminal ` +
420420
"factions and are trying to stage another Synthoid uprising.\n\n" +
421421
"The best way to deal with this is to prevent it before it even happens. The goal of " +
422422
`${BladeburnerBlackOpName.OperationWallace} is to destroy ${FactionName.TheDarkArmy} and ${FactionName.TheSyndicate} factions in ` +
423-
`${CityName.Aevum} immediately. Leave no survivors.`,
423+
`${CityNameEnum.Aevum} immediately. Leave no survivors.`,
424424
}),
425425
[BladeburnerBlackOpName.OperationShoulderOfOrion]: new BlackOperation({
426426
name: BladeburnerBlackOpName.OperationShoulderOfOrion,
@@ -490,7 +490,7 @@ export const BlackOperations: Record<BladeburnerBlackOpName, BlackOperation> = {
490490
"organic human brains means that the supercomputer may be able to reason abstractly and become self-aware.\n\n" +
491491
"I do not need to remind you why sentient-level AIs pose a serious threat to all of mankind.\n\n" +
492492
`The research for this project is being conducted at one of ${FactionName.FulcrumSecretTechnologies} secret ` +
493-
`facilities in ${CityName.Aevum}, codenamed 'Alpha Ranch'. Infiltrate the compound, delete and destroy the work, ` +
493+
`facilities in ${CityNameEnum.Aevum}, codenamed 'Alpha Ranch'. Infiltrate the compound, delete and destroy the work, ` +
494494
"and then find and kill the project lead.",
495495
}),
496496
[BladeburnerBlackOpName.OperationMorpheus]: new BlackOperation({
@@ -523,7 +523,7 @@ export const BlackOperations: Record<BladeburnerBlackOpName, BlackOperation> = {
523523
desc:
524524
"DreamSense Technologies is an advertising company that uses special technology to transmit their ads into the " +
525525
"people's dreams and subconscious. They do this using broadcast transmitter towers. Based on information from our " +
526-
`agents and informants in ${CityName.Chongqing}, we have reason to believe that one of the broadcast towers there ` +
526+
`agents and informants in ${CityNameEnum.Chongqing}, we have reason to believe that one of the broadcast towers there ` +
527527
"has been compromised by Synthoids and is being used to spread pro-Synthoid propaganda.\n\n" +
528528
"The mission is to destroy this broadcast tower. Speed and stealth are of the utmost importance for this.",
529529
}),
@@ -556,9 +556,9 @@ export const BlackOperations: Record<BladeburnerBlackOpName, BlackOperation> = {
556556
isKill: true,
557557
desc:
558558
"Our analysts have uncovered a gathering of MK-VI Synthoids that have taken up residence in the " +
559-
`${CityName.Sector12} Slums. We don't know if they are rogue Synthoids from the Uprising, but we do know that they ` +
559+
`${CityNameEnum.Sector12} Slums. We don't know if they are rogue Synthoids from the Uprising, but we do know that they ` +
560560
"have been stockpiling weapons, money, and other resources. This makes them dangerous.\n\n" +
561-
`This is a full-scale assault operation to find and retire all of these Synthoids in the ${CityName.Sector12} ` +
561+
`This is a full-scale assault operation to find and retire all of these Synthoids in the ${CityNameEnum.Sector12} ` +
562562
"Slums.",
563563
}),
564564
[BladeburnerBlackOpName.OperationAnnihilus]: new BlackOperation({
@@ -590,7 +590,7 @@ export const BlackOperations: Record<BladeburnerBlackOpName, BlackOperation> = {
590590
isKill: true,
591591
desc:
592592
"Our superiors have ordered us to eradicate everything and everyone in an underground facility located in " +
593-
`${CityName.Aevum}. They tell us that the facility houses many dangerous Synthoids and belongs to a terrorist ` +
593+
`${CityNameEnum.Aevum}. They tell us that the facility houses many dangerous Synthoids and belongs to a terrorist ` +
594594
`organization called '${FactionName.TheCovenant}'. We have no prior intelligence about this organization, so you ` +
595595
"are going in blind.",
596596
}),
@@ -628,7 +628,7 @@ export const BlackOperations: Record<BladeburnerBlackOpName, BlackOperation> = {
628628
"ones from the Uprising.\n\n" +
629629
`${FactionName.OmniTekIncorporated} has also told us they believe someone has triggered this malfunction in a ` +
630630
"large group of MK-VI Synthoids, and that these newly-radicalized Synthoids are now amassing in " +
631-
`${CityName.Volhaven} to form a terrorist group called Ultron.\n\n` +
631+
`${CityNameEnum.Volhaven} to form a terrorist group called Ultron.\n\n` +
632632
"Intelligence suggests Ultron is heavily armed and that their members are augmented. We believe Ultron is making " +
633633
"moves to take control of and weaponize DeltaOne's Tactical High-Energy Satellite Laser Array (THESLA).\n\n" +
634634
"Your task is to find and destroy Ultron.",

src/Bladeburner/ui/TravelModal.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import type { Bladeburner } from "../Bladeburner";
22

33
import React from "react";
44
import { Button, Typography } from "@mui/material";
5-
import { CityName } from "@enums";
5+
import { CityNameEnum } from "@enums";
6+
import type { CityName } from "@nsdefs";
67
import { WorldMap } from "../../ui/React/WorldMap";
78
import { Modal } from "../../ui/React/Modal";
89
import { Settings } from "../../Settings/Settings";
@@ -27,7 +28,7 @@ export function TravelModal({ bladeburner, open, onClose }: TravelModalProps): R
2728
for your Bladeburner duties does not affect your location in the game otherwise.
2829
</Typography>
2930
{Settings.DisableASCIIArt ? (
30-
Object.values(CityName).map((city) => (
31+
Object.values(CityNameEnum).map((city) => (
3132
<Button key={city} onClick={() => travel(city)}>
3233
{city}
3334
</Button>

src/Corporation/Actions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Player } from "@player";
2-
import { CorpResearchName, CorpSmartSupplyOption } from "@nsdefs";
2+
import { CityName, CorpResearchName, CorpSmartSupplyOption } from "@nsdefs";
33

44
import { MaterialInfo } from "./MaterialInfo";
55
import { Corporation } from "./Corporation";
@@ -13,7 +13,7 @@ import { Warehouse } from "./Warehouse";
1313
import { CreatingCorporationCheckResult, FactionName, IndustryType } from "@enums";
1414
import { ResearchMap } from "./ResearchMap";
1515
import { isRelevantMaterial } from "./ui/Helpers";
16-
import { CityName } from "@enums";
16+
import { CityNameEnum } from "@enums";
1717
import { getRandomIntInclusive } from "../utils/helpers/getRandomIntInclusive";
1818
import { getRecordValues } from "../Types/Record";
1919
import {
@@ -299,7 +299,7 @@ export function sellProduct(product: Product, city: CityName, amt: string, price
299299
const convertedAmount = convertAmountString(amt.toUpperCase());
300300

301301
if (all) {
302-
for (const cityName of Object.values(CityName)) {
302+
for (const cityName of Object.values(CityNameEnum)) {
303303
product.cityData[cityName].desiredSellAmount = convertedAmount;
304304
product.cityData[cityName].desiredSellPrice = convertedPrice;
305305
}

src/Corporation/Division.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { CorpMaterialName, CorpResearchName, CorpStateName } from "@nsdefs";
2-
import { CityName, CorpEmployeeJob, IndustryType } from "@enums";
1+
import { CityName, CorpMaterialName, CorpResearchName, CorpStateName } from "@nsdefs";
2+
import { CityNameEnum, CorpEmployeeJob, IndustryType } from "@enums";
33
import { constructorsForReviver, Generic_toJSON, Generic_fromJSON, IReviverValue } from "../utils/JSONReviver";
44
import { IndustryResearchTrees, IndustriesData } from "./data/IndustryData";
55
import * as corpConstants from "./data/Constants";
@@ -89,13 +89,13 @@ export class Division {
8989
this.type = params.type;
9090
this.name = params.name;
9191
// Add default starting
92-
this.warehouses[CityName.Sector12] = new Warehouse({
93-
loc: CityName.Sector12,
92+
this.warehouses[CityNameEnum.Sector12] = new Warehouse({
93+
loc: CityNameEnum.Sector12,
9494
division: this,
9595
size: corpConstants.warehouseInitialSize,
9696
});
97-
this.offices[CityName.Sector12] = new OfficeSpace({
98-
city: CityName.Sector12,
97+
this.offices[CityNameEnum.Sector12] = new OfficeSpace({
98+
city: CityNameEnum.Sector12,
9999
size: corpConstants.officeInitialSize,
100100
});
101101

@@ -138,7 +138,7 @@ export class Division {
138138
calculateRecoupableValue(): number {
139139
let price = this.startingCost;
140140
for (const city of getRecordKeys(this.offices)) {
141-
if (city === CityName.Sector12) continue;
141+
if (city === CityNameEnum.Sector12) continue;
142142
price += corpConstants.officeInitialCost;
143143
if (this.warehouses[city]) price += corpConstants.warehouseInitialCost;
144144
}
@@ -180,7 +180,7 @@ export class Division {
180180

181181
// Process offices (and the employees in them)
182182
let employeeSalary = 0;
183-
for (const officeLoc of Object.values(CityName)) {
183+
for (const officeLoc of Object.values(CityNameEnum)) {
184184
const office = this.offices[officeLoc];
185185
if (office) employeeSalary += office.process(marketCycles, corporation, this);
186186
}
@@ -230,7 +230,7 @@ export class Division {
230230
prodMats = this.producedMaterials;
231231

232232
//Only 'process the market' for materials that this industry deals with
233-
for (const city of Object.values(CityName)) {
233+
for (const city of Object.values(CityNameEnum)) {
234234
//If this industry has a warehouse in this city, process the market
235235
//for every material this industry requires or produces
236236
if (this.warehouses[city]) {

src/Corporation/Export.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { CityName } from "@enums";
1+
import type { CityName } from "@nsdefs";
22

33
export interface Export {
44
division: string;

src/Corporation/OfficeSpace.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { CityName, CorpEmployeeJob } from "@enums";
1+
import { CityNameEnum, CorpEmployeeJob } from "@enums";
2+
import type { CityName } from "@nsdefs";
23
import * as corpConstants from "./data/Constants";
34
import { Generic_fromJSON, Generic_toJSON, IReviverValue, constructorsForReviver } from "../utils/JSONReviver";
45
import { Division } from "./Division";
@@ -13,7 +14,7 @@ interface IParams {
1314
}
1415

1516
export class OfficeSpace {
16-
city = CityName.Sector12;
17+
city: CityName = CityNameEnum.Sector12;
1718
size = 1;
1819

1920
maxEnergy = 100;

0 commit comments

Comments
 (0)