mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-02 13:57:05 +02:00
NETSCRIPT: Add ns.formulas.work.companyGains function (#195)
* added ns.formulas.work.companyGains. * Removed Work/Formulas folder, added Work/Formulas.ts * CompanyPosition.calculateJobPerformance now takes in a Person instead of taking in a full set of stats, and it takes INT into account. * formulas.crimeGains takes in a person object. * Renamed ns Player type to Person. * added multWorkStats, which multiplies a WorkStats object with a multipliers object. * Remove unused types in NetscriptDefinitons.d.ts * reuse formulas code in other parts of game * getSleeveInformation also returns skills Co-authored-by: Alexey <alexey.kozhemiakin@gmail.com>
This commit is contained in:
+19
-13
@@ -1,5 +1,6 @@
|
||||
import { Person } from "src/PersonObjects/Person";
|
||||
import { Player } from "@player";
|
||||
import { Multipliers } from "../PersonObjects/Multipliers";
|
||||
|
||||
export interface WorkStats {
|
||||
money: number;
|
||||
@@ -13,19 +14,7 @@ export interface WorkStats {
|
||||
intExp: number;
|
||||
}
|
||||
|
||||
interface newWorkStatsParams {
|
||||
money?: number;
|
||||
reputation?: number;
|
||||
hackExp?: number;
|
||||
strExp?: number;
|
||||
defExp?: number;
|
||||
dexExp?: number;
|
||||
agiExp?: number;
|
||||
chaExp?: number;
|
||||
intExp?: number;
|
||||
}
|
||||
|
||||
export const newWorkStats = (params?: newWorkStatsParams): WorkStats => {
|
||||
export const newWorkStats = (params?: Partial<WorkStats>): WorkStats => {
|
||||
return {
|
||||
money: params?.money ?? 0,
|
||||
reputation: params?.reputation ?? 0,
|
||||
@@ -39,6 +28,7 @@ export const newWorkStats = (params?: newWorkStatsParams): WorkStats => {
|
||||
};
|
||||
};
|
||||
|
||||
/** Add two workStats objects */
|
||||
export const sumWorkStats = (w0: WorkStats, w1: WorkStats): WorkStats => {
|
||||
return {
|
||||
money: w0.money + w1.money,
|
||||
@@ -53,6 +43,7 @@ export const sumWorkStats = (w0: WorkStats, w1: WorkStats): WorkStats => {
|
||||
};
|
||||
};
|
||||
|
||||
/** Scale all stats on a WorkStats object by a number. Money scaling optional but defaults to true. */
|
||||
export const scaleWorkStats = (w: WorkStats, n: number, scaleMoney = true): WorkStats => {
|
||||
const m = scaleMoney ? n : 1;
|
||||
return {
|
||||
@@ -107,3 +98,18 @@ export const applyWorkStatsExp = (target: Person, workStats: WorkStats, cycles:
|
||||
target.gainIntelligenceExp(gains.intExp);
|
||||
return gains;
|
||||
};
|
||||
|
||||
/** Calculate the application of a person's multipliers to a WorkStats object */
|
||||
export function multWorkStats(workStats: Partial<WorkStats>, mults: Multipliers, moneyMult = 1, repMult = 1) {
|
||||
return {
|
||||
money: (workStats.money ?? 0) * moneyMult,
|
||||
reputation: (workStats.reputation ?? 0) * repMult,
|
||||
hackExp: (workStats.hackExp ?? 0) * mults.hacking_exp,
|
||||
strExp: (workStats.strExp ?? 0) * mults.strength_exp,
|
||||
defExp: (workStats.defExp ?? 0) * mults.defense_exp,
|
||||
dexExp: (workStats.dexExp ?? 0) * mults.dexterity_exp,
|
||||
agiExp: (workStats.agiExp ?? 0) * mults.agility_exp,
|
||||
chaExp: (workStats.chaExp ?? 0) * mults.charisma_exp,
|
||||
intExp: workStats.intExp ?? 0,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user