mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-23 09:42:53 +02:00
NETSCRIPT: Expose more enums for player use (#198)
* Add support for enums at other ns layers * APIWrapper: simplified wrapping algorithm and modified to just use cloneDeep to copy enums instead of recursively wrapping enums as if they were new API layers * Improve APIWrapper typing * Changed some typings at RamCostGenerator to allow for enums at different levels without enums needing a ram cost * Added enums to ns.corporation, removed getter functions that were being used instead. * Add FactionWorkType for player use * Add ClassType and CompanyWorkPos enums * Change netscriptDefinitions to expect members of these new enums where appropriate.
This commit is contained in:
@@ -2,9 +2,12 @@ import { Player } from "@player";
|
||||
import { NSFull } from "../NetscriptFunctions";
|
||||
|
||||
/** This type assumes any value that isn't an API layer or a function has been omitted (args and enum) */
|
||||
type RamCostTree<API> = {
|
||||
[Property in keyof API]: API[Property] extends () => unknown ? number | (() => number) : RamCostTree<API[Property]>;
|
||||
};
|
||||
type RamCostTree<API> = Omit<
|
||||
{
|
||||
[Property in keyof API]: API[Property] extends () => unknown ? number | (() => number) : RamCostTree<API[Property]>;
|
||||
},
|
||||
"enums" | "args"
|
||||
>;
|
||||
|
||||
/** Constants for assigning costs to ns functions */
|
||||
export const RamCostConstants: Record<string, number> = {
|
||||
@@ -414,7 +417,7 @@ const corporation = {
|
||||
* An error will be generated if there are missing OR additional ram costs defined.
|
||||
* To avoid errors, define every function in NetscriptDefinition.d.ts and NetscriptFunctions,
|
||||
* and have a ram cost associated here. */
|
||||
export const RamCosts: RamCostTree<Omit<NSFull, "args" | "enums">> = {
|
||||
export const RamCosts: RamCostTree<NSFull> = {
|
||||
corporation,
|
||||
hacknet,
|
||||
stock,
|
||||
|
||||
Reference in New Issue
Block a user