mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-22 01:03:01 +02:00
FEATURE: BitNode options (#1411)
This commit is contained in:
@@ -59,6 +59,7 @@ import { ServerConstants } from "../Server/data/Constants";
|
||||
import { blackOpsArray } from "../Bladeburner/data/BlackOperations";
|
||||
import { calculateEffectiveRequiredReputation } from "../Company/utils";
|
||||
import { calculateFavorAfterResetting } from "../Faction/formulas/favor";
|
||||
import { validBitNodes } from "../BitNode/BitNodeUtils";
|
||||
|
||||
export function NetscriptSingularity(): InternalAPI<ISingularity> {
|
||||
const runAfterReset = function (cbScript: ScriptFilePath) {
|
||||
@@ -628,7 +629,7 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
|
||||
|
||||
// Check if we're at max cores
|
||||
const homeComputer = Player.getHomeComputer();
|
||||
if (homeComputer.cpuCores >= 8) {
|
||||
if (Player.bitNodeOptions.restrictHomePCUpgrade || homeComputer.cpuCores >= 8) {
|
||||
helpers.log(ctx, () => `Your home computer is at max cores.`);
|
||||
return false;
|
||||
}
|
||||
@@ -659,7 +660,10 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
|
||||
|
||||
// Check if we're at max RAM
|
||||
const homeComputer = Player.getHomeComputer();
|
||||
if (homeComputer.maxRam >= ServerConstants.HomeComputerMaxRam) {
|
||||
if (
|
||||
(Player.bitNodeOptions.restrictHomePCUpgrade && homeComputer.maxRam >= 128) ||
|
||||
homeComputer.maxRam >= ServerConstants.HomeComputerMaxRam
|
||||
) {
|
||||
helpers.log(ctx, () => `Your home computer is at max RAM.`);
|
||||
return false;
|
||||
}
|
||||
@@ -1137,38 +1141,47 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
|
||||
}
|
||||
return item.price;
|
||||
},
|
||||
b1tflum3: (ctx) => (_nextBN, _cbScript) => {
|
||||
b1tflum3: (ctx) => (_nextBN, _cbScript, _bitNodeOptions) => {
|
||||
helpers.checkSingularityAccess(ctx);
|
||||
const nextBN = helpers.number(ctx, "nextBN", _nextBN);
|
||||
const cbScript = _cbScript
|
||||
? resolveScriptFilePath(helpers.string(ctx, "cbScript", _cbScript), ctx.workerScript.name)
|
||||
: false;
|
||||
if (cbScript === null) throw helpers.errorMessage(ctx, `Could not resolve file path: ${_cbScript}`);
|
||||
enterBitNode(true, Player.bitNodeN, nextBN);
|
||||
if (cbScript) setTimeout(() => runAfterReset(cbScript), 500);
|
||||
if (cbScript === null) {
|
||||
throw helpers.errorMessage(ctx, `Could not resolve file path: ${_cbScript}`);
|
||||
}
|
||||
enterBitNode(true, Player.bitNodeN, nextBN, helpers.validateBitNodeOptions(ctx, _bitNodeOptions));
|
||||
if (cbScript) {
|
||||
setTimeout(() => runAfterReset(cbScript), 500);
|
||||
}
|
||||
},
|
||||
destroyW0r1dD43m0n: (ctx) => (_nextBN, _cbScript) => {
|
||||
destroyW0r1dD43m0n: (ctx) => (_nextBN, _cbScript, _bitNodeOptions) => {
|
||||
helpers.checkSingularityAccess(ctx);
|
||||
const nextBN = helpers.number(ctx, "nextBN", _nextBN);
|
||||
if (nextBN > 14 || nextBN < 1 || !Number.isInteger(nextBN)) {
|
||||
throw new Error(`Invalid bitnode specified: ${_nextBN}`);
|
||||
if (!validBitNodes.includes(nextBN)) {
|
||||
throw new Error(`Invalid BitNode: ${_nextBN}.`);
|
||||
}
|
||||
const cbScript = _cbScript
|
||||
? resolveScriptFilePath(helpers.string(ctx, "cbScript", _cbScript), ctx.workerScript.name)
|
||||
: false;
|
||||
if (cbScript === null) throw helpers.errorMessage(ctx, `Could not resolve file path: ${_cbScript}`);
|
||||
if (cbScript === null) {
|
||||
throw helpers.errorMessage(ctx, `Could not resolve file path: ${_cbScript}`);
|
||||
}
|
||||
|
||||
const wd = GetServer(SpecialServers.WorldDaemon);
|
||||
if (!(wd instanceof Server)) {
|
||||
throw new Error("WorldDaemon is not a normal server. This is a bug. Please contact developers.");
|
||||
}
|
||||
const hackingRequirements = () => {
|
||||
if (Player.skills.hacking < wd.requiredHackingSkill) return false;
|
||||
if (!wd.hasAdminRights) return false;
|
||||
if (Player.skills.hacking < wd.requiredHackingSkill || !wd.hasAdminRights) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
const bladeburnerRequirements = () => {
|
||||
if (!Player.bladeburner) return false;
|
||||
if (!Player.bladeburner) {
|
||||
return false;
|
||||
}
|
||||
return Player.bladeburner.numBlackOpsComplete >= blackOpsArray.length;
|
||||
};
|
||||
|
||||
@@ -1179,8 +1192,10 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
|
||||
|
||||
wd.backdoorInstalled = true;
|
||||
calculateAchievements();
|
||||
enterBitNode(false, Player.bitNodeN, nextBN);
|
||||
if (cbScript) setTimeout(() => runAfterReset(cbScript), 500);
|
||||
enterBitNode(false, Player.bitNodeN, nextBN, helpers.validateBitNodeOptions(ctx, _bitNodeOptions));
|
||||
if (cbScript) {
|
||||
setTimeout(() => runAfterReset(cbScript), 500);
|
||||
}
|
||||
},
|
||||
getCurrentWork: (ctx) => () => {
|
||||
helpers.checkSingularityAccess(ctx);
|
||||
|
||||
Reference in New Issue
Block a user