mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-20 16:22:56 +02:00
ENUMS: Initial Enum Helper rework + Reorganization (#596)
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import type { PlayerObject } from "./PlayerObject";
|
||||
import type { ProgramFilePath } from "../../Paths/ProgramFilePath";
|
||||
|
||||
import { applyAugmentation } from "../../Augmentation/AugmentationHelpers";
|
||||
import { PlayerOwnedAugmentation } from "../../Augmentation/PlayerOwnedAugmentation";
|
||||
import { AugmentationNames } from "../../Augmentation/data/AugmentationNames";
|
||||
import { AugmentationName, CityName, CompletedProgramName, FactionName, LocationName, ToastVariant } from "@enums";
|
||||
import { BitNodeMultipliers } from "../../BitNode/BitNodeMultipliers";
|
||||
import { CodingContractRewardType, ICodingContractReward } from "../../CodingContracts";
|
||||
import { Company } from "../../Company/Company";
|
||||
@@ -11,14 +14,12 @@ import { CompanyPositions } from "../../Company/CompanyPositions";
|
||||
import { CompanyPosition } from "../../Company/CompanyPosition";
|
||||
import * as posNames from "../../Company/data/JobTracks";
|
||||
import { CONSTANTS } from "../../Constants";
|
||||
import { CompletedProgramName } from "../../Programs/Programs";
|
||||
import { Exploit } from "../../Exploits/Exploit";
|
||||
import { Faction } from "../../Faction/Faction";
|
||||
import { Factions } from "../../Faction/Factions";
|
||||
import { resetGangs } from "../../Gang/AllGangs";
|
||||
import { Cities } from "../../Locations/Cities";
|
||||
import { Locations } from "../../Locations/Locations";
|
||||
import { CityName, LocationName } from "../../Enums";
|
||||
import { Sleeve } from "../Sleeve/Sleeve";
|
||||
import { isSleeveCompanyWork } from "../Sleeve/Work/SleeveCompanyWork";
|
||||
import { calculateSkillProgress as calculateSkillProgressF, ISkillProgress } from "../formulas/skill";
|
||||
@@ -37,16 +38,12 @@ import { formatMoney } from "../../ui/formatNumber";
|
||||
import { MoneySourceTracker } from "../../utils/MoneySourceTracker";
|
||||
import { dialogBoxCreate } from "../../ui/React/DialogBox";
|
||||
|
||||
import { SnackbarEvents, ToastVariant } from "../../ui/React/Snackbar";
|
||||
import { SnackbarEvents } from "../../ui/React/Snackbar";
|
||||
import { achievements } from "../../Achievements/Achievements";
|
||||
import { FactionNames } from "../../Faction/data/FactionNames";
|
||||
|
||||
import { isCompanyWork } from "../../Work/CompanyWork";
|
||||
import { serverMetadata } from "../../Server/data/servers";
|
||||
|
||||
import type { PlayerObject } from "./PlayerObject";
|
||||
import { ProgramFilePath } from "src/Paths/ProgramFilePath";
|
||||
|
||||
export function init(this: PlayerObject): void {
|
||||
/* Initialize Player's home computer */
|
||||
const t_homeComp = safelyCreateUniqueServer({
|
||||
@@ -560,7 +557,7 @@ export function reapplyAllAugmentations(this: PlayerObject, resetMultipliers = t
|
||||
const playerAug = this.augmentations[i];
|
||||
const augName = playerAug.name;
|
||||
|
||||
if (augName == AugmentationNames.NeuroFluxGovernor) {
|
||||
if (augName == AugmentationName.NeuroFluxGovernor) {
|
||||
for (let j = 0; j < playerAug.level; ++j) {
|
||||
applyAugmentation(this.augmentations[i], true);
|
||||
}
|
||||
@@ -625,7 +622,7 @@ export function checkForFactionInvitations(this: PlayerObject): Faction[] {
|
||||
}
|
||||
|
||||
//Illuminati
|
||||
const illuminatiFac = Factions[FactionNames.Illuminati];
|
||||
const illuminatiFac = Factions[FactionName.Illuminati];
|
||||
if (
|
||||
!illuminatiFac.isBanned &&
|
||||
!illuminatiFac.isMember &&
|
||||
@@ -642,7 +639,7 @@ export function checkForFactionInvitations(this: PlayerObject): Faction[] {
|
||||
}
|
||||
|
||||
//Daedalus
|
||||
const daedalusFac = Factions[FactionNames.Daedalus];
|
||||
const daedalusFac = Factions[FactionName.Daedalus];
|
||||
if (
|
||||
!daedalusFac.isBanned &&
|
||||
!daedalusFac.isMember &&
|
||||
@@ -659,7 +656,7 @@ export function checkForFactionInvitations(this: PlayerObject): Faction[] {
|
||||
}
|
||||
|
||||
//The Covenant
|
||||
const covenantFac = Factions[FactionNames.TheCovenant];
|
||||
const covenantFac = Factions[FactionName.TheCovenant];
|
||||
if (
|
||||
!covenantFac.isBanned &&
|
||||
!covenantFac.isMember &&
|
||||
@@ -676,7 +673,7 @@ export function checkForFactionInvitations(this: PlayerObject): Faction[] {
|
||||
}
|
||||
|
||||
//ECorp
|
||||
const ecorpFac = Factions[FactionNames.ECorp];
|
||||
const ecorpFac = Factions[FactionName.ECorp];
|
||||
if (
|
||||
!ecorpFac.isBanned &&
|
||||
!ecorpFac.isMember &&
|
||||
@@ -687,7 +684,7 @@ export function checkForFactionInvitations(this: PlayerObject): Faction[] {
|
||||
}
|
||||
|
||||
//MegaCorp
|
||||
const megacorpFac = Factions[FactionNames.MegaCorp];
|
||||
const megacorpFac = Factions[FactionName.MegaCorp];
|
||||
if (
|
||||
!megacorpFac.isBanned &&
|
||||
!megacorpFac.isMember &&
|
||||
@@ -698,7 +695,7 @@ export function checkForFactionInvitations(this: PlayerObject): Faction[] {
|
||||
}
|
||||
|
||||
//Bachman & Associates
|
||||
const bachmanandassociatesFac = Factions[FactionNames.BachmanAssociates];
|
||||
const bachmanandassociatesFac = Factions[FactionName.BachmanAssociates];
|
||||
if (
|
||||
!bachmanandassociatesFac.isBanned &&
|
||||
!bachmanandassociatesFac.isMember &&
|
||||
@@ -709,7 +706,7 @@ export function checkForFactionInvitations(this: PlayerObject): Faction[] {
|
||||
}
|
||||
|
||||
//Blade Industries
|
||||
const bladeindustriesFac = Factions[FactionNames.BladeIndustries];
|
||||
const bladeindustriesFac = Factions[FactionName.BladeIndustries];
|
||||
if (
|
||||
!bladeindustriesFac.isBanned &&
|
||||
!bladeindustriesFac.isMember &&
|
||||
@@ -720,7 +717,7 @@ export function checkForFactionInvitations(this: PlayerObject): Faction[] {
|
||||
}
|
||||
|
||||
//NWO
|
||||
const nwoFac = Factions[FactionNames.NWO];
|
||||
const nwoFac = Factions[FactionName.NWO];
|
||||
if (
|
||||
!nwoFac.isBanned &&
|
||||
!nwoFac.isMember &&
|
||||
@@ -731,7 +728,7 @@ export function checkForFactionInvitations(this: PlayerObject): Faction[] {
|
||||
}
|
||||
|
||||
//Clarke Incorporated
|
||||
const clarkeincorporatedFac = Factions[FactionNames.ClarkeIncorporated];
|
||||
const clarkeincorporatedFac = Factions[FactionName.ClarkeIncorporated];
|
||||
if (
|
||||
!clarkeincorporatedFac.isBanned &&
|
||||
!clarkeincorporatedFac.isMember &&
|
||||
@@ -742,7 +739,7 @@ export function checkForFactionInvitations(this: PlayerObject): Faction[] {
|
||||
}
|
||||
|
||||
//OmniTek Incorporated
|
||||
const omnitekincorporatedFac = Factions[FactionNames.OmniTekIncorporated];
|
||||
const omnitekincorporatedFac = Factions[FactionName.OmniTekIncorporated];
|
||||
if (
|
||||
!omnitekincorporatedFac.isBanned &&
|
||||
!omnitekincorporatedFac.isMember &&
|
||||
@@ -753,7 +750,7 @@ export function checkForFactionInvitations(this: PlayerObject): Faction[] {
|
||||
}
|
||||
|
||||
//Four Sigma
|
||||
const foursigmaFac = Factions[FactionNames.FourSigma];
|
||||
const foursigmaFac = Factions[FactionName.FourSigma];
|
||||
if (
|
||||
!foursigmaFac.isBanned &&
|
||||
!foursigmaFac.isMember &&
|
||||
@@ -764,7 +761,7 @@ export function checkForFactionInvitations(this: PlayerObject): Faction[] {
|
||||
}
|
||||
|
||||
//KuaiGong International
|
||||
const kuaigonginternationalFac = Factions[FactionNames.KuaiGongInternational];
|
||||
const kuaigonginternationalFac = Factions[FactionName.KuaiGongInternational];
|
||||
if (
|
||||
!kuaigonginternationalFac.isBanned &&
|
||||
!kuaigonginternationalFac.isMember &&
|
||||
@@ -775,12 +772,12 @@ export function checkForFactionInvitations(this: PlayerObject): Faction[] {
|
||||
}
|
||||
|
||||
//Fulcrum Secret Technologies - If you've unlocked fulcrum secret technologies server and have a high rep with the company
|
||||
const fulcrumsecrettechonologiesFac = Factions[FactionNames.FulcrumSecretTechnologies];
|
||||
const fulcrumsecrettechonologiesFac = Factions[FactionName.FulcrumSecretTechnologies];
|
||||
const fulcrumSecretServer = GetServer(SpecialServers.FulcrumSecretTechnologies);
|
||||
if (!(fulcrumSecretServer instanceof Server))
|
||||
throw new Error(`${FactionNames.FulcrumSecretTechnologies} should be normal server`);
|
||||
throw new Error(`${FactionName.FulcrumSecretTechnologies} should be normal server`);
|
||||
if (fulcrumSecretServer == null) {
|
||||
console.error(`Could not find ${FactionNames.FulcrumSecretTechnologies} Server`);
|
||||
console.error(`Could not find ${FactionName.FulcrumSecretTechnologies} Server`);
|
||||
} else if (
|
||||
!fulcrumsecrettechonologiesFac.isBanned &&
|
||||
!fulcrumsecrettechonologiesFac.isMember &&
|
||||
@@ -792,11 +789,11 @@ export function checkForFactionInvitations(this: PlayerObject): Faction[] {
|
||||
}
|
||||
|
||||
//BitRunners
|
||||
const bitrunnersFac = Factions[FactionNames.BitRunners];
|
||||
const bitrunnersFac = Factions[FactionName.BitRunners];
|
||||
const bitrunnersServer = GetServer(SpecialServers.BitRunnersServer);
|
||||
if (!(bitrunnersServer instanceof Server)) throw new Error(`${FactionNames.BitRunners} should be normal server`);
|
||||
if (!(bitrunnersServer instanceof Server)) throw new Error(`${FactionName.BitRunners} should be normal server`);
|
||||
if (bitrunnersServer == null) {
|
||||
console.error(`Could not find ${FactionNames.BitRunners} Server`);
|
||||
console.error(`Could not find ${FactionName.BitRunners} Server`);
|
||||
} else if (
|
||||
!bitrunnersFac.isBanned &&
|
||||
!bitrunnersFac.isMember &&
|
||||
@@ -808,11 +805,11 @@ export function checkForFactionInvitations(this: PlayerObject): Faction[] {
|
||||
|
||||
//The Black Hand
|
||||
|
||||
const theblackhandFac = Factions[FactionNames.TheBlackHand];
|
||||
const theblackhandFac = Factions[FactionName.TheBlackHand];
|
||||
const blackhandServer = GetServer(SpecialServers.TheBlackHandServer);
|
||||
if (!(blackhandServer instanceof Server)) throw new Error(`${FactionNames.TheBlackHand} should be normal server`);
|
||||
if (!(blackhandServer instanceof Server)) throw new Error(`${FactionName.TheBlackHand} should be normal server`);
|
||||
if (blackhandServer == null) {
|
||||
console.error(`Could not find ${FactionNames.TheBlackHand} Server`);
|
||||
console.error(`Could not find ${FactionName.TheBlackHand} Server`);
|
||||
} else if (
|
||||
!theblackhandFac.isBanned &&
|
||||
!theblackhandFac.isMember &&
|
||||
@@ -823,11 +820,11 @@ export function checkForFactionInvitations(this: PlayerObject): Faction[] {
|
||||
}
|
||||
|
||||
//NiteSec
|
||||
const nitesecFac = Factions[FactionNames.NiteSec];
|
||||
const nitesecFac = Factions[FactionName.NiteSec];
|
||||
const nitesecServer = GetServer(SpecialServers.NiteSecServer);
|
||||
if (!(nitesecServer instanceof Server)) throw new Error(`${FactionNames.NiteSec} should be normal server`);
|
||||
if (!(nitesecServer instanceof Server)) throw new Error(`${FactionName.NiteSec} should be normal server`);
|
||||
if (nitesecServer == null) {
|
||||
console.error(`Could not find ${FactionNames.NiteSec} Server`);
|
||||
console.error(`Could not find ${FactionName.NiteSec} Server`);
|
||||
} else if (
|
||||
!nitesecFac.isBanned &&
|
||||
!nitesecFac.isMember &&
|
||||
@@ -838,7 +835,7 @@ export function checkForFactionInvitations(this: PlayerObject): Faction[] {
|
||||
}
|
||||
|
||||
//Chongqing
|
||||
const chongqingFac = Factions[FactionNames.Chongqing];
|
||||
const chongqingFac = Factions[FactionName.Chongqing];
|
||||
if (
|
||||
!chongqingFac.isBanned &&
|
||||
!chongqingFac.isMember &&
|
||||
@@ -850,7 +847,7 @@ export function checkForFactionInvitations(this: PlayerObject): Faction[] {
|
||||
}
|
||||
|
||||
//Sector-12
|
||||
const sector12Fac = Factions[FactionNames.Sector12];
|
||||
const sector12Fac = Factions[FactionName.Sector12];
|
||||
if (
|
||||
!sector12Fac.isBanned &&
|
||||
!sector12Fac.isMember &&
|
||||
@@ -862,7 +859,7 @@ export function checkForFactionInvitations(this: PlayerObject): Faction[] {
|
||||
}
|
||||
|
||||
//New Tokyo
|
||||
const newtokyoFac = Factions[FactionNames.NewTokyo];
|
||||
const newtokyoFac = Factions[FactionName.NewTokyo];
|
||||
if (
|
||||
!newtokyoFac.isBanned &&
|
||||
!newtokyoFac.isMember &&
|
||||
@@ -874,7 +871,7 @@ export function checkForFactionInvitations(this: PlayerObject): Faction[] {
|
||||
}
|
||||
|
||||
//Aevum
|
||||
const aevumFac = Factions[FactionNames.Aevum];
|
||||
const aevumFac = Factions[FactionName.Aevum];
|
||||
if (
|
||||
!aevumFac.isBanned &&
|
||||
!aevumFac.isMember &&
|
||||
@@ -886,7 +883,7 @@ export function checkForFactionInvitations(this: PlayerObject): Faction[] {
|
||||
}
|
||||
|
||||
//Ishima
|
||||
const ishimaFac = Factions[FactionNames.Ishima];
|
||||
const ishimaFac = Factions[FactionName.Ishima];
|
||||
if (
|
||||
!ishimaFac.isBanned &&
|
||||
!ishimaFac.isMember &&
|
||||
@@ -898,7 +895,7 @@ export function checkForFactionInvitations(this: PlayerObject): Faction[] {
|
||||
}
|
||||
|
||||
//Volhaven
|
||||
const volhavenFac = Factions[FactionNames.Volhaven];
|
||||
const volhavenFac = Factions[FactionName.Volhaven];
|
||||
if (
|
||||
!volhavenFac.isBanned &&
|
||||
!volhavenFac.isMember &&
|
||||
@@ -910,7 +907,7 @@ export function checkForFactionInvitations(this: PlayerObject): Faction[] {
|
||||
}
|
||||
|
||||
//Speakers for the Dead
|
||||
const speakersforthedeadFac = Factions[FactionNames.SpeakersForTheDead];
|
||||
const speakersforthedeadFac = Factions[FactionName.SpeakersForTheDead];
|
||||
if (
|
||||
!speakersforthedeadFac.isBanned &&
|
||||
!speakersforthedeadFac.isMember &&
|
||||
@@ -929,7 +926,7 @@ export function checkForFactionInvitations(this: PlayerObject): Faction[] {
|
||||
}
|
||||
|
||||
//The Dark Army
|
||||
const thedarkarmyFac = Factions[FactionNames.TheDarkArmy];
|
||||
const thedarkarmyFac = Factions[FactionName.TheDarkArmy];
|
||||
if (
|
||||
!thedarkarmyFac.isBanned &&
|
||||
!thedarkarmyFac.isMember &&
|
||||
@@ -949,7 +946,7 @@ export function checkForFactionInvitations(this: PlayerObject): Faction[] {
|
||||
}
|
||||
|
||||
//The Syndicate
|
||||
const thesyndicateFac = Factions[FactionNames.TheSyndicate];
|
||||
const thesyndicateFac = Factions[FactionName.TheSyndicate];
|
||||
if (
|
||||
!thesyndicateFac.isBanned &&
|
||||
!thesyndicateFac.isMember &&
|
||||
@@ -969,7 +966,7 @@ export function checkForFactionInvitations(this: PlayerObject): Faction[] {
|
||||
}
|
||||
|
||||
//Silhouette
|
||||
const silhouetteFac = Factions[FactionNames.Silhouette];
|
||||
const silhouetteFac = Factions[FactionName.Silhouette];
|
||||
if (
|
||||
!silhouetteFac.isBanned &&
|
||||
!silhouetteFac.isMember &&
|
||||
@@ -984,7 +981,7 @@ export function checkForFactionInvitations(this: PlayerObject): Faction[] {
|
||||
}
|
||||
|
||||
//Tetrads
|
||||
const tetradsFac = Factions[FactionNames.Tetrads];
|
||||
const tetradsFac = Factions[FactionName.Tetrads];
|
||||
if (
|
||||
!tetradsFac.isBanned &&
|
||||
!tetradsFac.isMember &&
|
||||
@@ -1000,7 +997,7 @@ export function checkForFactionInvitations(this: PlayerObject): Faction[] {
|
||||
}
|
||||
|
||||
//SlumSnakes
|
||||
const slumsnakesFac = Factions[FactionNames.SlumSnakes];
|
||||
const slumsnakesFac = Factions[FactionName.SlumSnakes];
|
||||
if (
|
||||
!slumsnakesFac.isBanned &&
|
||||
!slumsnakesFac.isMember &&
|
||||
@@ -1016,7 +1013,7 @@ export function checkForFactionInvitations(this: PlayerObject): Faction[] {
|
||||
}
|
||||
|
||||
//Netburners
|
||||
const netburnersFac = Factions[FactionNames.Netburners];
|
||||
const netburnersFac = Factions[FactionName.Netburners];
|
||||
let totalHacknetRam = 0;
|
||||
let totalHacknetCores = 0;
|
||||
let totalHacknetLevels = 0;
|
||||
@@ -1048,7 +1045,7 @@ export function checkForFactionInvitations(this: PlayerObject): Faction[] {
|
||||
}
|
||||
|
||||
//Tian Di Hui
|
||||
const tiandihuiFac = Factions[FactionNames.TianDiHui];
|
||||
const tiandihuiFac = Factions[FactionName.TianDiHui];
|
||||
if (
|
||||
!tiandihuiFac.isBanned &&
|
||||
!tiandihuiFac.isMember &&
|
||||
@@ -1061,11 +1058,11 @@ export function checkForFactionInvitations(this: PlayerObject): Faction[] {
|
||||
}
|
||||
|
||||
//CyberSec
|
||||
const cybersecFac = Factions[FactionNames.CyberSec];
|
||||
const cybersecFac = Factions[FactionName.CyberSec];
|
||||
const cybersecServer = GetServer(SpecialServers.CyberSecServer);
|
||||
if (!(cybersecServer instanceof Server)) throw new Error(`${FactionNames.CyberSec} should be normal server`);
|
||||
if (!(cybersecServer instanceof Server)) throw new Error(`${FactionName.CyberSec} should be normal server`);
|
||||
if (cybersecServer == null) {
|
||||
console.error(`Could not find ${FactionNames.CyberSec} Server`);
|
||||
console.error(`Could not find ${FactionName.CyberSec} Server`);
|
||||
} else if (
|
||||
!cybersecFac.isBanned &&
|
||||
!cybersecFac.isMember &&
|
||||
@@ -1126,7 +1123,7 @@ export function gainCodingContractReward(
|
||||
const totalGain = CONSTANTS.CodingContractBaseFactionRepGain * difficulty;
|
||||
|
||||
// Ignore Bladeburners and other special factions for this calculation
|
||||
const specialFactions = [FactionNames.Bladeburners as string];
|
||||
const specialFactions = [FactionName.Bladeburners as string];
|
||||
const factions = this.factions.slice().filter((f) => {
|
||||
return !specialFactions.includes(f);
|
||||
});
|
||||
@@ -1217,7 +1214,7 @@ export function sourceFileLvl(this: PlayerObject, n: number): number {
|
||||
|
||||
export function focusPenalty(this: PlayerObject): number {
|
||||
let focus = 1;
|
||||
if (!this.hasAugmentation(AugmentationNames.NeuroreceptorManager, true)) {
|
||||
if (!this.hasAugmentation(AugmentationName.NeuroreceptorManager, true)) {
|
||||
focus = this.focus ? 1 : CONSTANTS.BaseFocusBonus;
|
||||
}
|
||||
return focus;
|
||||
|
||||
Reference in New Issue
Block a user