diff --git a/dist/bitburner.d.ts b/dist/bitburner.d.ts index 15d87b134..b773a6ea2 100644 --- a/dist/bitburner.d.ts +++ b/dist/bitburner.d.ts @@ -1207,6 +1207,8 @@ export declare interface Formulas { hacknetServers: HacknetServersFormulas; /** Gang formulas */ gang: GangFormulas; + /** Work formulas */ + work: WorkFormulas; } /** @@ -7326,4 +7328,29 @@ export declare interface WarehouseAPI { hasWarehouse(adivisionName: string, acityName: string): boolean; } +/** + * Work formulas + * @public + */ +export declare interface WorkFormulas { + crimeGains(crimeType: string): WorkStats; + classGains(player: Player, classType: string, locationName: string): WorkStats; + factionGains(player: Player, workType: string, favor: number): WorkStats; +} + +/** + * @public + */ +export declare interface WorkStats { + money: number; + reputation: number; + hackExp: number; + strExp: number; + defExp: number; + dexExp: number; + agiExp: number; + chaExp: number; + intExp: number; +} + export { } diff --git a/markdown/bitburner.formulas.md b/markdown/bitburner.formulas.md index 04231ac35..358e50edc 100644 --- a/markdown/bitburner.formulas.md +++ b/markdown/bitburner.formulas.md @@ -26,4 +26,5 @@ You need Formulas.exe on your home computer to use this API. | [hacknetServers](./bitburner.formulas.hacknetservers.md) | [HacknetServersFormulas](./bitburner.hacknetserversformulas.md) | Hacknet Servers formulas | | [reputation](./bitburner.formulas.reputation.md) | [ReputationFormulas](./bitburner.reputationformulas.md) | Reputation formulas | | [skills](./bitburner.formulas.skills.md) | [SkillsFormulas](./bitburner.skillsformulas.md) | Skills formulas | +| [work](./bitburner.formulas.work.md) | [WorkFormulas](./bitburner.workformulas.md) | Work formulas | diff --git a/markdown/bitburner.formulas.work.md b/markdown/bitburner.formulas.work.md new file mode 100644 index 000000000..0ee012fb6 --- /dev/null +++ b/markdown/bitburner.formulas.work.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [bitburner](./bitburner.md) > [Formulas](./bitburner.formulas.md) > [work](./bitburner.formulas.work.md) + +## Formulas.work property + +Work formulas + +Signature: + +```typescript +work: WorkFormulas; +``` diff --git a/markdown/bitburner.md b/markdown/bitburner.md index ae4a91c55..33ba99900 100644 --- a/markdown/bitburner.md +++ b/markdown/bitburner.md @@ -91,6 +91,8 @@ | [UserInterface](./bitburner.userinterface.md) | User Interface API. | | [Warehouse](./bitburner.warehouse.md) | Warehouse for a division in a city | | [WarehouseAPI](./bitburner.warehouseapi.md) | Corporation Warehouse API | +| [WorkFormulas](./bitburner.workformulas.md) | Work formulas | +| [WorkStats](./bitburner.workstats.md) | | ## Type Aliases diff --git a/markdown/bitburner.workformulas.classgains.md b/markdown/bitburner.workformulas.classgains.md new file mode 100644 index 000000000..d75920601 --- /dev/null +++ b/markdown/bitburner.workformulas.classgains.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [bitburner](./bitburner.md) > [WorkFormulas](./bitburner.workformulas.md) > [classGains](./bitburner.workformulas.classgains.md) + +## WorkFormulas.classGains() method + +Signature: + +```typescript +classGains(player: Player, classType: string, locationName: string): WorkStats; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| player | [Player](./bitburner.player.md) | | +| classType | string | | +| locationName | string | | + +Returns: + +[WorkStats](./bitburner.workstats.md) + diff --git a/markdown/bitburner.workformulas.crimegains.md b/markdown/bitburner.workformulas.crimegains.md new file mode 100644 index 000000000..91487d0a8 --- /dev/null +++ b/markdown/bitburner.workformulas.crimegains.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [bitburner](./bitburner.md) > [WorkFormulas](./bitburner.workformulas.md) > [crimeGains](./bitburner.workformulas.crimegains.md) + +## WorkFormulas.crimeGains() method + +Signature: + +```typescript +crimeGains(crimeType: string): WorkStats; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| crimeType | string | | + +Returns: + +[WorkStats](./bitburner.workstats.md) + diff --git a/markdown/bitburner.workformulas.factiongains.md b/markdown/bitburner.workformulas.factiongains.md new file mode 100644 index 000000000..e8d6b5703 --- /dev/null +++ b/markdown/bitburner.workformulas.factiongains.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [bitburner](./bitburner.md) > [WorkFormulas](./bitburner.workformulas.md) > [factionGains](./bitburner.workformulas.factiongains.md) + +## WorkFormulas.factionGains() method + +Signature: + +```typescript +factionGains(player: Player, workType: string, favor: number): WorkStats; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| player | [Player](./bitburner.player.md) | | +| workType | string | | +| favor | number | | + +Returns: + +[WorkStats](./bitburner.workstats.md) + diff --git a/markdown/bitburner.workformulas.md b/markdown/bitburner.workformulas.md new file mode 100644 index 000000000..f1eaa6d07 --- /dev/null +++ b/markdown/bitburner.workformulas.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [bitburner](./bitburner.md) > [WorkFormulas](./bitburner.workformulas.md) + +## WorkFormulas interface + +Work formulas + +Signature: + +```typescript +interface WorkFormulas +``` + +## Methods + +| Method | Description | +| --- | --- | +| [classGains(player, classType, locationName)](./bitburner.workformulas.classgains.md) | | +| [crimeGains(crimeType)](./bitburner.workformulas.crimegains.md) | | +| [factionGains(player, workType, favor)](./bitburner.workformulas.factiongains.md) | | + diff --git a/markdown/bitburner.workstats.agiexp.md b/markdown/bitburner.workstats.agiexp.md new file mode 100644 index 000000000..ba80aa014 --- /dev/null +++ b/markdown/bitburner.workstats.agiexp.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [bitburner](./bitburner.md) > [WorkStats](./bitburner.workstats.md) > [agiExp](./bitburner.workstats.agiexp.md) + +## WorkStats.agiExp property + +Signature: + +```typescript +agiExp: number; +``` diff --git a/markdown/bitburner.workstats.chaexp.md b/markdown/bitburner.workstats.chaexp.md new file mode 100644 index 000000000..4c5a069c0 --- /dev/null +++ b/markdown/bitburner.workstats.chaexp.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [bitburner](./bitburner.md) > [WorkStats](./bitburner.workstats.md) > [chaExp](./bitburner.workstats.chaexp.md) + +## WorkStats.chaExp property + +Signature: + +```typescript +chaExp: number; +``` diff --git a/markdown/bitburner.workstats.defexp.md b/markdown/bitburner.workstats.defexp.md new file mode 100644 index 000000000..7f59581f7 --- /dev/null +++ b/markdown/bitburner.workstats.defexp.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [bitburner](./bitburner.md) > [WorkStats](./bitburner.workstats.md) > [defExp](./bitburner.workstats.defexp.md) + +## WorkStats.defExp property + +Signature: + +```typescript +defExp: number; +``` diff --git a/markdown/bitburner.workstats.dexexp.md b/markdown/bitburner.workstats.dexexp.md new file mode 100644 index 000000000..13e6a05e5 --- /dev/null +++ b/markdown/bitburner.workstats.dexexp.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [bitburner](./bitburner.md) > [WorkStats](./bitburner.workstats.md) > [dexExp](./bitburner.workstats.dexexp.md) + +## WorkStats.dexExp property + +Signature: + +```typescript +dexExp: number; +``` diff --git a/markdown/bitburner.workstats.hackexp.md b/markdown/bitburner.workstats.hackexp.md new file mode 100644 index 000000000..90be2da13 --- /dev/null +++ b/markdown/bitburner.workstats.hackexp.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [bitburner](./bitburner.md) > [WorkStats](./bitburner.workstats.md) > [hackExp](./bitburner.workstats.hackexp.md) + +## WorkStats.hackExp property + +Signature: + +```typescript +hackExp: number; +``` diff --git a/markdown/bitburner.workstats.intexp.md b/markdown/bitburner.workstats.intexp.md new file mode 100644 index 000000000..75cdd9827 --- /dev/null +++ b/markdown/bitburner.workstats.intexp.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [bitburner](./bitburner.md) > [WorkStats](./bitburner.workstats.md) > [intExp](./bitburner.workstats.intexp.md) + +## WorkStats.intExp property + +Signature: + +```typescript +intExp: number; +``` diff --git a/markdown/bitburner.workstats.md b/markdown/bitburner.workstats.md new file mode 100644 index 000000000..40d9f7d56 --- /dev/null +++ b/markdown/bitburner.workstats.md @@ -0,0 +1,27 @@ + + +[Home](./index.md) > [bitburner](./bitburner.md) > [WorkStats](./bitburner.workstats.md) + +## WorkStats interface + + +Signature: + +```typescript +export interface WorkStats +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [agiExp](./bitburner.workstats.agiexp.md) | number | | +| [chaExp](./bitburner.workstats.chaexp.md) | number | | +| [defExp](./bitburner.workstats.defexp.md) | number | | +| [dexExp](./bitburner.workstats.dexexp.md) | number | | +| [hackExp](./bitburner.workstats.hackexp.md) | number | | +| [intExp](./bitburner.workstats.intexp.md) | number | | +| [money](./bitburner.workstats.money.md) | number | | +| [reputation](./bitburner.workstats.reputation.md) | number | | +| [strExp](./bitburner.workstats.strexp.md) | number | | + diff --git a/markdown/bitburner.workstats.money.md b/markdown/bitburner.workstats.money.md new file mode 100644 index 000000000..8e3a44b42 --- /dev/null +++ b/markdown/bitburner.workstats.money.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [bitburner](./bitburner.md) > [WorkStats](./bitburner.workstats.md) > [money](./bitburner.workstats.money.md) + +## WorkStats.money property + +Signature: + +```typescript +money: number; +``` diff --git a/markdown/bitburner.workstats.reputation.md b/markdown/bitburner.workstats.reputation.md new file mode 100644 index 000000000..a39fb3ea9 --- /dev/null +++ b/markdown/bitburner.workstats.reputation.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [bitburner](./bitburner.md) > [WorkStats](./bitburner.workstats.md) > [reputation](./bitburner.workstats.reputation.md) + +## WorkStats.reputation property + +Signature: + +```typescript +reputation: number; +``` diff --git a/markdown/bitburner.workstats.strexp.md b/markdown/bitburner.workstats.strexp.md new file mode 100644 index 000000000..de3254e40 --- /dev/null +++ b/markdown/bitburner.workstats.strexp.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [bitburner](./bitburner.md) > [WorkStats](./bitburner.workstats.md) > [strExp](./bitburner.workstats.strexp.md) + +## WorkStats.strExp property + +Signature: + +```typescript +strExp: number; +``` diff --git a/src/Faction/FactionHelpers.tsx b/src/Faction/FactionHelpers.tsx index bfc42e891..882cba6b7 100644 --- a/src/Faction/FactionHelpers.tsx +++ b/src/Faction/FactionHelpers.tsx @@ -128,9 +128,9 @@ export function processPassiveFactionRepGain(numCycles: number): void { // 100 favor = 11%/s const favorMult = Math.min(0.1, faction.favor / 1000 + 0.01); // Find the best of all possible favor gain, minimum 1 rep / 2 minute. - const hRep = getHackingWorkRepGain(Player, faction); - const sRep = getFactionSecurityWorkRepGain(Player, faction); - const fRep = getFactionFieldWorkRepGain(Player, faction); + const hRep = getHackingWorkRepGain(Player, faction.favor); + const sRep = getFactionSecurityWorkRepGain(Player, faction.favor); + const fRep = getFactionFieldWorkRepGain(Player, faction.favor); const rate = Math.max(hRep * favorMult, sRep * favorMult, fRep * favorMult, 1 / 120); faction.playerReputation += rate * numCycles * Player.mults.faction_rep * BitNodeMultipliers.FactionPassiveRepGain; diff --git a/src/Netscript/RamCostGenerator.ts b/src/Netscript/RamCostGenerator.ts index 43c1b9498..a68173274 100644 --- a/src/Netscript/RamCostGenerator.ts +++ b/src/Netscript/RamCostGenerator.ts @@ -590,6 +590,11 @@ const SourceRamCosts = { ascensionPointsGain: 0, ascensionMultiplier: 0, }, + work: { + crimeGains: 0, + classGains: 0, + factionGains: 0, + }, }, }; diff --git a/src/NetscriptFunctions/Formulas.ts b/src/NetscriptFunctions/Formulas.ts index 3cc659d2e..fb5cae6ab 100644 --- a/src/NetscriptFunctions/Formulas.ts +++ b/src/NetscriptFunctions/Formulas.ts @@ -43,6 +43,14 @@ import { favorToRep as calculateFavorToRep, repToFavor as calculateRepToFavor } import { repFromDonation } from "../Faction/formulas/donation"; import { InternalAPI, NetscriptContext } from "../Netscript/APIWrapper"; import { helpers } from "../Netscript/NetscriptHelpers"; +import { WorkStats } from "../Work/WorkStats"; +import { calculateCrimeWorkStats } from "../Work/formulas/Crime"; +import { Crimes } from "../Crime/Crimes"; +import { calculateClassEarnings } from "../Work/formulas/Class"; +import { ClassType } from "../Work/ClassWork"; +import { LocationName } from "../Locations/data/LocationNames"; +import { calculateFactionExp, calculateFactionRep } from "../Work/formulas/Faction"; +import { FactionWorkType } from "../Work/data/FactionWorkType"; export function NetscriptFormulas(): InternalAPI { const checkFormulasAccess = function (ctx: NetscriptContext): void { @@ -326,5 +334,38 @@ export function NetscriptFormulas(): InternalAPI { return calculateAscensionMult(points); }, }, + work: { + crimeGains: + (ctx: NetscriptContext) => + (_crimeType: unknown): WorkStats => { + const crimeType = helpers.string(ctx, "crimeType", _crimeType); + const crime = Object.values(Crimes).find((c) => String(c.type) === crimeType); + if (!crime) throw new Error(`Invalid crime type: ${crimeType}`); + return calculateCrimeWorkStats(crime); + }, + classGains: + (ctx: NetscriptContext) => + (_player: unknown, _classType: unknown, _locationName: unknown): WorkStats => { + const target = helpers.player(ctx, _player); + const classType = helpers.string(ctx, "classType", _classType); + const locationName = helpers.string(ctx, "locationName", _locationName); + return calculateClassEarnings(player, target, classType as ClassType, locationName as LocationName); + }, + factionGains: + (ctx: NetscriptContext) => + (_player: unknown, _workType: unknown, _favor: unknown): WorkStats => { + const player = helpers.player(ctx, _player); + const workType = helpers.string(ctx, "_workType", _workType) as FactionWorkType; + const favor = helpers.number(ctx, "favor", _favor); + const exp = calculateFactionExp(player, workType); + const rep = calculateFactionRep(player, workType, favor); + exp.reputation = rep; + return exp; + }, + // companyGains: (ctx: NetscriptContext) =>_player: unknown (): WorkStats { + // const player = helpers.player(ctx, _player); + + // }, + }, }; } diff --git a/src/PersonObjects/Sleeve/Work/SleeveFactionWork.ts b/src/PersonObjects/Sleeve/Work/SleeveFactionWork.ts index 6223a863e..0cc7b5bae 100644 --- a/src/PersonObjects/Sleeve/Work/SleeveFactionWork.ts +++ b/src/PersonObjects/Sleeve/Work/SleeveFactionWork.ts @@ -43,7 +43,7 @@ export class SleeveFactionWork extends Work { [FactionWorkType.FIELD]: getFactionFieldWorkRepGain, [FactionWorkType.SECURITY]: getFactionSecurityWorkRepGain, }; - return repFormulas[this.factionWorkType](sleeve, faction) * sleeve.shockBonus(); + return repFormulas[this.factionWorkType](sleeve, faction.favor) * sleeve.shockBonus(); } getFaction(): Faction { diff --git a/src/PersonObjects/formulas/reputation.ts b/src/PersonObjects/formulas/reputation.ts index e404bdd5e..149d66733 100644 --- a/src/PersonObjects/formulas/reputation.ts +++ b/src/PersonObjects/formulas/reputation.ts @@ -1,28 +1,28 @@ -import { Faction } from "../../Faction/Faction"; import { CONSTANTS } from "../../Constants"; import { BitNodeMultipliers } from "../../BitNode/BitNodeMultipliers"; import { CalculateShareMult } from "../../NetworkShare/Share"; import { IPerson } from "../IPerson"; +import { calculateIntelligenceBonus } from "./intelligence"; -function mult(f: Faction): number { - let favorMult = 1 + f.favor / 100; +function mult(favor: number): number { + let favorMult = 1 + favor / 100; if (isNaN(favorMult)) { favorMult = 1; } return favorMult * BitNodeMultipliers.FactionWorkRepGain; } -export function getHackingWorkRepGain(p: IPerson, f: Faction): number { +export function getHackingWorkRepGain(p: IPerson, favor: number): number { return ( ((p.skills.hacking + p.skills.intelligence / 3) / CONSTANTS.MaxSkillLevel) * p.mults.faction_rep * - p.getIntelligenceBonus(1) * - mult(f) * + calculateIntelligenceBonus(p.skills.intelligence, 1) * + mult(favor) * CalculateShareMult() ); } -export function getFactionSecurityWorkRepGain(p: IPerson, f: Faction): number { +export function getFactionSecurityWorkRepGain(p: IPerson, favor: number): number { const t = (0.9 * (p.skills.strength + @@ -32,10 +32,10 @@ export function getFactionSecurityWorkRepGain(p: IPerson, f: Faction): number { (p.skills.hacking + p.skills.intelligence) * CalculateShareMult())) / CONSTANTS.MaxSkillLevel / 4.5; - return t * p.mults.faction_rep * mult(f) * p.getIntelligenceBonus(1); + return t * p.mults.faction_rep * mult(favor) * calculateIntelligenceBonus(p.skills.intelligence, 1); } -export function getFactionFieldWorkRepGain(p: IPerson, f: Faction): number { +export function getFactionFieldWorkRepGain(p: IPerson, favor: number): number { const t = (0.9 * (p.skills.strength + @@ -46,5 +46,5 @@ export function getFactionFieldWorkRepGain(p: IPerson, f: Faction): number { (p.skills.hacking + p.skills.intelligence) * CalculateShareMult())) / CONSTANTS.MaxSkillLevel / 5.5; - return t * p.mults.faction_rep * mult(f) * p.getIntelligenceBonus(1); + return t * p.mults.faction_rep * mult(favor) * calculateIntelligenceBonus(p.skills.intelligence, 1); } diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index b20415c1c..090267b1e 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -3850,6 +3850,31 @@ interface SkillsFormulas { calculateExp(skill: number, skillMult?: number): number; } +/** + * @public + */ +export interface WorkStats { + money: number; + reputation: number; + hackExp: number; + strExp: number; + defExp: number; + dexExp: number; + agiExp: number; + chaExp: number; + intExp: number; +} + +/** + * Work formulas + * @public + */ +interface WorkFormulas { + crimeGains(crimeType: string): WorkStats; + classGains(player: Player, classType: string, locationName: string): WorkStats; + factionGains(player: Player, workType: string, favor: number): WorkStats; +} + /** * Reputation formulas * @public @@ -4131,6 +4156,8 @@ export interface Formulas { hacknetServers: HacknetServersFormulas; /** Gang formulas */ gang: GangFormulas; + /** Work formulas */ + work: WorkFormulas; } /** diff --git a/src/Work/CrimeWork.ts b/src/Work/CrimeWork.ts index f91bcbd98..af4d9d711 100644 --- a/src/Work/CrimeWork.ts +++ b/src/Work/CrimeWork.ts @@ -9,6 +9,7 @@ import { CrimeType } from "../utils/WorkType"; import { Work, WorkType } from "./Work"; import { newWorkStats, scaleWorkStats, WorkStats } from "./WorkStats"; import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers"; +import { calculateCrimeWorkStats } from "./formulas/Crime"; enum newCrimeType { SHOPLIFT = "SHOPLIFT", @@ -90,23 +91,7 @@ export class CrimeWork extends Work { } earnings(): WorkStats { - const crime = this.getCrime(); - const gains = scaleWorkStats( - newWorkStats({ - money: crime.money, - hackExp: crime.hacking_exp * 2, - strExp: crime.strength_exp * 2, - defExp: crime.defense_exp * 2, - dexExp: crime.dexterity_exp * 2, - agiExp: crime.agility_exp * 2, - chaExp: crime.charisma_exp * 2, - intExp: crime.intelligence_exp * 2, - }), - BitNodeMultipliers.CrimeExpGain, - false, - ); - gains.money *= BitNodeMultipliers.CrimeMoney; - return gains; + return calculateCrimeWorkStats(this.getCrime()); } commit(player: IPlayer): void { diff --git a/src/Work/FactionWork.tsx b/src/Work/FactionWork.tsx index 5c0f67b19..d25ab67a5 100644 --- a/src/Work/FactionWork.tsx +++ b/src/Work/FactionWork.tsx @@ -8,14 +8,9 @@ import { Faction } from "../Faction/Faction"; import { applyWorkStats, scaleWorkStats, WorkStats } from "./WorkStats"; import { dialogBoxCreate } from "../ui/React/DialogBox"; import { Reputation } from "../ui/React/Reputation"; -import { - getFactionFieldWorkRepGain, - getFactionSecurityWorkRepGain, - getHackingWorkRepGain, -} from "../PersonObjects/formulas/reputation"; import { CONSTANTS } from "../Constants"; import { AugmentationNames } from "../Augmentation/data/AugmentationNames"; -import { calculateFactionExp } from "./formulas/Faction"; +import { calculateFactionExp, calculateFactionRep } from "./formulas/Faction"; import { FactionWorkType } from "./data/FactionWorkType"; interface FactionWorkParams { @@ -43,18 +38,11 @@ export class FactionWork extends Work { } getReputationRate(player: IPlayer): number { - const faction = this.getFaction(); - const repFormulas = { - [FactionWorkType.HACKING]: getHackingWorkRepGain, - [FactionWorkType.FIELD]: getFactionFieldWorkRepGain, - [FactionWorkType.SECURITY]: getFactionSecurityWorkRepGain, - }; - const rep = repFormulas[this.factionWorkType](player, faction); let focusBonus = 1; if (!player.hasAugmentation(AugmentationNames.NeuroreceptorManager)) { focusBonus = player.focus ? 1 : CONSTANTS.BaseFocusBonus; } - return rep * focusBonus; + return calculateFactionRep(player, this.factionWorkType, this.getFaction().favor) * focusBonus; } getExpRates(player: IPlayer): WorkStats { diff --git a/src/Work/formulas/Crime.ts b/src/Work/formulas/Crime.ts new file mode 100644 index 000000000..365bc7adc --- /dev/null +++ b/src/Work/formulas/Crime.ts @@ -0,0 +1,22 @@ +import { BitNodeMultipliers } from "../../BitNode/BitNodeMultipliers"; +import { Crime } from "src/Crime/Crime"; +import { newWorkStats, scaleWorkStats, WorkStats } from "../WorkStats"; + +export const calculateCrimeWorkStats = (crime: Crime): WorkStats => { + const gains = scaleWorkStats( + newWorkStats({ + money: crime.money, + hackExp: crime.hacking_exp * 2, + strExp: crime.strength_exp * 2, + defExp: crime.defense_exp * 2, + dexExp: crime.dexterity_exp * 2, + agiExp: crime.agility_exp * 2, + chaExp: crime.charisma_exp * 2, + intExp: crime.intelligence_exp * 2, + }), + BitNodeMultipliers.CrimeExpGain, + false, + ); + gains.money *= BitNodeMultipliers.CrimeMoney; + return gains; +}; diff --git a/src/Work/formulas/Faction.ts b/src/Work/formulas/Faction.ts index 409dc0d52..0a2913f38 100644 --- a/src/Work/formulas/Faction.ts +++ b/src/Work/formulas/Faction.ts @@ -3,6 +3,11 @@ import { BitNodeMultipliers } from "../../BitNode/BitNodeMultipliers"; import { CONSTANTS } from "../../Constants"; import { FactionWorkType } from "../data/FactionWorkType"; import { newWorkStats, WorkStats } from "../WorkStats"; +import { + getFactionFieldWorkRepGain, + getFactionSecurityWorkRepGain, + getHackingWorkRepGain, +} from "../../PersonObjects/formulas/reputation"; const gameCPS = 1000 / CONSTANTS._idleSpeed; // 5 cycles per second @@ -25,6 +30,15 @@ export const FactionWorkStats: Record = { }), }; +export const calculateFactionRep = (person: IPerson, tpe: FactionWorkType, favor: number): number => { + const repFormulas = { + [FactionWorkType.HACKING]: getHackingWorkRepGain, + [FactionWorkType.FIELD]: getFactionFieldWorkRepGain, + [FactionWorkType.SECURITY]: getFactionSecurityWorkRepGain, + }; + return repFormulas[tpe](person, favor); +}; + export function calculateFactionExp(person: IPerson, tpe: FactionWorkType): WorkStats { const baseStats = FactionWorkStats[tpe]; return { diff --git a/src/engine.tsx b/src/engine.tsx index 127486ffd..a4812d943 100644 --- a/src/engine.tsx +++ b/src/engine.tsx @@ -295,9 +295,9 @@ const Engine: { // No rep for gangs. if (Player.getGangName() === facName) continue; - const hRep = getHackingWorkRepGain(Player, faction); - const sRep = getFactionSecurityWorkRepGain(Player, faction); - const fRep = getFactionFieldWorkRepGain(Player, faction); + const hRep = getHackingWorkRepGain(Player, faction.favor); + const sRep = getFactionSecurityWorkRepGain(Player, faction.favor); + const fRep = getFactionFieldWorkRepGain(Player, faction.favor); // can be infinite, doesn't matter. const reputationRate = Math.max(hRep, sRep, fRep) / Player.factions.length;