mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-17 06:48:42 +02:00
NETSCRIPT: ns.sleeve.getSleeve added. getPlayer and getSleeve can both be used for formulas. (#200)
* BREAKING CHANGE: Removed getSleeveStats and getSleeveInformation because this info is provided by getSleeve in a more usable form. * BREAKING CHANGE: Removed tor, inBladeburner, and hasCorporation fields from ns.getPlayer. Functionality still exists via added functions ns.hasTorRouter, ns.corporation.hasCorporation, and ns.bladeburner.inBladeburner. * Separated ns definitions for Person, Sleeve, and Player interfaces with both Player and Sleeve just extending Person. Added getSleeve, which provides a Sleeve object similar to getPlayer. * Renamed the sleeve ns layer's interface as sleeve lowercase because of name conflict. todo: May move all the ns layers interface names to lowercase for consistency * Added ns.formulas.work.crimeSuccessChance and reworked to allow both sleeve and player calculations. * Removed internal Person.getIntelligenceBonus function which was just a wrapper for calculateIntelligenceBonus. Any use of the former in formulas creates a conflict where ns-provided Person objects throw an error. * Renamed helpers.player to helpers.person for netscript person validation. Reduced number of fields validated due to Person being a smaller interface. * Fixed bug in bladeburner where Player multipliers and int were being used no matter which person was performing the task * Fixed leak of Player.jobs at ns.getPlayer * Person / Player / Sleeve classes now implement the netscript equivalent interfaces. Netscript helper for person no longer asserts that it's a real Person class member, only that it's a Person interface. Functions that use netscript persons have been changed to expect just a person interface to prevent needing this incorrect type assertion.
This commit is contained in:
@@ -78,6 +78,7 @@ import { ScriptDeath } from "./Netscript/ScriptDeath";
|
||||
import { getBitNodeMultipliers } from "./BitNode/BitNode";
|
||||
import { assert, arrayAssert, stringAssert, objectAssert } from "./utils/helpers/typeAssertion";
|
||||
import { CrimeType } from "./utils/WorkType";
|
||||
import { cloneDeep } from "lodash";
|
||||
|
||||
export const enums = {
|
||||
toast: ToastVariant,
|
||||
@@ -122,6 +123,7 @@ const base: InternalAPI<NS> = {
|
||||
helpers.log(ctx, () => `returned ${server.serversOnNetwork.length} connections for ${server.hostname}`);
|
||||
return out;
|
||||
},
|
||||
hasTorRouter: () => () => Player.hasTorRouter(),
|
||||
hack:
|
||||
(ctx) =>
|
||||
(_hostname, opts = {}) => {
|
||||
@@ -1806,10 +1808,10 @@ const base: InternalAPI<NS> = {
|
||||
},
|
||||
getPlayer: () => () => {
|
||||
const data = {
|
||||
hp: JSON.parse(JSON.stringify(Player.hp)),
|
||||
skills: JSON.parse(JSON.stringify(Player.skills)),
|
||||
exp: JSON.parse(JSON.stringify(Player.exp)),
|
||||
mults: JSON.parse(JSON.stringify(Player.mults)),
|
||||
hp: cloneDeep(Player.hp),
|
||||
skills: cloneDeep(Player.skills),
|
||||
exp: cloneDeep(Player.exp),
|
||||
mults: cloneDeep(Player.mults),
|
||||
numPeopleKilled: Player.numPeopleKilled,
|
||||
money: Player.money,
|
||||
city: Player.city,
|
||||
@@ -1818,14 +1820,10 @@ const base: InternalAPI<NS> = {
|
||||
totalPlaytime: Player.totalPlaytime,
|
||||
playtimeSinceLastAug: Player.playtimeSinceLastAug,
|
||||
playtimeSinceLastBitnode: Player.playtimeSinceLastBitnode,
|
||||
jobs: {},
|
||||
jobs: cloneDeep(Player.jobs),
|
||||
factions: Player.factions.slice(),
|
||||
tor: Player.hasTorRouter(),
|
||||
inBladeburner: Player.inBladeburner(),
|
||||
hasCorporation: Player.hasCorporation(),
|
||||
entropy: Player.entropy,
|
||||
};
|
||||
Object.assign(data.jobs, Player.jobs);
|
||||
return data;
|
||||
},
|
||||
getMoneySources: () => () => ({
|
||||
|
||||
Reference in New Issue
Block a user