mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-17 14:59:16 +02:00
work on making sure all the functions are accounted for
This commit is contained in:
@@ -187,6 +187,7 @@ export const RamCosts: IMap<any> = {
|
||||
universityCourse: RamCostConstants.ScriptSingularityFn1RamCost,
|
||||
gymWorkout: RamCostConstants.ScriptSingularityFn1RamCost,
|
||||
travelToCity: RamCostConstants.ScriptSingularityFn1RamCost,
|
||||
goToLocation: RamCostConstants.ScriptSingularityFn1RamCost,
|
||||
purchaseTor: RamCostConstants.ScriptSingularityFn1RamCost,
|
||||
purchaseProgram: RamCostConstants.ScriptSingularityFn1RamCost,
|
||||
getCurrentServer: RamCostConstants.ScriptSingularityFn1RamCost,
|
||||
@@ -200,7 +201,9 @@ export const RamCosts: IMap<any> = {
|
||||
isBusy: RamCostConstants.ScriptSingularityFn1RamCost / 4,
|
||||
stopAction: RamCostConstants.ScriptSingularityFn1RamCost / 2,
|
||||
upgradeHomeRam: RamCostConstants.ScriptSingularityFn2RamCost,
|
||||
upgradeHomeCores: RamCostConstants.ScriptSingularityFn2RamCost,
|
||||
getUpgradeHomeRamCost: RamCostConstants.ScriptSingularityFn2RamCost / 2,
|
||||
getUpgradeHomeCoresCost: RamCostConstants.ScriptSingularityFn2RamCost / 2,
|
||||
workForCompany: RamCostConstants.ScriptSingularityFn2RamCost,
|
||||
applyToCompany: RamCostConstants.ScriptSingularityFn2RamCost,
|
||||
getCompanyRep: RamCostConstants.ScriptSingularityFn2RamCost / 3,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,224 +0,0 @@
|
||||
import { INetscriptHelper } from "./INetscriptHelper";
|
||||
import { WorkerScript } from "../Netscript/WorkerScript";
|
||||
import { IPlayer } from "../PersonObjects/IPlayer";
|
||||
import { purchaseAugmentation } from "../Faction/FactionHelpers";
|
||||
import { startWorkerScript } from "../NetscriptWorker";
|
||||
import { Augmentation } from "../Augmentation/Augmentation";
|
||||
import { Augmentations } from "../Augmentation/Augmentations";
|
||||
import { augmentationExists, installAugmentations } from "../Augmentation/AugmentationHelpers";
|
||||
import { prestigeAugmentation } from "../Prestige";
|
||||
import { AugmentationNames } from "../Augmentation/data/AugmentationNames";
|
||||
import { killWorkerScript } from "../Netscript/killWorkerScript";
|
||||
import { CONSTANTS } from "../Constants";
|
||||
import { isString } from "../utils/helpers/isString";
|
||||
import { getRamCost } from "../Netscript/RamCostGenerator";
|
||||
import { RunningScript } from "../Script/RunningScript";
|
||||
|
||||
export interface INetscriptAugmentations {
|
||||
getOwnedAugmentations(purchased?: any): any;
|
||||
getOwnedSourceFiles(): any;
|
||||
getAugmentationsFromFaction(facname: any): any;
|
||||
getAugmentationCost(name: any): any;
|
||||
getAugmentationPrereq(name: any): any;
|
||||
getAugmentationPrice(name: any): any;
|
||||
getAugmentationRepReq(name: any): any;
|
||||
getAugmentationStats(name: any): any;
|
||||
purchaseAugmentation(faction: any, name: any): any;
|
||||
softReset(cbScript: any): any;
|
||||
installAugmentations(cbScript: any): any;
|
||||
}
|
||||
|
||||
export function NetscriptAugmentations(
|
||||
player: IPlayer,
|
||||
workerScript: WorkerScript,
|
||||
helper: INetscriptHelper,
|
||||
): INetscriptAugmentations {
|
||||
const getAugmentation = function (func: any, name: any): Augmentation {
|
||||
if (!augmentationExists(name)) {
|
||||
throw helper.makeRuntimeErrorMsg(func, `Invalid augmentation: '${name}'`);
|
||||
}
|
||||
|
||||
return Augmentations[name];
|
||||
};
|
||||
const runAfterReset = function (cbScript = null): void {
|
||||
//Run a script after reset
|
||||
if (cbScript && isString(cbScript)) {
|
||||
const home = player.getHomeComputer();
|
||||
for (const script of home.scripts) {
|
||||
if (script.filename === cbScript) {
|
||||
const ramUsage = script.ramUsage;
|
||||
const ramAvailable = home.maxRam - home.ramUsed;
|
||||
if (ramUsage > ramAvailable) {
|
||||
return; // Not enough RAM
|
||||
}
|
||||
const runningScriptObj = new RunningScript(script, []); // No args
|
||||
runningScriptObj.threads = 1; // Only 1 thread
|
||||
startWorkerScript(runningScriptObj, home);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
return {
|
||||
getOwnedAugmentations: function (purchased: any = false): any {
|
||||
helper.updateDynamicRam("getOwnedAugmentations", getRamCost("getOwnedAugmentations"));
|
||||
helper.checkSingularityAccess("getOwnedAugmentations", 3);
|
||||
const res = [];
|
||||
for (let i = 0; i < player.augmentations.length; ++i) {
|
||||
res.push(player.augmentations[i].name);
|
||||
}
|
||||
if (purchased) {
|
||||
for (let i = 0; i < player.queuedAugmentations.length; ++i) {
|
||||
res.push(player.queuedAugmentations[i].name);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
},
|
||||
getOwnedSourceFiles: function (): any {
|
||||
helper.updateDynamicRam("getOwnedSourceFiles", getRamCost("getOwnedSourceFiles"));
|
||||
helper.checkSingularityAccess("getOwnedSourceFiles", 3);
|
||||
const res = [];
|
||||
for (let i = 0; i < player.sourceFiles.length; ++i) {
|
||||
res.push({
|
||||
n: player.sourceFiles[i].n,
|
||||
lvl: player.sourceFiles[i].lvl,
|
||||
});
|
||||
}
|
||||
return res;
|
||||
},
|
||||
getAugmentationsFromFaction: function (facname: any): any {
|
||||
helper.updateDynamicRam("getAugmentationsFromFaction", getRamCost("getAugmentationsFromFaction"));
|
||||
helper.checkSingularityAccess("getAugmentationsFromFaction", 3);
|
||||
const faction = helper.getFaction("getAugmentationsFromFaction", facname);
|
||||
|
||||
// If player has a gang with this faction, return all augmentations.
|
||||
if (player.hasGangWith(facname)) {
|
||||
const res = [];
|
||||
for (const augName in Augmentations) {
|
||||
const aug = Augmentations[augName];
|
||||
if (!aug.isSpecial) {
|
||||
res.push(augName);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
return faction.augmentations.slice();
|
||||
},
|
||||
getAugmentationCost: function (name: any): any {
|
||||
helper.updateDynamicRam("getAugmentationCost", getRamCost("getAugmentationCost"));
|
||||
helper.checkSingularityAccess("getAugmentationCost", 3);
|
||||
const aug = getAugmentation("getAugmentationCost", name);
|
||||
return [aug.baseRepRequirement, aug.baseCost];
|
||||
},
|
||||
getAugmentationPrereq: function (name: any): any {
|
||||
helper.updateDynamicRam("getAugmentationPrereq", getRamCost("getAugmentationPrereq"));
|
||||
helper.checkSingularityAccess("getAugmentationPrereq", 3);
|
||||
const aug = getAugmentation("getAugmentationPrereq", name);
|
||||
return aug.prereqs.slice();
|
||||
},
|
||||
getAugmentationPrice: function (name: any): any {
|
||||
helper.updateDynamicRam("getAugmentationPrice", getRamCost("getAugmentationPrice"));
|
||||
helper.checkSingularityAccess("getAugmentationPrice", 3);
|
||||
const aug = getAugmentation("getAugmentationPrice", name);
|
||||
return aug.baseCost;
|
||||
},
|
||||
getAugmentationRepReq: function (name: any): any {
|
||||
helper.updateDynamicRam("getAugmentationRepReq", getRamCost("getAugmentationRepReq"));
|
||||
helper.checkSingularityAccess("getAugmentationRepReq", 3);
|
||||
const aug = getAugmentation("getAugmentationRepReq", name);
|
||||
return aug.baseRepRequirement;
|
||||
},
|
||||
getAugmentationStats: function (name: any): any {
|
||||
helper.updateDynamicRam("getAugmentationStats", getRamCost("getAugmentationStats"));
|
||||
helper.checkSingularityAccess("getAugmentationStats", 3);
|
||||
const aug = getAugmentation("getAugmentationStats", name);
|
||||
return Object.assign({}, aug.mults);
|
||||
},
|
||||
purchaseAugmentation: function (faction: any, name: any): any {
|
||||
helper.updateDynamicRam("purchaseAugmentation", getRamCost("purchaseAugmentation"));
|
||||
helper.checkSingularityAccess("purchaseAugmentation", 3);
|
||||
const fac = helper.getFaction("purchaseAugmentation", faction);
|
||||
const aug = getAugmentation("purchaseAugmentation", name);
|
||||
|
||||
let augs = [];
|
||||
if (player.hasGangWith(faction)) {
|
||||
for (const augName in Augmentations) {
|
||||
const tempAug = Augmentations[augName];
|
||||
if (!tempAug.isSpecial) {
|
||||
augs.push(augName);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
augs = fac.augmentations;
|
||||
}
|
||||
|
||||
if (!augs.includes(name)) {
|
||||
workerScript.log("purchaseAugmentation", `Faction '${faction}' does not have the '${name}' augmentation.`);
|
||||
return false;
|
||||
}
|
||||
|
||||
const isNeuroflux = aug.name === AugmentationNames.NeuroFluxGovernor;
|
||||
if (!isNeuroflux) {
|
||||
for (let j = 0; j < player.queuedAugmentations.length; ++j) {
|
||||
if (player.queuedAugmentations[j].name === aug.name) {
|
||||
workerScript.log("purchaseAugmentation", `You already have the '${name}' augmentation.`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (let j = 0; j < player.augmentations.length; ++j) {
|
||||
if (player.augmentations[j].name === aug.name) {
|
||||
workerScript.log("purchaseAugmentation", `You already have the '${name}' augmentation.`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fac.playerReputation < aug.baseRepRequirement) {
|
||||
workerScript.log("purchaseAugmentation", `You do not have enough reputation with '${fac.name}'.`);
|
||||
return false;
|
||||
}
|
||||
|
||||
const res = purchaseAugmentation(aug, fac, true);
|
||||
workerScript.log("purchaseAugmentation", res);
|
||||
if (isString(res) && res.startsWith("You purchased")) {
|
||||
player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
softReset: function (cbScript: any): any {
|
||||
helper.updateDynamicRam("softReset", getRamCost("softReset"));
|
||||
helper.checkSingularityAccess("softReset", 3);
|
||||
|
||||
workerScript.log("softReset", "Soft resetting. This will cause this script to be killed");
|
||||
setTimeout(() => {
|
||||
prestigeAugmentation();
|
||||
runAfterReset(cbScript);
|
||||
}, 0);
|
||||
|
||||
// Prevent workerScript from "finishing execution naturally"
|
||||
workerScript.running = false;
|
||||
killWorkerScript(workerScript);
|
||||
},
|
||||
installAugmentations: function (cbScript: any): any {
|
||||
helper.updateDynamicRam("installAugmentations", getRamCost("installAugmentations"));
|
||||
helper.checkSingularityAccess("installAugmentations", 3);
|
||||
|
||||
if (player.queuedAugmentations.length === 0) {
|
||||
workerScript.log("installAugmentations", "You do not have any Augmentations to be installed.");
|
||||
return false;
|
||||
}
|
||||
player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain);
|
||||
workerScript.log("installAugmentations", "Installing Augmentations. This will cause this script to be killed");
|
||||
setTimeout(() => {
|
||||
installAugmentations();
|
||||
runAfterReset(cbScript);
|
||||
}, 0);
|
||||
|
||||
workerScript.running = false; // Prevent workerScript from "finishing execution naturally"
|
||||
killWorkerScript(workerScript);
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -4,20 +4,13 @@ import { IPlayer } from "../PersonObjects/IPlayer";
|
||||
import { getRamCost } from "../Netscript/RamCostGenerator";
|
||||
import { is2DArray } from "../utils/helpers/is2DArray";
|
||||
import { CodingContract } from "../CodingContracts";
|
||||
|
||||
export interface INetscriptCodingContract {
|
||||
attempt(answer: any, fn: any, ip?: any, options?: { returnReward: any }): any;
|
||||
getContractType(fn: any, ip?: any): any;
|
||||
getData(fn: any, ip?: any): any;
|
||||
getDescription(fn: any, ip?: any): any;
|
||||
getNumTriesRemaining(fn: any, ip?: any): any;
|
||||
}
|
||||
import { CodingContract as ICodingContract } from "../ScriptEditor/NetscriptDefinitions";
|
||||
|
||||
export function NetscriptCodingContract(
|
||||
player: IPlayer,
|
||||
workerScript: WorkerScript,
|
||||
helper: INetscriptHelper,
|
||||
): INetscriptCodingContract {
|
||||
): ICodingContract {
|
||||
const getCodingContract = function (func: any, ip: any, fn: any): CodingContract {
|
||||
const server = helper.getServer(ip, func);
|
||||
const contract = server.getContract(fn);
|
||||
|
||||
@@ -28,6 +28,7 @@ import {
|
||||
calculateWeakenTime,
|
||||
} from "../Hacking";
|
||||
import { Programs } from "../Programs/Programs";
|
||||
import { Formulas as IFormulas } from "../ScriptEditor/NetscriptDefinitions";
|
||||
|
||||
export interface INetscriptFormulas {
|
||||
skills: {
|
||||
@@ -63,11 +64,7 @@ export interface INetscriptFormulas {
|
||||
};
|
||||
}
|
||||
|
||||
export function NetscriptFormulas(
|
||||
player: IPlayer,
|
||||
workerScript: WorkerScript,
|
||||
helper: INetscriptHelper,
|
||||
): INetscriptFormulas {
|
||||
export function NetscriptFormulas(player: IPlayer, workerScript: WorkerScript, helper: INetscriptHelper): IFormulas {
|
||||
const checkFormulasAccess = function (func: string): void {
|
||||
if (!player.hasProgram(Programs.Formulas.name)) {
|
||||
throw helper.makeRuntimeErrorMsg(`formulas.${func}`, `Requires Formulas.exe to run.`);
|
||||
|
||||
@@ -9,30 +9,9 @@ import { WorkerScript } from "../Netscript/WorkerScript";
|
||||
import { GangMember } from "../Gang/GangMember";
|
||||
import { GangMemberTask } from "../Gang/GangMemberTask";
|
||||
|
||||
export interface INetscriptGang {
|
||||
createGang(faction: string): boolean;
|
||||
inGang(): boolean;
|
||||
getMemberNames(): string[];
|
||||
getGangInformation(): any;
|
||||
getOtherGangInformation(): any;
|
||||
getMemberInformation(name: string): any;
|
||||
canRecruitMember(): boolean;
|
||||
recruitMember(name: string): boolean;
|
||||
getTaskNames(): string[];
|
||||
setMemberTask(memberName: string, taskName: string): boolean;
|
||||
getTaskStats(taskName: string): any;
|
||||
getEquipmentNames(): string[];
|
||||
getEquipmentCost(equipName: string): number;
|
||||
getEquipmentType(equipName: string): string;
|
||||
getEquipmentStats(equipName: string): any;
|
||||
purchaseEquipment(memberName: string, equipName: string): any;
|
||||
ascendMember(name: string): any;
|
||||
setTerritoryWarfare(engage: boolean): void;
|
||||
getChanceToWinClash(otherGang: string): number;
|
||||
getBonusTime(): number;
|
||||
}
|
||||
import { Gang as IGang } from "../ScriptEditor/NetscriptDefinitions";
|
||||
|
||||
export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helper: INetscriptHelper): INetscriptGang {
|
||||
export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helper: INetscriptHelper): IGang {
|
||||
const checkGangApiAccess = function (func: string): void {
|
||||
const gang = player.gang;
|
||||
if (gang === null) throw new Error("Must have joined gang");
|
||||
|
||||
@@ -18,34 +18,9 @@ import { HacknetServer } from "../Hacknet/HacknetServer";
|
||||
import { HacknetNode } from "../Hacknet/HacknetNode";
|
||||
import { GetServer } from "../Server/AllServers";
|
||||
|
||||
export interface INetscriptHacknet {
|
||||
numNodes(): number;
|
||||
maxNumNodes(): number;
|
||||
purchaseNode(): any;
|
||||
getPurchaseNodeCost(): number;
|
||||
getNodeStats(i: number): any;
|
||||
upgradeLevel(i: number, n: number): boolean;
|
||||
upgradeRam(i: number, n: number): boolean;
|
||||
upgradeCore(i: number, n: number): boolean;
|
||||
upgradeCache(i: number, n: number): boolean;
|
||||
getLevelUpgradeCost(i: number, n: number): number;
|
||||
getRamUpgradeCost(i: number, n: number): number;
|
||||
getCoreUpgradeCost(i: number, n: number): number;
|
||||
getCacheUpgradeCost(i: number, n: number): number;
|
||||
numHashes(): number;
|
||||
hashCapacity(): number;
|
||||
hashCost(upgName: string): number;
|
||||
spendHashes(upgName: string, upgTarget: string): any;
|
||||
getHashUpgradeLevel(upgName: string): number;
|
||||
getStudyMult(): number;
|
||||
getTrainingMult(): number;
|
||||
}
|
||||
import { Hacknet as IHacknet } from "../ScriptEditor/NetscriptDefinitions";
|
||||
|
||||
export function NetscriptHacknet(
|
||||
player: IPlayer,
|
||||
workerScript: WorkerScript,
|
||||
helper: INetscriptHelper,
|
||||
): INetscriptHacknet {
|
||||
export function NetscriptHacknet(player: IPlayer, workerScript: WorkerScript, helper: INetscriptHelper): IHacknet {
|
||||
// Utility function to get Hacknet Node object
|
||||
const getHacknetNode = function (i: any, callingFn = ""): HacknetNode | HacknetServer {
|
||||
if (isNaN(i)) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { BaseServer } from "../Server/BaseServer";
|
||||
import { Faction } from "../Faction/Faction";
|
||||
|
||||
export interface INetscriptHelper {
|
||||
updateDynamicRam(functionName: string, ram: number): void;
|
||||
@@ -9,5 +8,5 @@ export interface INetscriptHelper {
|
||||
boolean(v: any): boolean;
|
||||
getServer(ip: any, fn: any): BaseServer;
|
||||
checkSingularityAccess(func: string, n: number): void;
|
||||
getFaction(func: string, name: string): Faction;
|
||||
hack(hostname: string, manual: boolean): Promise<number>;
|
||||
}
|
||||
|
||||
1219
src/NetscriptFunctions/Singularity.ts
Normal file
1219
src/NetscriptFunctions/Singularity.ts
Normal file
File diff suppressed because it is too large
Load Diff
@@ -10,47 +10,9 @@ import { Augmentations } from "../Augmentation/Augmentations";
|
||||
import { CityName } from "../Locations/data/CityNames";
|
||||
import { findCrime } from "../Crime/CrimeHelpers";
|
||||
|
||||
export interface INetscriptSleeve {
|
||||
getNumSleeves(): number;
|
||||
setToShockRecovery(sleeveNumber?: number): boolean;
|
||||
setToSynchronize(sleeveNumber?: number): boolean;
|
||||
setToCommitCrime(sleeveNumber?: number, crimeName?: string): boolean;
|
||||
setToUniversityCourse(sleeveNumber?: number, universityName?: string, className?: string): boolean;
|
||||
travel(sleeveNumber?: number, cityName?: string): boolean;
|
||||
setToCompanyWork(sleeveNumber?: number, companyName?: string): boolean;
|
||||
setToFactionWork(sleeveNumber?: number, factionName?: string, workType?: string): boolean;
|
||||
setToGymWorkout(sleeveNumber?: number, gymName?: string, stat?: string): boolean;
|
||||
getSleeveStats(sleeveNumber?: number): {
|
||||
shock: number;
|
||||
sync: number;
|
||||
hacking_skill: number;
|
||||
strength: number;
|
||||
defense: number;
|
||||
dexterity: number;
|
||||
agility: number;
|
||||
charisma: number;
|
||||
};
|
||||
getTask(sleeveNumber?: number): {
|
||||
task: string;
|
||||
crime: string;
|
||||
location: string;
|
||||
gymStatType: string;
|
||||
factionWorkType: string;
|
||||
};
|
||||
getInformation(sleeveNumber?: number): any;
|
||||
getSleeveAugmentations(sleeveNumber?: number): string[];
|
||||
getSleevePurchasableAugs(sleeveNumber?: number): {
|
||||
name: string;
|
||||
cost: number;
|
||||
}[];
|
||||
purchaseSleeveAug(sleeveNumber?: number, augName?: string): boolean;
|
||||
}
|
||||
import { Sleeve as ISleeve } from "../ScriptEditor/NetscriptDefinitions";
|
||||
|
||||
export function NetscriptSleeve(
|
||||
player: IPlayer,
|
||||
workerScript: WorkerScript,
|
||||
helper: INetscriptHelper,
|
||||
): INetscriptSleeve {
|
||||
export function NetscriptSleeve(player: IPlayer, workerScript: WorkerScript, helper: INetscriptHelper): ISleeve {
|
||||
const checkSleeveAPIAccess = function (func: any): void {
|
||||
if (player.bitNodeN !== 10 && !SourceFileFlags[10]) {
|
||||
throw helper.makeRuntimeErrorMsg(
|
||||
|
||||
767
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
767
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user