diff --git a/src/Netscript/RamCostGenerator.ts b/src/Netscript/RamCostGenerator.ts index 9c72aecea..e5f5d266a 100644 --- a/src/Netscript/RamCostGenerator.ts +++ b/src/Netscript/RamCostGenerator.ts @@ -54,6 +54,7 @@ export const RamCostConstants: Record = { ScriptCodingContractBaseRamCost: 10, ScriptSleeveBaseRamCost: 4, ScriptClearTerminalCost: 0.2, + ScriptGetMoneySourcesCost: 1.0, ScriptSingularityFn1RamCost: 2, ScriptSingularityFn2RamCost: 3, @@ -528,6 +529,7 @@ export const RamCosts: RamCostTree> = { wget: 0, getFavorToDonate: RamCostConstants.ScriptGetFavorToDonate, getPlayer: RamCostConstants.ScriptSingularityFn1RamCost / 4, + getMoneySources: RamCostConstants.ScriptGetMoneySourcesCost, mv: 0, tail: 0, toast: 0, diff --git a/src/NetscriptFunctions.ts b/src/NetscriptFunctions.ts index 56b210599..f6cb3694a 100644 --- a/src/NetscriptFunctions.ts +++ b/src/NetscriptFunctions.ts @@ -61,7 +61,14 @@ import { NetscriptCorporation } from "./NetscriptFunctions/Corporation"; import { NetscriptFormulas } from "./NetscriptFunctions/Formulas"; import { NetscriptStockMarket } from "./NetscriptFunctions/StockMarket"; import { NetscriptGrafting } from "./NetscriptFunctions/Grafting"; -import { NS, RecentScript as IRecentScript, BasicHGWOptions, ProcessInfo } from "./ScriptEditor/NetscriptDefinitions"; +import { + NS, + RecentScript as IRecentScript, + BasicHGWOptions, + ProcessInfo, + MoneySource as IMoneySource, + MoneySources as IMoneySources, +} from "./ScriptEditor/NetscriptDefinitions"; import { NetscriptSingularity } from "./NetscriptFunctions/Singularity"; import { dialogBoxCreate } from "./ui/React/DialogBox"; @@ -1828,6 +1835,51 @@ const base: InternalAPI = { Object.assign(data.jobs, Player.jobs); return data; }, + getMoneySources: () => (): IMoneySources => { + const sinceInstall: IMoneySource = { + bladeburner: Player.moneySourceA.bladeburner, + casino: Player.moneySourceA.casino, + class: Player.moneySourceA.class, + codingcontract: Player.moneySourceA.codingcontract, + corporation: Player.moneySourceA.corporation, + crime: Player.moneySourceA.crime, + gang: Player.moneySourceA.gang, + hacking: Player.moneySourceA.hacking, + hacknet: Player.moneySourceA.hacknet, + hacknet_expenses: Player.moneySourceA.hacknet_expenses, + hospitalization: Player.moneySourceA.hospitalization, + infiltration: Player.moneySourceA.infiltration, + sleeves: Player.moneySourceA.sleeves, + stock: Player.moneySourceA.stock, + total: Player.moneySourceA.total, + work: Player.moneySourceA.work, + servers: Player.moneySourceA.servers, + other: Player.moneySourceA.other, + augmentations: Player.moneySourceA.augmentations, + }; + const sinceStart: IMoneySource = { + bladeburner: Player.moneySourceB.bladeburner, + casino: Player.moneySourceB.casino, + class: Player.moneySourceB.class, + codingcontract: Player.moneySourceB.codingcontract, + corporation: Player.moneySourceB.corporation, + crime: Player.moneySourceB.crime, + gang: Player.moneySourceB.gang, + hacking: Player.moneySourceB.hacking, + hacknet: Player.moneySourceB.hacknet, + hacknet_expenses: Player.moneySourceB.hacknet_expenses, + hospitalization: Player.moneySourceB.hospitalization, + infiltration: Player.moneySourceB.infiltration, + sleeves: Player.moneySourceB.sleeves, + stock: Player.moneySourceB.stock, + total: Player.moneySourceB.total, + work: Player.moneySourceB.work, + servers: Player.moneySourceB.servers, + other: Player.moneySourceB.other, + augmentations: Player.moneySourceB.augmentations, + }; + return { sinceInstall: sinceInstall, sinceStart: sinceStart }; + }, atExit: (ctx) => (f) => { if (typeof f !== "function") { throw helpers.makeRuntimeErrorMsg(ctx, "argument should be function"); diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index 3f27083f6..4010bb387 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -61,6 +61,35 @@ interface Player { entropy: number; } +/** @public */ +interface MoneySource { + bladeburner: number; + casino: number; + class: number; + codingcontract: number; + corporation: number; + crime: number; + gang: number; + hacking: number; + hacknet: number; + hacknet_expenses: number; + hospitalization: number; + infiltration: number; + sleeves: number; + stock: number; + total: number; + work: number; + servers: number; + other: number; + augmentations: number; +} + +/** @public */ +interface MoneySources { + sinceInstall: MoneySource; + sinceStart: MoneySource; +} + /** @public */ export interface Multipliers { /** Multiplier to hacking skill */ @@ -6692,6 +6721,17 @@ export interface NS { */ getPlayer(): Player; + /** + * Get information about the sources of income for this run. + * @remarks + * RAM cost: 1.0 GB + * + * Returns an object with information on the income sources for this run + * + * @returns Money sources + */ + getMoneySources(): MoneySources; + /** * Add callback function when the script dies * @remarks