diff --git a/src/Netscript/RamCostGenerator.ts b/src/Netscript/RamCostGenerator.ts index 1b56ddd75..bf772b6b8 100644 --- a/src/Netscript/RamCostGenerator.ts +++ b/src/Netscript/RamCostGenerator.ts @@ -62,7 +62,6 @@ export const RamCostConstants: IMap = { ScriptGetFavorToDonate: 0.1, ScriptCodingContractBaseRamCost: 10, ScriptSleeveBaseRamCost: 4, - ScriptGetOwnedSourceFiles: 5, ScriptClearTerminalCost: 0.2, ScriptSingularityFn1RamCost: 2, @@ -191,6 +190,7 @@ const singularity = { getCrimeChance: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost), getCrimeStats: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost), getOwnedAugmentations: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost), + getOwnedSourceFiles: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost), getAugmentationsFromFaction: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost), getAugmentationCost: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost), getAugmentationPrereq: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost), @@ -519,7 +519,6 @@ const SourceRamCosts = { getFavorToDonate: RamCostConstants.ScriptGetFavorToDonate, getPlayer: RamCostConstants.ScriptSingularityFn1RamCost / 4, mv: 0, - getOwnedSourceFiles: RamCostConstants.ScriptGetOwnedSourceFiles, tail: 0, toast: 0, closeTail: 0, diff --git a/src/NetscriptFunctions.ts b/src/NetscriptFunctions.ts index 9b3bb0617..c022f1dad 100644 --- a/src/NetscriptFunctions.ts +++ b/src/NetscriptFunctions.ts @@ -2425,16 +2425,6 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS { getFavorToDonate: () => (): number => { return Math.floor(CONSTANTS.BaseFavorToDonate * BitNodeMultipliers.RepToDonateToFaction); }, - getOwnedSourceFiles: () => (): SourceFileLvl[] => { - const res: SourceFileLvl[] = []; - for (let i = 0; i < Player.sourceFiles.length; ++i) { - res.push({ - n: Player.sourceFiles[i].n, - lvl: Player.sourceFiles[i].lvl, - }); - } - return res; - }, getPlayer: () => (): INetscriptPlayer => { const data = { hacking: Player.hacking, diff --git a/src/NetscriptFunctions/Singularity.ts b/src/NetscriptFunctions/Singularity.ts index a4f5ad941..91f0dd391 100644 --- a/src/NetscriptFunctions/Singularity.ts +++ b/src/NetscriptFunctions/Singularity.ts @@ -17,6 +17,7 @@ import { CrimeStats, PlayerSkills, Singularity as ISingularity, + SourceFileLvl, } from "../ScriptEditor/NetscriptDefinitions"; import { findCrime } from "../Crime/CrimeHelpers"; @@ -114,6 +115,16 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript } return res; }, + getOwnedSourceFiles: () => (): SourceFileLvl[] => { + const res: SourceFileLvl[] = []; + for (let i = 0; i < player.sourceFiles.length; ++i) { + res.push({ + n: player.sourceFiles[i].n, + lvl: player.sourceFiles[i].lvl, + }); + } + return res; + }, getAugmentationsFromFaction: (_ctx: NetscriptContext) => function (_facName: unknown): string[] { _ctx.helper.checkSingularityAccess(); diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index 4358f82f8..c7316daa0 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -2081,6 +2081,17 @@ export interface Singularity { */ getOwnedAugmentations(purchased?: boolean): string[]; + /** + * 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 a list of augmentation available from a faction. * @remarks @@ -6446,17 +6457,6 @@ export interface NS { */ 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. * @remarks diff --git a/test/jest/Netscript/DynamicRamCalculation.test.js b/test/jest/Netscript/DynamicRamCalculation.test.js index 319a7ef2b..b34a99f87 100644 --- a/test/jest/Netscript/DynamicRamCalculation.test.js +++ b/test/jest/Netscript/DynamicRamCalculation.test.js @@ -623,13 +623,13 @@ describe("Netscript Dynamic RAM Calculation/Generation Tests", function () { await testNonzeroDynamicRamCost(f); }); - it("stock.buy()", async function () { - const f = ["stock", "buy"]; + it("stock.buyStock()", async function () { + const f = ["stock", "buyStock"]; await testNonzeroDynamicRamCost(f); }); - it("stock.sell()", async function () { - const f = ["stock", "sell"]; + it("stock.sellStock()", async function () { + const f = ["stock", "sellStock"]; await testNonzeroDynamicRamCost(f); }); @@ -681,187 +681,187 @@ describe("Netscript Dynamic RAM Calculation/Generation Tests", function () { describe("Singularity Functions", function () { it("universityCourse()", async function () { - const f = ["universityCourse"]; + const f = ["singularity", "universityCourse"]; await testNonzeroDynamicRamCost(f); }); it("gymWorkout()", async function () { - const f = ["gymWorkout"]; + const f = ["singularity", "gymWorkout"]; await testNonzeroDynamicRamCost(f); }); it("travelToCity()", async function () { - const f = ["travelToCity"]; + const f = ["singularity", "travelToCity"]; await testNonzeroDynamicRamCost(f); }); it("purchaseTor()", async function () { - const f = ["purchaseTor"]; + const f = ["singularity", "purchaseTor"]; await testNonzeroDynamicRamCost(f); }); it("purchaseProgram()", async function () { - const f = ["purchaseProgram"]; + const f = ["singularity", "purchaseProgram"]; await testNonzeroDynamicRamCost(f); }); it("getStats()", async function () { - const f = ["getStats"]; + const f = ["singularity", "getStats"]; await testNonzeroDynamicRamCost(f); }); it("getDarkwebProgramCost()", async function () { - const f = ["getDarkwebProgramCost"]; + const f = ["singularity", "getDarkwebProgramCost"]; await testNonzeroDynamicRamCost(f); }); it("getDarkwebPrograms()", async function () { - const f = ["getDarkwebPrograms"]; + const f = ["singularity", "getDarkwebPrograms"]; await testNonzeroDynamicRamCost(f); }); it("getCharacterInformation()", async function () { - const f = ["getCharacterInformation"]; + const f = ["singularity", "getCharacterInformation"]; await testNonzeroDynamicRamCost(f); }); it("isBusy()", async function () { - const f = ["isBusy"]; + const f = ["singularity", "isBusy"]; await testNonzeroDynamicRamCost(f); }); it("stopAction()", async function () { - const f = ["stopAction"]; + const f = ["singularity", "stopAction"]; await testNonzeroDynamicRamCost(f); }); it("upgradeHomeRam()", async function () { - const f = ["upgradeHomeRam"]; + const f = ["singularity", "upgradeHomeRam"]; await testNonzeroDynamicRamCost(f); }); it("getUpgradeHomeRamCost()", async function () { - const f = ["getUpgradeHomeRamCost"]; + const f = ["singularity", "getUpgradeHomeRamCost"]; await testNonzeroDynamicRamCost(f); }); it("workForCompany()", async function () { - const f = ["workForCompany"]; + const f = ["singularity", "workForCompany"]; await testNonzeroDynamicRamCost(f); }); it("applyToCompany()", async function () { - const f = ["applyToCompany"]; + const f = ["singularity", "applyToCompany"]; await testNonzeroDynamicRamCost(f); }); it("getCompanyRep()", async function () { - const f = ["getCompanyRep"]; + const f = ["singularity", "getCompanyRep"]; await testNonzeroDynamicRamCost(f); }); it("getCompanyFavor()", async function () { - const f = ["getCompanyFavor"]; + const f = ["singularity", "getCompanyFavor"]; await testNonzeroDynamicRamCost(f); }); it("getCompanyFavorGain()", async function () { - const f = ["getCompanyFavorGain"]; + const f = ["singularity", "getCompanyFavorGain"]; await testNonzeroDynamicRamCost(f); }); it("checkFactionInvitations()", async function () { - const f = ["checkFactionInvitations"]; + const f = ["singularity", "checkFactionInvitations"]; await testNonzeroDynamicRamCost(f); }); it("joinFaction()", async function () { - const f = ["joinFaction"]; + const f = ["singularity", "joinFaction"]; await testNonzeroDynamicRamCost(f); }); it("workForFaction()", async function () { - const f = ["workForFaction"]; + const f = ["singularity", "workForFaction"]; await testNonzeroDynamicRamCost(f); }); it("getFactionRep()", async function () { - const f = ["getFactionRep"]; + const f = ["singularity", "getFactionRep"]; await testNonzeroDynamicRamCost(f); }); it("getFactionFavor()", async function () { - const f = ["getFactionFavor"]; + const f = ["singularity", "getFactionFavor"]; await testNonzeroDynamicRamCost(f); }); it("getFactionFavorGain()", async function () { - const f = ["getFactionFavorGain"]; + const f = ["singularity", "getFactionFavorGain"]; await testNonzeroDynamicRamCost(f); }); it("donateToFaction()", async function () { - const f = ["donateToFaction"]; + const f = ["singularity", "donateToFaction"]; await testNonzeroDynamicRamCost(f); }); it("createProgram()", async function () { - const f = ["createProgram"]; + const f = ["singularity", "createProgram"]; await testNonzeroDynamicRamCost(f); }); it("commitCrime()", async function () { - const f = ["commitCrime"]; + const f = ["singularity", "commitCrime"]; await testNonzeroDynamicRamCost(f); }); it("getCrimeChance()", async function () { - const f = ["getCrimeChance"]; + const f = ["singularity", "getCrimeChance"]; await testNonzeroDynamicRamCost(f); }); it("getOwnedAugmentations()", async function () { - const f = ["getOwnedAugmentations"]; + const f = ["singularity", "getOwnedAugmentations"]; await testNonzeroDynamicRamCost(f); }); it("getOwnedSourceFiles()", async function () { - const f = ["getOwnedSourceFiles"]; + const f = ["singularity", "getOwnedSourceFiles"]; await testNonzeroDynamicRamCost(f); }); it("getAugmentationsFromFaction()", async function () { - const f = ["getAugmentationsFromFaction"]; + const f = ["singularity", "getAugmentationsFromFaction"]; await testNonzeroDynamicRamCost(f); }); it("getAugmentationCost()", async function () { - const f = ["getAugmentationCost"]; + const f = ["singularity", "getAugmentationCost"]; await testNonzeroDynamicRamCost(f); }); it("getAugmentationPrereq()", async function () { - const f = ["getAugmentationPrereq"]; + const f = ["singularity", "getAugmentationPrereq"]; await testNonzeroDynamicRamCost(f); }); it("getAugmentationPrice()", async function () { - const f = ["getAugmentationPrice"]; + const f = ["singularity", "getAugmentationPrice"]; await testNonzeroDynamicRamCost(f); }); it("getAugmentationRepReq()", async function () { - const f = ["getAugmentationRepReq"]; + const f = ["singularity", "getAugmentationRepReq"]; await testNonzeroDynamicRamCost(f); }); it("purchaseAugmentation()", async function () { - const f = ["purchaseAugmentation"]; + const f = ["singularity", "purchaseAugmentation"]; await testNonzeroDynamicRamCost(f); }); it("installAugmentations()", async function () { - const f = ["installAugmentations"]; + const f = ["singularity", "installAugmentations"]; await testNonzeroDynamicRamCost(f); }); }); diff --git a/test/jest/Netscript/StaticRamCalculation.test.js b/test/jest/Netscript/StaticRamCalculation.test.js index d248047a8..2288cd2b1 100644 --- a/test/jest/Netscript/StaticRamCalculation.test.js +++ b/test/jest/Netscript/StaticRamCalculation.test.js @@ -591,13 +591,13 @@ describe("Netscript Static RAM Calculation/Generation Tests", function () { await expectNonZeroRamCost(f); }); - it("stock.buy()", async function () { - const f = ["stock", "buy"]; + it("stock.buyStock()", async function () { + const f = ["stock", "buyStock"]; await expectNonZeroRamCost(f); }); - it("stock.sell()", async function () { - const f = ["stock", "sell"]; + it("stock.sellStock()", async function () { + const f = ["stock", "sellStock"]; await expectNonZeroRamCost(f); }); @@ -607,7 +607,7 @@ describe("Netscript Static RAM Calculation/Generation Tests", function () { }); it("stock.sellShort()", async function () { - const f = ["stock", "sell"]; + const f = ["stock", "sellShort"]; await expectNonZeroRamCost(f); }); diff --git a/test/jest/StockMarket.test.ts b/test/jest/StockMarket.test.ts index 6cab27121..7b1e03df4 100644 --- a/test/jest/StockMarket.test.ts +++ b/test/jest/StockMarket.test.ts @@ -457,13 +457,13 @@ describe("Stock Market Tests", function () { it("should trigger a price update when it has enough cycles", function () { // Get the initial prices - const initialValues: IMap = {}; + const initialValues: IMap = {}; for (const stockName in StockMarket) { const stock = StockMarket[stockName]; if (!(stock instanceof Stock)) { continue; } - initialValues[stock.symbol] = stock; + initialValues[stock.symbol] = { ...stock }; } // Don't know or care how many exact cycles are required