diff --git a/src/Netscript/APIWrapper.ts b/src/Netscript/APIWrapper.ts index cb644b49b..58c892d4f 100644 --- a/src/Netscript/APIWrapper.ts +++ b/src/Netscript/APIWrapper.ts @@ -9,11 +9,12 @@ import { Settings } from "../Settings/Settings"; import { CONSTANTS } from "../Constants"; type ExternalFunction = (...args: any[]) => any; -type ExternalAPI = { +export type ExternalAPI = { [string: string]: ExternalAPI | ExternalFunction; }; type InternalFunction unknown> = (ctx: NetscriptContext) => F; + export type InternalAPI = { [Property in keyof API]: API[Property] extends ExternalFunction ? InternalFunction diff --git a/src/Netscript/RamCostGenerator.ts b/src/Netscript/RamCostGenerator.ts index 620d67453..25549ae6f 100644 --- a/src/Netscript/RamCostGenerator.ts +++ b/src/Netscript/RamCostGenerator.ts @@ -443,6 +443,53 @@ export const RamCosts: IMap = { // Easter egg function break: 0, }, + + formulas: { + reputation: { + calculateFavorToRep: 0, + calculateRepToFavor: 0, + repFromDonation: 0, + }, + skills: { + calculateSkill: 0, + calculateExp: 0, + }, + hacking: { + hackChance: 0, + hackExp: 0, + hackPercent: 0, + growPercent: 0, + hackTime: 0, + growTime: 0, + weakenTime: 0, + }, + hacknetNodes: { + moneyGainRate: 0, + levelUpgradeCost: 0, + ramUpgradeCost: 0, + coreUpgradeCost: 0, + hacknetNodeCost: 0, + constants: 0, + }, + hacknetServers: { + hashGainRate: 0, + levelUpgradeCost: 0, + ramUpgradeCost: 0, + coreUpgradeCost: 0, + cacheUpgradeCost: 0, + hashUpgradeCost: 0, + hacknetServerCost: 0, + constants: 0, + }, + gang: { + wantedPenalty: 0, + respectGain: 0, + wantedLevelGain: 0, + moneyGain: 0, + ascensionPointsGain: 0, + ascensionMultiplier: 0, + }, + }, }; export function getRamCost(player: IPlayer, ...args: string[]): number { diff --git a/src/NetscriptFunctions.ts b/src/NetscriptFunctions.ts index 6fbb948fe..6dddccbe9 100644 --- a/src/NetscriptFunctions.ts +++ b/src/NetscriptFunctions.ts @@ -78,6 +78,7 @@ import { IPort } from "./NetscriptPort"; import { NS as INS, Singularity as ISingularity, + Formulas as IFormulas, Player as INetscriptPlayer, Gang as IGang, Bladeburner as IBladeburner, @@ -532,8 +533,9 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS { }; const extra = NetscriptExtra(Player, workerScript, helper); - const formulas = NetscriptFormulas(Player, workerScript, helper); + const formulas = wrapAPI(helper, {}, workerScript, NetscriptFormulas(Player, helper), "formulas") + .formulas as unknown as IFormulas; const gang = wrapAPI(helper, {}, workerScript, NetscriptGang(Player, workerScript), "gang").gang as unknown as IGang; const sleeve = wrapAPI(helper, {}, workerScript, NetscriptSleeve(Player), "sleeve").sleeve as unknown as ISleeve; const hacknet = wrapAPI(helper, {}, workerScript, NetscriptHacknet(Player, workerScript), "hacknet") diff --git a/src/NetscriptFunctions/Formulas.ts b/src/NetscriptFunctions/Formulas.ts index 9b5156dc5..2c8124ca0 100644 --- a/src/NetscriptFunctions/Formulas.ts +++ b/src/NetscriptFunctions/Formulas.ts @@ -41,11 +41,7 @@ import { favorToRep as calculateFavorToRep, repToFavor as calculateRepToFavor } import { repFromDonation } from "../Faction/formulas/donation"; import { InternalAPI, NetscriptContext } from "../Netscript/APIWrapper"; -export function NetscriptFormulas( - player: IPlayer, - workerScript: WorkerScript, - helper: INetscriptHelper, -): InternalAPI { +export function NetscriptFormulas(player: IPlayer, helper: INetscriptHelper): InternalAPI { const checkFormulasAccess = function (ctx: NetscriptContext): void { if (!player.hasProgram(Programs.Formulas.name)) { throw helper.makeRuntimeErrorMsg(`formulas.${ctx.function}`, `Requires Formulas.exe to run.`);