From cb1aa452a17ac4507490bd23874aa3de0671633a Mon Sep 17 00:00:00 2001 From: theit8514 Date: Thu, 2 Dec 2021 12:17:33 -0500 Subject: [PATCH 1/2] Move getOwnedSourceFiles to NetscriptFunctions --- dist/bitburner.d.ts | 2 -- src/NetscriptFunctions.ts | 12 ++++++++++- src/NetscriptFunctions/Singularity.ts | 12 ----------- src/ScriptEditor/NetscriptDefinitions.d.ts | 24 ++++++++++------------ 4 files changed, 22 insertions(+), 28 deletions(-) diff --git a/dist/bitburner.d.ts b/dist/bitburner.d.ts index a0e9948e8..703118331 100644 --- a/dist/bitburner.d.ts +++ b/dist/bitburner.d.ts @@ -4085,8 +4085,6 @@ export declare interface Singularity { * @remarks * RAM cost: 5 GB * - * Singularity - Level 3 - * * Returns an array of source files * * @returns Array containing an object with number and level of the source file. diff --git a/src/NetscriptFunctions.ts b/src/NetscriptFunctions.ts index f90cbc7ca..edbdd89e3 100644 --- a/src/NetscriptFunctions.ts +++ b/src/NetscriptFunctions.ts @@ -2150,7 +2150,17 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS { updateDynamicRam("getFavorToDonate", getRamCost("getFavorToDonate")); return Math.floor(CONSTANTS.BaseFavorToDonate * BitNodeMultipliers.RepToDonateToFaction); }, - + getOwnedSourceFiles: function (): any { + helper.updateDynamicRam("getOwnedSourceFiles", getRamCost("getOwnedSourceFiles")); + 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; + }, getPlayer: function (): INetscriptPlayer { helper.updateDynamicRam("getPlayer", getRamCost("getPlayer")); diff --git a/src/NetscriptFunctions/Singularity.ts b/src/NetscriptFunctions/Singularity.ts index 72b642126..270553867 100644 --- a/src/NetscriptFunctions/Singularity.ts +++ b/src/NetscriptFunctions/Singularity.ts @@ -105,18 +105,6 @@ export function NetscriptSingularity( } 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); diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index 2cf2b6233..0ebec0244 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -1747,19 +1747,6 @@ export interface Singularity { */ getOwnedAugmentations(purchased?: boolean): string[]; - /** - * Get a list of acquired Source-Files. - * @remarks - * RAM cost: 5 GB - * - * Singularity - Level 3 - * - * Returns an array of source files - * - * @returns Array containing an object with number and level of the source file. - */ - getOwnedSourceFiles(): SourceFileLvl[]; - /** * Get a list of augmentation available from a faction. * @remarks @@ -4978,6 +4965,17 @@ export interface NS extends Singularity { */ getBitNodeMultipliers(): BitNodeMultipliers; + /** + * Get a list of acquired Source-Files. + * @remarks + * RAM cost: 5 GB + * + * Returns an array of source files + * + * @returns Array containing an object with number and level of the source file. + */ + getOwnedSourceFiles(): SourceFileLvl[]; + /** * Get information about the player. * @returns Player info From 9b4e612be2f29762be9ff57e192465cabf872c18 Mon Sep 17 00:00:00 2001 From: theit8514 Date: Thu, 2 Dec 2021 12:32:10 -0500 Subject: [PATCH 2/2] Update return type --- src/NetscriptFunctions.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/NetscriptFunctions.ts b/src/NetscriptFunctions.ts index edbdd89e3..bc108d71e 100644 --- a/src/NetscriptFunctions.ts +++ b/src/NetscriptFunctions.ts @@ -63,7 +63,7 @@ import { NetscriptGang } from "./NetscriptFunctions/Gang"; import { NetscriptSleeve } from "./NetscriptFunctions/Sleeve"; import { NetscriptExtra } from "./NetscriptFunctions/Extra"; import { NetscriptHacknet } from "./NetscriptFunctions/Hacknet"; -import { NS as INS, Player as INetscriptPlayer } from "./ScriptEditor/NetscriptDefinitions"; +import { NS as INS, Player as INetscriptPlayer, SourceFileLvl } from "./ScriptEditor/NetscriptDefinitions"; import { NetscriptBladeburner } from "./NetscriptFunctions/Bladeburner"; import { NetscriptCodingContract } from "./NetscriptFunctions/CodingContract"; import { NetscriptCorporation } from "./NetscriptFunctions/Corporation"; @@ -2150,14 +2150,14 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS { updateDynamicRam("getFavorToDonate", getRamCost("getFavorToDonate")); return Math.floor(CONSTANTS.BaseFavorToDonate * BitNodeMultipliers.RepToDonateToFaction); }, - getOwnedSourceFiles: function (): any { + getOwnedSourceFiles: function (): SourceFileLvl[] { helper.updateDynamicRam("getOwnedSourceFiles", getRamCost("getOwnedSourceFiles")); - const res = []; + const res: SourceFileLvl[] = []; for (let i = 0; i < Player.sourceFiles.length; ++i) { res.push({ n: Player.sourceFiles[i].n, lvl: Player.sourceFiles[i].lvl, - }); + } as SourceFileLvl); } return res; },