Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CODEBASE: Convert internal enums to const objects 1 #2001

Draft
wants to merge 5 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Achievements/Achievements.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
AugmentationName,
BladeburnerSkillName,
CityName,
CityNameEnum,
CompletedProgramName,
CorpUnlockName,
FactionName,
Expand Down Expand Up @@ -304,7 +304,7 @@ export const achievements: Record<string, Achievement> = {
TRAVEL: {
...achievementData.TRAVEL,
Icon: "TRAVEL",
Condition: () => Player.city !== CityName.Sector12,
Condition: () => Player.city !== CityNameEnum.Sector12,
},
WORKOUT: {
...achievementData.WORKOUT,
Expand Down
4 changes: 2 additions & 2 deletions src/BitNode/BitNode.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { Player } from "@player";
import { CityName, FactionName } from "@enums";
import { CityNameEnum, FactionName } from "@enums";
import { BitNodeMultipliers, replaceCurrentNodeMults } from "./BitNodeMultipliers";

class BitNode {
Expand Down Expand Up @@ -406,7 +406,7 @@ export function initBitNodes() {
<br />
<br />
Their leader, Allison "Mother" Stanek is said to have created her own augmentation whose power goes beyond any
other. Find her in {CityName.Chongqing} and gain her trust.
other. Find her in {CityNameEnum.Chongqing} and gain her trust.
<br />
<br />
Destroying this BitNode will give you Source-File 13, or if you already have this Source-File, it will upgrade
Expand Down
15 changes: 8 additions & 7 deletions src/Bladeburner/Bladeburner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import {
BladeburnerMultName,
BladeburnerOperationName,
BladeburnerSkillName,
CityName,
CityNameEnum,
FactionName,
} from "@enums";
import type { CityName } from "@nsdefs";
import { getKeyList } from "../utils/helpers/getKeyList";
import { constructorsForReviver, Generic_toJSON, Generic_fromJSON, IReviverValue } from "../utils/JSONReviver";
import { formatHp, formatNumberNoSuffix, formatSleeveShock } from "../ui/formatNumber";
Expand Down Expand Up @@ -83,8 +84,8 @@ export class Bladeburner implements OperationTeam {

action: ActionIdentifier | null = null;

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

triggerMigration(sourceCityName: CityName): void {
const cityHelper = getEnumHelper("CityName");
const cityHelper = getEnumHelper("CityNameEnum");
let destCityName = cityHelper.random();
while (destCityName === sourceCityName) destCityName = cityHelper.random();

Expand Down Expand Up @@ -562,7 +563,7 @@ export class Bladeburner implements OperationTeam {

randomEvent(): void {
const chance = Math.random();
const cityHelper = getEnumHelper("CityName");
const cityHelper = getEnumHelper("CityNameEnum");

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

// Chaos goes down very slowly
for (const cityName of Object.values(CityName)) {
for (const cityName of Object.values(CityNameEnum)) {
const city = this.cities[cityName];
if (!city) throw new Error("Invalid city when processing passive chaos reduction in Bladeburner.process");
city.chaos -= 0.0001 * seconds;
Expand Down
5 changes: 3 additions & 2 deletions src/Bladeburner/City.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CityName } from "@enums";
import { CityNameEnum } from "@enums";
import type { CityName } from "@nsdefs";
import { BladeburnerConstants } from "./data/Constants";
import { getRandomIntInclusive } from "../utils/helpers/getRandomIntInclusive";
import { Generic_fromJSON, Generic_toJSON, IReviverValue, constructorsForReviver } from "../utils/JSONReviver";
Expand All @@ -12,7 +13,7 @@ export class City {
comms = 0; // Number of communities
chaos = 0;

constructor(name = CityName.Sector12) {
constructor(name: CityName = CityNameEnum.Sector12) {
this.name = name;

// Synthoid population and estimate
Expand Down
26 changes: 13 additions & 13 deletions src/Bladeburner/data/BlackOperations.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BlackOperation } from "../Actions/BlackOperation";
import { BladeburnerBlackOpName, CityName, FactionName } from "@enums";
import { BladeburnerBlackOpName, CityNameEnum, FactionName } from "@enums";

export const BlackOperations: Record<BladeburnerBlackOpName, BlackOperation> = {
[BladeburnerBlackOpName.OperationTyphoon]: new BlackOperation({
Expand Down Expand Up @@ -103,7 +103,7 @@ export const BlackOperations: Record<BladeburnerBlackOpName, BlackOperation> = {
"their works discuss Synthoids and pose a threat to society. The publications are spreading rapidly in China and " +
"other Eastern countries.\n\n" +
"Samizdat has done a good job of keeping hidden and anonymous. However, we've just received intelligence that " +
`their base of operations is in ${CityName.Ishima}'s underground sewer systems. Your task is to investigate the ` +
`their base of operations is in ${CityNameEnum.Ishima}'s underground sewer systems. Your task is to investigate the ` +
"sewer systems, and eliminate Samizdat. They must never publish anything again.",
}),
[BladeburnerBlackOpName.OperationTitan]: new BlackOperation({
Expand Down Expand Up @@ -138,7 +138,7 @@ export const BlackOperations: Record<BladeburnerBlackOpName, BlackOperation> = {
"know, Titan Laboratories' management has no knowledge about this. We don't know what the Synthoids are up to, " +
"but the research that they could be conducting using Titan Laboratories' vast resources is potentially very " +
"dangerous.\n\n" +
`Your goal is to enter and destroy the Bioengineering department's facility in ${CityName.Aevum}. The task is not ` +
`Your goal is to enter and destroy the Bioengineering department's facility in ${CityNameEnum.Aevum}. The task is not ` +
"just to retire the Synthoids there, but also to destroy any information or research at the facility that is " +
"relevant to the Synthoids and their goals.",
}),
Expand Down Expand Up @@ -239,7 +239,7 @@ export const BlackOperations: Record<BladeburnerBlackOpName, BlackOperation> = {
desc:
"The CIA has just encountered a new security threat. A new criminal group, lead by a shadowy operative who calls " +
"himself Juggernaut, has been smuggling drugs and weapons (including suspected bioweapons) into " +
`${CityName.Sector12}. We also have reason to believe they tried to break into one of Universal Energy's ` +
`${CityNameEnum.Sector12}. We also have reason to believe they tried to break into one of Universal Energy's ` +
"facilities in order to cause a city-wide blackout. The CIA suspects that Juggernaut is a heavily-augmented " +
"Synthoid, and have thus enlisted our help.\n\n" +
"Your mission is to eradicate Juggernaut and his followers.",
Expand Down Expand Up @@ -378,7 +378,7 @@ export const BlackOperations: Record<BladeburnerBlackOpName, BlackOperation> = {
},
isKill: true,
desc:
`A week ago ${FactionName.BladeIndustries} reported a small break-in at one of their ${CityName.Aevum} ` +
`A week ago ${FactionName.BladeIndustries} reported a small break-in at one of their ${CityNameEnum.Aevum} ` +
`Augmentation storage facilities. We figured out that ${FactionName.TheDarkArmy} was behind the heist, and didn't think ` +
"any more of it. However, we've just discovered that several known MK-VI Synthoids were part of that break-in group.\n\n" +
"We cannot have Synthoids upgrading their already-enhanced abilities with Augmentations. Your task is to hunt " +
Expand Down Expand Up @@ -416,11 +416,11 @@ export const BlackOperations: Record<BladeburnerBlackOpName, BlackOperation> = {
`${FactionName.TheDarkArmy} was well aware that there were Synthoids amongst their ranks. Even worse, we believe ` +
`that ${FactionName.TheDarkArmy} is working together with other criminal organizations such as ` +
`${FactionName.TheSyndicate} and that they are planning some sort of large-scale takeover of multiple major ` +
`cities, most notably ${CityName.Aevum}. We suspect that Synthoids have infiltrated the ranks of these criminal ` +
`cities, most notably ${CityNameEnum.Aevum}. We suspect that Synthoids have infiltrated the ranks of these criminal ` +
"factions and are trying to stage another Synthoid uprising.\n\n" +
"The best way to deal with this is to prevent it before it even happens. The goal of " +
`${BladeburnerBlackOpName.OperationWallace} is to destroy ${FactionName.TheDarkArmy} and ${FactionName.TheSyndicate} factions in ` +
`${CityName.Aevum} immediately. Leave no survivors.`,
`${CityNameEnum.Aevum} immediately. Leave no survivors.`,
}),
[BladeburnerBlackOpName.OperationShoulderOfOrion]: new BlackOperation({
name: BladeburnerBlackOpName.OperationShoulderOfOrion,
Expand Down Expand Up @@ -490,7 +490,7 @@ export const BlackOperations: Record<BladeburnerBlackOpName, BlackOperation> = {
"organic human brains means that the supercomputer may be able to reason abstractly and become self-aware.\n\n" +
"I do not need to remind you why sentient-level AIs pose a serious threat to all of mankind.\n\n" +
`The research for this project is being conducted at one of ${FactionName.FulcrumSecretTechnologies} secret ` +
`facilities in ${CityName.Aevum}, codenamed 'Alpha Ranch'. Infiltrate the compound, delete and destroy the work, ` +
`facilities in ${CityNameEnum.Aevum}, codenamed 'Alpha Ranch'. Infiltrate the compound, delete and destroy the work, ` +
"and then find and kill the project lead.",
}),
[BladeburnerBlackOpName.OperationMorpheus]: new BlackOperation({
Expand Down Expand Up @@ -523,7 +523,7 @@ export const BlackOperations: Record<BladeburnerBlackOpName, BlackOperation> = {
desc:
"DreamSense Technologies is an advertising company that uses special technology to transmit their ads into the " +
"people's dreams and subconscious. They do this using broadcast transmitter towers. Based on information from our " +
`agents and informants in ${CityName.Chongqing}, we have reason to believe that one of the broadcast towers there ` +
`agents and informants in ${CityNameEnum.Chongqing}, we have reason to believe that one of the broadcast towers there ` +
"has been compromised by Synthoids and is being used to spread pro-Synthoid propaganda.\n\n" +
"The mission is to destroy this broadcast tower. Speed and stealth are of the utmost importance for this.",
}),
Expand Down Expand Up @@ -556,9 +556,9 @@ export const BlackOperations: Record<BladeburnerBlackOpName, BlackOperation> = {
isKill: true,
desc:
"Our analysts have uncovered a gathering of MK-VI Synthoids that have taken up residence in the " +
`${CityName.Sector12} Slums. We don't know if they are rogue Synthoids from the Uprising, but we do know that they ` +
`${CityNameEnum.Sector12} Slums. We don't know if they are rogue Synthoids from the Uprising, but we do know that they ` +
"have been stockpiling weapons, money, and other resources. This makes them dangerous.\n\n" +
`This is a full-scale assault operation to find and retire all of these Synthoids in the ${CityName.Sector12} ` +
`This is a full-scale assault operation to find and retire all of these Synthoids in the ${CityNameEnum.Sector12} ` +
"Slums.",
}),
[BladeburnerBlackOpName.OperationAnnihilus]: new BlackOperation({
Expand Down Expand Up @@ -590,7 +590,7 @@ export const BlackOperations: Record<BladeburnerBlackOpName, BlackOperation> = {
isKill: true,
desc:
"Our superiors have ordered us to eradicate everything and everyone in an underground facility located in " +
`${CityName.Aevum}. They tell us that the facility houses many dangerous Synthoids and belongs to a terrorist ` +
`${CityNameEnum.Aevum}. They tell us that the facility houses many dangerous Synthoids and belongs to a terrorist ` +
`organization called '${FactionName.TheCovenant}'. We have no prior intelligence about this organization, so you ` +
"are going in blind.",
}),
Expand Down Expand Up @@ -628,7 +628,7 @@ export const BlackOperations: Record<BladeburnerBlackOpName, BlackOperation> = {
"ones from the Uprising.\n\n" +
`${FactionName.OmniTekIncorporated} has also told us they believe someone has triggered this malfunction in a ` +
"large group of MK-VI Synthoids, and that these newly-radicalized Synthoids are now amassing in " +
`${CityName.Volhaven} to form a terrorist group called Ultron.\n\n` +
`${CityNameEnum.Volhaven} to form a terrorist group called Ultron.\n\n` +
"Intelligence suggests Ultron is heavily armed and that their members are augmented. We believe Ultron is making " +
"moves to take control of and weaponize DeltaOne's Tactical High-Energy Satellite Laser Array (THESLA).\n\n" +
"Your task is to find and destroy Ultron.",
Expand Down
5 changes: 3 additions & 2 deletions src/Bladeburner/ui/TravelModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import type { Bladeburner } from "../Bladeburner";

import React from "react";
import { Button, Typography } from "@mui/material";
import { CityName } from "@enums";
import { CityNameEnum } from "@enums";
import type { CityName } from "@nsdefs";
import { WorldMap } from "../../ui/React/WorldMap";
import { Modal } from "../../ui/React/Modal";
import { Settings } from "../../Settings/Settings";
Expand All @@ -27,7 +28,7 @@ export function TravelModal({ bladeburner, open, onClose }: TravelModalProps): R
for your Bladeburner duties does not affect your location in the game otherwise.
</Typography>
{Settings.DisableASCIIArt ? (
Object.values(CityName).map((city) => (
Object.values(CityNameEnum).map((city) => (
<Button key={city} onClick={() => travel(city)}>
{city}
</Button>
Expand Down
6 changes: 3 additions & 3 deletions src/Corporation/Actions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Player } from "@player";
import { CorpResearchName, CorpSmartSupplyOption } from "@nsdefs";
import { CityName, CorpResearchName, CorpSmartSupplyOption } from "@nsdefs";

import { MaterialInfo } from "./MaterialInfo";
import { Corporation } from "./Corporation";
Expand All @@ -13,7 +13,7 @@ import { Warehouse } from "./Warehouse";
import { CreatingCorporationCheckResult, FactionName, IndustryType } from "@enums";
import { ResearchMap } from "./ResearchMap";
import { isRelevantMaterial } from "./ui/Helpers";
import { CityName } from "@enums";
import { CityNameEnum } from "@enums";
import { getRandomIntInclusive } from "../utils/helpers/getRandomIntInclusive";
import { getRecordValues } from "../Types/Record";
import {
Expand Down Expand Up @@ -299,7 +299,7 @@ export function sellProduct(product: Product, city: CityName, amt: string, price
const convertedAmount = convertAmountString(amt.toUpperCase());

if (all) {
for (const cityName of Object.values(CityName)) {
for (const cityName of Object.values(CityNameEnum)) {
product.cityData[cityName].desiredSellAmount = convertedAmount;
product.cityData[cityName].desiredSellPrice = convertedPrice;
}
Expand Down
18 changes: 9 additions & 9 deletions src/Corporation/Division.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CorpMaterialName, CorpResearchName, CorpStateName } from "@nsdefs";
import { CityName, CorpEmployeeJob, IndustryType } from "@enums";
import { CityName, CorpMaterialName, CorpResearchName, CorpStateName } from "@nsdefs";
import { CityNameEnum, CorpEmployeeJob, IndustryType } from "@enums";
import { constructorsForReviver, Generic_toJSON, Generic_fromJSON, IReviverValue } from "../utils/JSONReviver";
import { IndustryResearchTrees, IndustriesData } from "./data/IndustryData";
import * as corpConstants from "./data/Constants";
Expand Down Expand Up @@ -89,13 +89,13 @@ export class Division {
this.type = params.type;
this.name = params.name;
// Add default starting
this.warehouses[CityName.Sector12] = new Warehouse({
loc: CityName.Sector12,
this.warehouses[CityNameEnum.Sector12] = new Warehouse({
loc: CityNameEnum.Sector12,
division: this,
size: corpConstants.warehouseInitialSize,
});
this.offices[CityName.Sector12] = new OfficeSpace({
city: CityName.Sector12,
this.offices[CityNameEnum.Sector12] = new OfficeSpace({
city: CityNameEnum.Sector12,
size: corpConstants.officeInitialSize,
});

Expand Down Expand Up @@ -138,7 +138,7 @@ export class Division {
calculateRecoupableValue(): number {
let price = this.startingCost;
for (const city of getRecordKeys(this.offices)) {
if (city === CityName.Sector12) continue;
if (city === CityNameEnum.Sector12) continue;
price += corpConstants.officeInitialCost;
if (this.warehouses[city]) price += corpConstants.warehouseInitialCost;
}
Expand Down Expand Up @@ -180,7 +180,7 @@ export class Division {

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

//Only 'process the market' for materials that this industry deals with
for (const city of Object.values(CityName)) {
for (const city of Object.values(CityNameEnum)) {
//If this industry has a warehouse in this city, process the market
//for every material this industry requires or produces
if (this.warehouses[city]) {
Expand Down
2 changes: 1 addition & 1 deletion src/Corporation/Export.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CityName } from "@enums";
import type { CityName } from "@nsdefs";

export interface Export {
division: string;
Expand Down
5 changes: 3 additions & 2 deletions src/Corporation/OfficeSpace.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CityName, CorpEmployeeJob } from "@enums";
import { CityNameEnum, CorpEmployeeJob } from "@enums";
import type { CityName } from "@nsdefs";
import * as corpConstants from "./data/Constants";
import { Generic_fromJSON, Generic_toJSON, IReviverValue, constructorsForReviver } from "../utils/JSONReviver";
import { Division } from "./Division";
Expand All @@ -13,7 +14,7 @@ interface IParams {
}

export class OfficeSpace {
city = CityName.Sector12;
city: CityName = CityNameEnum.Sector12;
size = 1;

maxEnergy = 100;
Expand Down
Loading