mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-22 15:42:05 +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:
@@ -40,8 +40,9 @@ import { SleeveSupportWork } from "./Work/SleeveSupportWork";
|
||||
import { SleeveBladeburnerWork } from "./Work/SleeveBladeburnerWork";
|
||||
import { SleeveCrimeWork } from "./Work/SleeveCrimeWork";
|
||||
import * as sleeveMethods from "./SleeveMethods";
|
||||
import { Sleeve as ISleeve } from "../../ScriptEditor/NetscriptDefinitions";
|
||||
|
||||
export class Sleeve extends Person {
|
||||
export class Sleeve extends Person implements ISleeve {
|
||||
currentWork: Work | null = null;
|
||||
|
||||
/** Clone retains 'memory' synchronization (and maybe exp?) upon prestige/installing Augs */
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Player } from "@player";
|
||||
import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../../../utils/JSONReviver";
|
||||
import { Sleeve } from "../Sleeve";
|
||||
import { Work, WorkType } from "./Work";
|
||||
import { calculateIntelligenceBonus } from "../../formulas/intelligence";
|
||||
|
||||
export const isSleeveSynchroWork = (w: Work | null): w is SleeveSynchroWork =>
|
||||
w !== null && w.type === WorkType.SYNCHRO;
|
||||
@@ -12,7 +13,10 @@ export class SleeveSynchroWork extends Work {
|
||||
}
|
||||
|
||||
process(sleeve: Sleeve, cycles: number): number {
|
||||
sleeve.sync = Math.min(100, sleeve.sync + Player.getIntelligenceBonus(0.5) * 0.0002 * cycles);
|
||||
sleeve.sync = Math.min(
|
||||
100,
|
||||
sleeve.sync + calculateIntelligenceBonus(Player.skills.intelligence, 0.5) * 0.0002 * cycles,
|
||||
);
|
||||
if (sleeve.sync >= 100) sleeve.stopWork();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ import React from "react";
|
||||
|
||||
import { Typography, Table, TableBody, TableCell, TableRow } from "@mui/material";
|
||||
|
||||
import { CONSTANTS } from "../../../Constants";
|
||||
|
||||
import { numeralWrapper } from "../../../ui/numeralFormat";
|
||||
import { Settings } from "../../../Settings/Settings";
|
||||
import { StatsRow } from "../../../ui/React/StatsRow";
|
||||
@@ -15,7 +17,8 @@ import { isSleeveClassWork } from "../Work/SleeveClassWork";
|
||||
import { isSleeveFactionWork } from "../Work/SleeveFactionWork";
|
||||
import { isSleeveCompanyWork } from "../Work/SleeveCompanyWork";
|
||||
import { isSleeveCrimeWork } from "../Work/SleeveCrimeWork";
|
||||
import { BitNodeMultipliers } from "../../../BitNode/BitNodeMultipliers";
|
||||
|
||||
const CYCLES_PER_SEC = 1000 / CONSTANTS.MilliPerCycle;
|
||||
|
||||
interface IProps {
|
||||
sleeve: Sleeve;
|
||||
@@ -99,37 +102,37 @@ export function EarningsElement(props: IProps): React.ReactElement {
|
||||
if (isSleeveCrimeWork(props.sleeve.currentWork)) {
|
||||
const gains = props.sleeve.currentWork.getExp(props.sleeve);
|
||||
data = [
|
||||
[`Money:`, <Money money={5 * gains.money} />],
|
||||
[`Hacking Exp:`, `${numeralWrapper.formatExp(5 * gains.hackExp)}`],
|
||||
[`Strength Exp:`, `${numeralWrapper.formatExp(5 * gains.strExp)}`],
|
||||
[`Defense Exp:`, `${numeralWrapper.formatExp(5 * gains.defExp)}`],
|
||||
[`Dexterity Exp:`, `${numeralWrapper.formatExp(5 * gains.dexExp)}`],
|
||||
[`Agility Exp:`, `${numeralWrapper.formatExp(5 * gains.agiExp)}`],
|
||||
[`Charisma Exp:`, `${numeralWrapper.formatExp(5 * gains.chaExp)}`],
|
||||
[`Money:`, <Money money={gains.money} />],
|
||||
[`Hacking Exp:`, `${numeralWrapper.formatExp(gains.hackExp)}`],
|
||||
[`Strength Exp:`, `${numeralWrapper.formatExp(gains.strExp)}`],
|
||||
[`Defense Exp:`, `${numeralWrapper.formatExp(gains.defExp)}`],
|
||||
[`Dexterity Exp:`, `${numeralWrapper.formatExp(gains.dexExp)}`],
|
||||
[`Agility Exp:`, `${numeralWrapper.formatExp(gains.agiExp)}`],
|
||||
[`Charisma Exp:`, `${numeralWrapper.formatExp(gains.chaExp)}`],
|
||||
];
|
||||
}
|
||||
if (isSleeveClassWork(props.sleeve.currentWork)) {
|
||||
const rates = props.sleeve.currentWork.calculateRates(props.sleeve);
|
||||
data = [
|
||||
[`Money:`, <MoneyRate money={5 * rates.money} />],
|
||||
[`Hacking Exp:`, `${numeralWrapper.formatExp(5 * rates.hackExp)} / sec`],
|
||||
[`Strength Exp:`, `${numeralWrapper.formatExp(5 * rates.strExp)} / sec`],
|
||||
[`Defense Exp:`, `${numeralWrapper.formatExp(5 * rates.defExp)} / sec`],
|
||||
[`Dexterity Exp:`, `${numeralWrapper.formatExp(5 * rates.dexExp)} / sec`],
|
||||
[`Agility Exp:`, `${numeralWrapper.formatExp(5 * rates.agiExp)} / sec`],
|
||||
[`Charisma Exp:`, `${numeralWrapper.formatExp(5 * rates.chaExp)} / sec`],
|
||||
[`Money:`, <MoneyRate money={CYCLES_PER_SEC * rates.money} />],
|
||||
[`Hacking Exp:`, `${numeralWrapper.formatExp(CYCLES_PER_SEC * rates.hackExp)} / sec`],
|
||||
[`Strength Exp:`, `${numeralWrapper.formatExp(CYCLES_PER_SEC * rates.strExp)} / sec`],
|
||||
[`Defense Exp:`, `${numeralWrapper.formatExp(CYCLES_PER_SEC * rates.defExp)} / sec`],
|
||||
[`Dexterity Exp:`, `${numeralWrapper.formatExp(CYCLES_PER_SEC * rates.dexExp)} / sec`],
|
||||
[`Agility Exp:`, `${numeralWrapper.formatExp(CYCLES_PER_SEC * rates.agiExp)} / sec`],
|
||||
[`Charisma Exp:`, `${numeralWrapper.formatExp(CYCLES_PER_SEC * rates.chaExp)} / sec`],
|
||||
];
|
||||
}
|
||||
if (isSleeveFactionWork(props.sleeve.currentWork)) {
|
||||
const rates = props.sleeve.currentWork.getExpRates(props.sleeve);
|
||||
const repGain = props.sleeve.currentWork.getReputationRate(props.sleeve);
|
||||
data = [
|
||||
[`Hacking Exp:`, `${numeralWrapper.formatExp(5 * rates.hackExp)} / sec`],
|
||||
[`Strength Exp:`, `${numeralWrapper.formatExp(5 * rates.strExp)} / sec`],
|
||||
[`Defense Exp:`, `${numeralWrapper.formatExp(5 * rates.defExp)} / sec`],
|
||||
[`Dexterity Exp:`, `${numeralWrapper.formatExp(5 * rates.dexExp)} / sec`],
|
||||
[`Agility Exp:`, `${numeralWrapper.formatExp(5 * rates.agiExp)} / sec`],
|
||||
[`Charisma Exp:`, `${numeralWrapper.formatExp(5 * rates.chaExp)} / sec`],
|
||||
[`Hacking Exp:`, `${numeralWrapper.formatExp(CYCLES_PER_SEC * rates.hackExp)} / sec`],
|
||||
[`Strength Exp:`, `${numeralWrapper.formatExp(CYCLES_PER_SEC * rates.strExp)} / sec`],
|
||||
[`Defense Exp:`, `${numeralWrapper.formatExp(CYCLES_PER_SEC * rates.defExp)} / sec`],
|
||||
[`Dexterity Exp:`, `${numeralWrapper.formatExp(CYCLES_PER_SEC * rates.dexExp)} / sec`],
|
||||
[`Agility Exp:`, `${numeralWrapper.formatExp(CYCLES_PER_SEC * rates.agiExp)} / sec`],
|
||||
[`Charisma Exp:`, `${numeralWrapper.formatExp(CYCLES_PER_SEC * rates.chaExp)} / sec`],
|
||||
[`Reputation:`, <ReputationRate reputation={repGain} />],
|
||||
];
|
||||
}
|
||||
@@ -137,14 +140,14 @@ export function EarningsElement(props: IProps): React.ReactElement {
|
||||
if (isSleeveCompanyWork(props.sleeve.currentWork)) {
|
||||
const rates = props.sleeve.currentWork.getGainRates(props.sleeve);
|
||||
data = [
|
||||
[`Money:`, <MoneyRate money={5 * rates.money * BitNodeMultipliers.CompanyWorkMoney} />],
|
||||
[`Hacking Exp:`, `${numeralWrapper.formatExp(5 * rates.hackExp)} / sec`],
|
||||
[`Strength Exp:`, `${numeralWrapper.formatExp(5 * rates.strExp)} / sec`],
|
||||
[`Defense Exp:`, `${numeralWrapper.formatExp(5 * rates.defExp)} / sec`],
|
||||
[`Dexterity Exp:`, `${numeralWrapper.formatExp(5 * rates.dexExp)} / sec`],
|
||||
[`Agility Exp:`, `${numeralWrapper.formatExp(5 * rates.agiExp)} / sec`],
|
||||
[`Charisma Exp:`, `${numeralWrapper.formatExp(5 * rates.chaExp)} / sec`],
|
||||
[`Reputation:`, <ReputationRate reputation={5 * rates.reputation} />],
|
||||
[`Money:`, <MoneyRate money={CYCLES_PER_SEC * rates.money} />],
|
||||
[`Hacking Exp:`, `${numeralWrapper.formatExp(CYCLES_PER_SEC * rates.hackExp)} / sec`],
|
||||
[`Strength Exp:`, `${numeralWrapper.formatExp(CYCLES_PER_SEC * rates.strExp)} / sec`],
|
||||
[`Defense Exp:`, `${numeralWrapper.formatExp(CYCLES_PER_SEC * rates.defExp)} / sec`],
|
||||
[`Dexterity Exp:`, `${numeralWrapper.formatExp(CYCLES_PER_SEC * rates.dexExp)} / sec`],
|
||||
[`Agility Exp:`, `${numeralWrapper.formatExp(CYCLES_PER_SEC * rates.agiExp)} / sec`],
|
||||
[`Charisma Exp:`, `${numeralWrapper.formatExp(CYCLES_PER_SEC * rates.chaExp)} / sec`],
|
||||
[`Reputation:`, <ReputationRate reputation={CYCLES_PER_SEC * rates.reputation} />],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -246,7 +246,7 @@ const canDo: {
|
||||
"Take University Course": (sleeve: Sleeve) =>
|
||||
[CityName.Aevum, CityName.Sector12, CityName.Volhaven].includes(sleeve.city),
|
||||
"Workout at Gym": (sleeve: Sleeve) => [CityName.Aevum, CityName.Sector12, CityName.Volhaven].includes(sleeve.city),
|
||||
"Perform Bladeburner Actions": () => Player.inBladeburner(),
|
||||
"Perform Bladeburner Actions": () => !!Player.bladeburner,
|
||||
"Shock Recovery": (sleeve: Sleeve) => sleeve.shock < 100,
|
||||
Synchronize: (sleeve: Sleeve) => sleeve.sync < 100,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user