FEATURE: BitNode options (#1411)

This commit is contained in:
catloversg
2024-07-15 04:30:30 +07:00
committed by GitHub
parent 0e1e8a9862
commit 783120c886
71 changed files with 1315 additions and 308 deletions
+18 -1
View File
@@ -1,4 +1,4 @@
import type { Player as IPlayer } from "@nsdefs";
import type { BitNodeOptions, Player as IPlayer } from "@nsdefs";
import type { PlayerAchievement } from "../../Achievements/Achievements";
import type { Bladeburner } from "../../Bladeburner/Bladeburner";
import type { Corporation } from "../../Corporation/Corporation";
@@ -74,6 +74,22 @@ export class PlayerObject extends Person implements IPlayer {
entropy = 0;
bitNodeOptions: BitNodeOptions = {
sourceFileOverrides: new JSONMap<number, number>(),
intelligenceOverride: undefined,
restrictHomePCUpgrade: false,
disableGang: false,
disableCorporation: false,
disableBladeburner: false,
disable4SData: false,
disableHacknetServer: false,
disableSleeveExpAndAugmentation: false,
};
get activeSourceFiles(): JSONMap<number, number> {
return new JSONMap([...this.sourceFiles, ...this.bitNodeOptions.sourceFileOverrides]);
}
// Player-specific methods
init = generalMethods.init;
startWork = workMethods.startWork;
@@ -129,6 +145,7 @@ export class PlayerObject extends Person implements IPlayer {
setBitNodeNumber = generalMethods.setBitNodeNumber;
canAccessCotMG = generalMethods.canAccessCotMG;
sourceFileLvl = generalMethods.sourceFileLvl;
activeSourceFileLvl = generalMethods.activeSourceFileLvl;
applyEntropy = augmentationMethods.applyEntropy;
focusPenalty = generalMethods.focusPenalty;
@@ -1,9 +1,10 @@
import { canAccessBitNodeFeature } from "../../BitNode/BitNodeUtils";
import { Bladeburner } from "../../Bladeburner/Bladeburner";
import type { PlayerObject } from "./PlayerObject";
export function canAccessBladeburner(this: PlayerObject): boolean {
return this.bitNodeN === 6 || this.bitNodeN === 7 || this.sourceFileLvl(6) > 0 || this.sourceFileLvl(7) > 0;
return (canAccessBitNodeFeature(6) || canAccessBitNodeFeature(7)) && !this.bitNodeOptions.disableBladeburner;
}
export function startBladeburner(this: PlayerObject): void {
@@ -3,9 +3,10 @@ import { resetIndustryResearchTrees } from "../../Corporation/data/IndustryData"
import { Corporation } from "../../Corporation/Corporation";
import type { PlayerObject } from "./PlayerObject";
import { canAccessBitNodeFeature } from "../../BitNode/BitNodeUtils";
export function canAccessCorporation(this: PlayerObject): boolean {
return this.bitNodeN === 3 || this.sourceFileLvl(3) > 0;
return canAccessBitNodeFeature(3) && !this.bitNodeOptions.disableCorporation;
}
export function startCorporation(this: PlayerObject, corpName: string, seedFunded: boolean): void {
@@ -17,7 +18,7 @@ export function startCorporation(this: PlayerObject, corpName: string, seedFunde
//reset the research tree in case the corporation was restarted
resetIndustryResearchTrees();
if (this.bitNodeN === 3 || this.sourceFileLvl(3) === 3) {
if (this.bitNodeN === 3 || this.activeSourceFileLvl(3) === 3) {
this.corporation.unlocks.add(CorpUnlockName.WarehouseAPI);
this.corporation.unlocks.add(CorpUnlockName.OfficeAPI);
}
@@ -6,12 +6,16 @@ import { Factions } from "../../Faction/Factions";
import { Gang } from "../../Gang/Gang";
import { GangConstants } from "../../Gang/data/Constants";
import { isFactionWork } from "../../Work/FactionWork";
import { canAccessBitNodeFeature } from "../../BitNode/BitNodeUtils";
export function canAccessGang(this: PlayerObject): boolean {
if (this.bitNodeOptions.disableGang) {
return false;
}
if (this.bitNodeN === 2) {
return true;
}
if (this.sourceFileLvl(2) <= 0) {
if (this.activeSourceFileLvl(2) === 0) {
return false;
}
@@ -19,7 +23,7 @@ export function canAccessGang(this: PlayerObject): boolean {
}
export function isAwareOfGang(this: PlayerObject): boolean {
return this.bitNodeN === 2 || this.sourceFileLvl(2) >= 1;
return canAccessBitNodeFeature(2) && !this.bitNodeOptions.disableGang;
}
export function getGangFaction(this: PlayerObject): Faction {
@@ -49,6 +49,7 @@ import { achievements } from "../../Achievements/Achievements";
import { isCompanyWork } from "../../Work/CompanyWork";
import { isMember } from "../../utils/EnumHelper";
import { canAccessBitNodeFeature } from "../../BitNode/BitNodeUtils";
export function init(this: PlayerObject): void {
/* Initialize Player's home computer */
@@ -415,7 +416,7 @@ export function reapplyAllSourceFiles(this: PlayerObject): void {
//Will always be called after reapplyAllAugmentations() so multipliers do not have to be reset
//this.resetMultipliers();
for (const [bn, lvl] of this.sourceFiles) {
for (const [bn, lvl] of this.activeSourceFiles) {
const srcFileKey = "SourceFile" + bn;
const sourceFileObject = SourceFiles[srcFileKey];
if (!sourceFileObject) {
@@ -536,7 +537,7 @@ export function gotoLocation(this: PlayerObject, to: LocationName): boolean {
}
export function canAccessGrafting(this: PlayerObject): boolean {
return this.bitNodeN === 10 || this.sourceFileLvl(10) > 0;
return canAccessBitNodeFeature(10);
}
export function giveExploit(this: PlayerObject, exploit: Exploit): void {
@@ -560,13 +561,20 @@ export function getCasinoWinnings(this: PlayerObject): number {
}
export function canAccessCotMG(this: PlayerObject): boolean {
return this.bitNodeN === 13 || this.sourceFileLvl(13) > 0;
return canAccessBitNodeFeature(13);
}
export function sourceFileLvl(this: PlayerObject, n: number): number {
return this.sourceFiles.get(n) ?? 0;
}
export function activeSourceFileLvl(this: PlayerObject, n: number): number {
if (this.bitNodeOptions.sourceFileOverrides.has(n)) {
return this.bitNodeOptions.sourceFileOverrides.get(n) ?? 0;
}
return this.sourceFiles.get(n) ?? 0;
}
export function focusPenalty(this: PlayerObject): number {
let focus = 1;
if (!this.hasAugmentation(AugmentationName.NeuroreceptorManager, true)) {