From 0550bc188c41f63e416930c42e9d1dbea1393d9d Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Thu, 14 Jul 2022 17:43:08 -0400 Subject: [PATCH] refactor some stuff --- src/Bladeburner/ui/StartButton.tsx | 2 +- src/Crime/Crime.ts | 2 +- src/DarkWeb/DarkWeb.tsx | 2 +- src/Faction/ui/FactionRoot.tsx | 6 +- src/Locations/ui/CompanyLocation.tsx | 2 +- src/Locations/ui/GymLocation.tsx | 2 +- src/Locations/ui/UniversityLocation.tsx | 2 +- src/NetscriptFunctions/Grafting.ts | 2 +- src/NetscriptFunctions/Singularity.ts | 27 ++++---- .../Grafting/ui/GraftingRoot.tsx | 2 +- src/PersonObjects/IPlayer.ts | 11 ++- src/PersonObjects/Multipliers.ts | 67 +++++++++++++++++++ src/PersonObjects/Player/PlayerObject.ts | 14 ++-- ...hods.tsx => PlayerObjectGeneralMethods.ts} | 19 +++--- .../Player/PlayerObjectWorkMethods.ts | 2 +- src/Programs/ui/ProgramsRoot.tsx | 2 +- src/Work/CrimeWork.tsx | 64 ++++++------------ src/Work/WorkStats.ts | 2 - src/engine.tsx | 6 +- src/ui/React/CharacterOverview.tsx | 2 +- src/ui/WorkInProgressRoot.tsx | 19 +++--- src/utils/WorkType.ts | 11 --- 22 files changed, 149 insertions(+), 119 deletions(-) create mode 100644 src/PersonObjects/Multipliers.ts rename src/PersonObjects/Player/{PlayerObjectGeneralMethods.tsx => PlayerObjectGeneralMethods.ts} (99%) diff --git a/src/Bladeburner/ui/StartButton.tsx b/src/Bladeburner/ui/StartButton.tsx index b16bc84b2..18f30b869 100644 --- a/src/Bladeburner/ui/StartButton.tsx +++ b/src/Bladeburner/ui/StartButton.tsx @@ -33,7 +33,7 @@ export function StartButton(props: IProps): React.ReactElement { if (disabled) return; props.bladeburner.action.type = props.type; props.bladeburner.action.name = props.name; - if (!player.hasAugmentation(AugmentationNames.BladesSimulacrum, true)) player.finishNEWWork(true); + if (!player.hasAugmentation(AugmentationNames.BladesSimulacrum, true)) player.finishWork(true); props.bladeburner.startAction(player, props.bladeburner.action); props.rerender(); } diff --git a/src/Crime/Crime.ts b/src/Crime/Crime.ts index a510cfd72..fb0a395b8 100644 --- a/src/Crime/Crime.ts +++ b/src/Crime/Crime.ts @@ -101,7 +101,7 @@ export class Crime { if (div <= 0) { div = 1; } - p.startNEWWork( + p.startWork( new CrimeWork({ crimeType: this.type, singularity: workerScript !== null, diff --git a/src/DarkWeb/DarkWeb.tsx b/src/DarkWeb/DarkWeb.tsx index 1d36056b9..64e400d6f 100644 --- a/src/DarkWeb/DarkWeb.tsx +++ b/src/DarkWeb/DarkWeb.tsx @@ -76,7 +76,7 @@ export function buyDarkwebItem(itemName: string): void { Player.getHomeComputer().pushProgram(item.program); // Cancel if the program is in progress of writing if (isCreateProgramWork(Player.currentWork) && Player.currentWork.programName === item.program) { - Player.finishNEWWork(true); + Player.finishWork(true); } Terminal.print( diff --git a/src/Faction/ui/FactionRoot.tsx b/src/Faction/ui/FactionRoot.tsx index 213a697a5..8893cfa13 100644 --- a/src/Faction/ui/FactionRoot.tsx +++ b/src/Faction/ui/FactionRoot.tsx @@ -69,7 +69,7 @@ function MainPage({ faction, rerender, onAugmentations }: IMainProps): React.Rea } function startFieldWork(faction: Faction): void { - player.startNEWWork( + player.startWork( new FactionWork({ singularity: false, faction: faction.name, @@ -80,7 +80,7 @@ function MainPage({ faction, rerender, onAugmentations }: IMainProps): React.Rea } function startHackingContracts(faction: Faction): void { - player.startNEWWork( + player.startWork( new FactionWork({ singularity: false, faction: faction.name, @@ -91,7 +91,7 @@ function MainPage({ faction, rerender, onAugmentations }: IMainProps): React.Rea } function startSecurityWork(faction: Faction): void { - player.startNEWWork( + player.startWork( new FactionWork({ singularity: false, faction: faction.name, diff --git a/src/Locations/ui/CompanyLocation.tsx b/src/Locations/ui/CompanyLocation.tsx index d570f4027..b64b0c58a 100644 --- a/src/Locations/ui/CompanyLocation.tsx +++ b/src/Locations/ui/CompanyLocation.tsx @@ -176,7 +176,7 @@ export function CompanyLocation(props: IProps): React.ReactElement { const pos = companyPosition; if (pos instanceof CompanyPosition) { - p.startNEWWork( + p.startWork( new CompanyWork({ singularity: false, companyName: props.locName, diff --git a/src/Locations/ui/GymLocation.tsx b/src/Locations/ui/GymLocation.tsx index ffa0342c8..d9ed2b032 100644 --- a/src/Locations/ui/GymLocation.tsx +++ b/src/Locations/ui/GymLocation.tsx @@ -24,7 +24,7 @@ type IProps = { export function GymLocation(props: IProps): React.ReactElement { function train(stat: ClassType): void { - props.p.startNEWWork( + props.p.startWork( new ClassWork({ classType: stat, location: props.loc.name, diff --git a/src/Locations/ui/UniversityLocation.tsx b/src/Locations/ui/UniversityLocation.tsx index 0500cd9ce..823f3dfb5 100644 --- a/src/Locations/ui/UniversityLocation.tsx +++ b/src/Locations/ui/UniversityLocation.tsx @@ -25,7 +25,7 @@ export function UniversityLocation(props: IProps): React.ReactElement { const router = use.Router(); function take(classType: ClassType): void { - player.startNEWWork( + player.startWork( new ClassWork({ classType: classType, location: props.loc.name, diff --git a/src/NetscriptFunctions/Grafting.ts b/src/NetscriptFunctions/Grafting.ts index db57941c9..f74e85ba9 100644 --- a/src/NetscriptFunctions/Grafting.ts +++ b/src/NetscriptFunctions/Grafting.ts @@ -76,7 +76,7 @@ export function NetscriptGrafting(player: IPlayer): InternalAPI { return false; } - player.startNEWWork( + player.startWork( new GraftingWork({ singularity: true, augmentation: augName, diff --git a/src/NetscriptFunctions/Singularity.ts b/src/NetscriptFunctions/Singularity.ts index c193c962a..f36efb1be 100644 --- a/src/NetscriptFunctions/Singularity.ts +++ b/src/NetscriptFunctions/Singularity.ts @@ -49,7 +49,6 @@ import { InternalAPI, NetscriptContext } from "src/Netscript/APIWrapper"; import { BlackOperationNames } from "../Bladeburner/data/BlackOperationNames"; import { enterBitNode } from "../RedPill"; import { FactionNames } from "../Faction/data/FactionNames"; -import { WorkType } from "../utils/WorkType"; import { ClassWork, ClassType } from "../Work/ClassWork"; import { CreateProgramWork, isCreateProgramWork } from "../Work/CreateProgramWork"; import { FactionWork } from "../Work/FactionWork"; @@ -323,7 +322,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript _ctx.log(() => `Invalid class name: ${className}.`); return false; } - player.startNEWWork( + player.startWork( new ClassWork({ classType: task, location: player.location, @@ -408,25 +407,25 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript switch (stat.toLowerCase()) { case "strength".toLowerCase(): case "str".toLowerCase(): - player.startNEWWork( + player.startWork( new ClassWork({ classType: ClassType.GymStrength, location: player.location, singularity: true }), ); break; case "defense".toLowerCase(): case "def".toLowerCase(): - player.startNEWWork( + player.startWork( new ClassWork({ classType: ClassType.GymDefense, location: player.location, singularity: true }), ); break; case "dexterity".toLowerCase(): case "dex".toLowerCase(): - player.startNEWWork( + player.startWork( new ClassWork({ classType: ClassType.GymDexterity, location: player.location, singularity: true }), ); break; case "agility".toLowerCase(): case "agi".toLowerCase(): - player.startNEWWork( + player.startWork( new ClassWork({ classType: ClassType.GymAgility, location: player.location, singularity: true }), ); break; @@ -526,7 +525,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript player.getHomeComputer().pushProgram(item.program); // Cancel if the program is in progress of writing if (isCreateProgramWork(player.currentWork) && player.currentWork.programName === item.program) { - player.finishNEWWork(true); + player.finishWork(true); } player.loseMoney(item.price, "other"); @@ -725,7 +724,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript function (): boolean { _ctx.helper.checkSingularityAccess(); const wasWorking = player.currentWork !== null; - player.finishNEWWork(true); + player.finishWork(true); return wasWorking; }, upgradeHomeCores: (_ctx: NetscriptContext) => @@ -826,7 +825,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript const wasFocused = player.focus; - player.startNEWWork( + player.startWork( new CompanyWork({ singularity: true, companyName: companyName, @@ -994,7 +993,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript _ctx.log(() => `Faction '${faction.name}' do not need help with hacking contracts.`); return false; } - player.startNEWWork( + player.startWork( new FactionWork({ singularity: true, factionWorkType: FactionWorkType.HACKING, @@ -1017,7 +1016,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript _ctx.log(() => `Faction '${faction.name}' do not need help with field missions.`); return false; } - player.startNEWWork( + player.startWork( new FactionWork({ singularity: true, factionWorkType: FactionWorkType.FIELD, @@ -1040,7 +1039,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript _ctx.log(() => `Faction '${faction.name}' do not need help with security work.`); return false; } - player.startNEWWork( + player.startWork( new FactionWork({ singularity: true, factionWorkType: FactionWorkType.SECURITY, @@ -1158,7 +1157,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript return false; } - player.startNEWWork( + player.startWork( new CreateProgramWork({ programName: p.name, singularity: true, @@ -1181,7 +1180,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript const crimeRoughName = _ctx.helper.string("crimeRoughName", _crimeRoughName); if (player.currentWork !== null) { - player.finishNEWWork(true); + player.finishWork(true); } // Set Location to slums diff --git a/src/PersonObjects/Grafting/ui/GraftingRoot.tsx b/src/PersonObjects/Grafting/ui/GraftingRoot.tsx index c6d137716..9f37f2d12 100644 --- a/src/PersonObjects/Grafting/ui/GraftingRoot.tsx +++ b/src/PersonObjects/Grafting/ui/GraftingRoot.tsx @@ -155,7 +155,7 @@ export const GraftingRoot = (): React.ReactElement => { open={graftOpen} onClose={() => setGraftOpen(false)} onConfirm={() => { - player.startNEWWork( + player.startWork( new GraftingWork({ augmentation: selectedAug, singularity: false, diff --git a/src/PersonObjects/IPlayer.ts b/src/PersonObjects/IPlayer.ts index 890f6b32d..7eb275025 100644 --- a/src/PersonObjects/IPlayer.ts +++ b/src/PersonObjects/IPlayer.ts @@ -25,12 +25,10 @@ import { ICorporation } from "../Corporation/ICorporation"; import { IGang } from "../Gang/IGang"; import { IBladeburner } from "../Bladeburner/IBladeburner"; import { ICodingContractReward } from "../CodingContracts"; -import { IRouter } from "../ui/Router"; import { HacknetServer } from "../Hacknet/HacknetServer"; import { ISkillProgress } from "./formulas/skill"; import { PlayerAchievement } from "../Achievements/Achievements"; import { IPerson } from "./IPerson"; -import { WorkType } from "../utils/WorkType"; import { Work } from "src/Work/Work"; export interface IPlayer extends IPerson { @@ -51,7 +49,6 @@ export interface IPlayer extends IPerson { hasWseAccount: boolean; hp: number; jobs: IMap; - init: () => void; karma: number; numPeopleKilled: number; location: LocationName; @@ -129,9 +126,10 @@ export interface IPlayer extends IPerson { entropy: number; // Methods - startNEWWork(w: Work): void; - processNEWWork(cycles: number): void; - finishNEWWork(cancelled: boolean): void; + init: () => void; + startWork(w: Work): void; + processWork(cycles: number): void; + finishWork(cancelled: boolean): void; applyForAgentJob(sing?: boolean): boolean; applyForBusinessConsultantJob(sing?: boolean): boolean; applyForBusinessJob(sing?: boolean): boolean; @@ -201,4 +199,5 @@ export interface IPlayer extends IPerson { canAccessCotMG(): boolean; sourceFileLvl(n: number): number; applyEntropy(stacks?: number): void; + focusPenalty(): number; } diff --git a/src/PersonObjects/Multipliers.ts b/src/PersonObjects/Multipliers.ts new file mode 100644 index 000000000..7f36b9bcb --- /dev/null +++ b/src/PersonObjects/Multipliers.ts @@ -0,0 +1,67 @@ +export interface Multipliers { + hacking_chance: number; + hacking_speed: number; + hacking_money: number; + hacking_grow: number; + hacking: number; + hacking_exp: number; + strength: number; + strength_exp: number; + defense: number; + defense_exp: number; + dexterity: number; + dexterity_exp: number; + agility: number; + agility_exp: number; + charisma: number; + charisma_exp: number; + hacknet_node_money: number; + hacknet_node_purchase_cost: number; + hacknet_node_ram_cost: number; + hacknet_node_core_cost: number; + hacknet_node_level_cost: number; + company_rep: number; + faction_rep: number; + work_money: number; + crime_success: number; + crime_money: number; + bladeburner_max_stamina: number; + bladeburner_stamina_gain: number; + bladeburner_analysis: number; + bladeburner_success_chance: number; +} + +export const defaultMultipliers = (): Multipliers => { + return { + hacking_chance: 1, + hacking_speed: 1, + hacking_money: 1, + hacking_grow: 1, + hacking: 1, + hacking_exp: 1, + strength: 1, + strength_exp: 1, + defense: 1, + defense_exp: 1, + dexterity: 1, + dexterity_exp: 1, + agility: 1, + agility_exp: 1, + charisma: 1, + charisma_exp: 1, + hacknet_node_money: 1, + hacknet_node_purchase_cost: 1, + hacknet_node_ram_cost: 1, + hacknet_node_core_cost: 1, + hacknet_node_level_cost: 1, + company_rep: 1, + faction_rep: 1, + work_money: 1, + crime_success: 1, + crime_money: 1, + bladeburner_max_stamina: 1, + bladeburner_stamina_gain: 1, + bladeburner_analysis: 1, + bladeburner_success_chance: 1, + }; +}; diff --git a/src/PersonObjects/Player/PlayerObject.ts b/src/PersonObjects/Player/PlayerObject.ts index aa679ef3a..58ed5526c 100644 --- a/src/PersonObjects/Player/PlayerObject.ts +++ b/src/PersonObjects/Player/PlayerObject.ts @@ -140,9 +140,9 @@ export class PlayerObject implements IPlayer { entropy: number; // Methods - startNEWWork: (w: Work) => void; - processNEWWork: (cycles: number) => void; - finishNEWWork: (cancelled: boolean) => void; + startWork: (w: Work) => void; + processWork: (cycles: number) => void; + finishWork: (cancelled: boolean) => void; applyForAgentJob: (sing?: boolean) => boolean; applyForBusinessConsultantJob: (sing?: boolean) => boolean; applyForBusinessJob: (sing?: boolean) => boolean; @@ -226,6 +226,7 @@ export class PlayerObject implements IPlayer { canAccessCotMG: () => boolean; sourceFileLvl: (n: number) => number; applyEntropy: (stacks?: number) => void; + focusPenalty: () => number; constructor() { //Skills and stats @@ -409,9 +410,9 @@ export class PlayerObject implements IPlayer { this.gainIntelligenceExp = generalMethods.gainIntelligenceExp; this.gainStats = generalMethods.gainStats; this.queryStatFromString = generalMethods.queryStatFromString; - this.startNEWWork = workMethods.start; - this.processNEWWork = workMethods.process; - this.finishNEWWork = workMethods.finish; + this.startWork = workMethods.start; + this.processWork = workMethods.process; + this.finishWork = workMethods.finish; this.startFocusing = generalMethods.startFocusing; this.stopFocusing = generalMethods.stopFocusing; this.takeDamage = generalMethods.takeDamage; @@ -477,6 +478,7 @@ export class PlayerObject implements IPlayer { this.sourceFileLvl = generalMethods.sourceFileLvl; this.applyEntropy = augmentationMethods.applyEntropy; + this.focusPenalty = generalMethods.focusPenalty; } whoAmI(): string { diff --git a/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx b/src/PersonObjects/Player/PlayerObjectGeneralMethods.ts similarity index 99% rename from src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx rename to src/PersonObjects/Player/PlayerObjectGeneralMethods.ts index 2049289e9..12ad37c74 100644 --- a/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx +++ b/src/PersonObjects/Player/PlayerObjectGeneralMethods.ts @@ -37,21 +37,13 @@ import { SpecialServers } from "../../Server/data/SpecialServers"; import { applySourceFile } from "../../SourceFile/applySourceFile"; import { applyExploit } from "../../Exploits/applyExploits"; import { SourceFiles } from "../../SourceFile/SourceFiles"; -import { influenceStockThroughCompanyWork } from "../../StockMarket/PlayerInfluencing"; import { getHospitalizationCost } from "../../Hospital/Hospital"; import { HacknetServer } from "../../Hacknet/HacknetServer"; import { numeralWrapper } from "../../ui/numeralFormat"; -import { IRouter } from "../../ui/Router"; import { MoneySourceTracker } from "../../utils/MoneySourceTracker"; import { dialogBoxCreate } from "../../ui/React/DialogBox"; -import { convertTimeMsToTimeElapsedString } from "../../utils/StringHelperFunctions"; -import { Reputation } from "../../ui/React/Reputation"; -import { Money } from "../../ui/React/Money"; - -import React from "react"; -import { serverMetadata } from "../../Server/data/servers"; import { SnackbarEvents, ToastVariant } from "../../ui/React/Snackbar"; import { achievements } from "../../Achievements/Achievements"; import { FactionNames } from "../../Faction/data/FactionNames"; @@ -59,7 +51,6 @@ import { ITaskTracker } from "../ITaskTracker"; import { IPerson } from "../IPerson"; import { Player } from "../../Player"; -import { WorkType } from "../../utils/WorkType"; import { isCompanyWork } from "../../Work/CompanyWork"; export function init(this: IPlayer): void { @@ -617,7 +608,7 @@ export function getNextCompanyPosition( export function quitJob(this: IPlayer, company: string, _sing = false): void { if (isCompanyWork(this.currentWork) && this.currentWork.companyName === company) { - this.finishNEWWork(true); + this.finishWork(true); } delete this.jobs[company]; if (this.companyName === company) { @@ -1487,3 +1478,11 @@ export function sourceFileLvl(this: IPlayer, n: number): number { if (!sf) return 0; return sf.lvl; } + +export function focusPenalty(this: IPlayer): number { + let focus = 1; + if (!this.hasAugmentation(AugmentationNames["NeuroreceptorManager"])) { + focus = this.focus ? 1 : CONSTANTS.BaseFocusBonus; + } + return focus; +} diff --git a/src/PersonObjects/Player/PlayerObjectWorkMethods.ts b/src/PersonObjects/Player/PlayerObjectWorkMethods.ts index 6ef8557b2..058c79b0c 100644 --- a/src/PersonObjects/Player/PlayerObjectWorkMethods.ts +++ b/src/PersonObjects/Player/PlayerObjectWorkMethods.ts @@ -11,7 +11,7 @@ export function process(this: IPlayer, cycles = 1): void { if (this.currentWork === null) return; const finished = this.currentWork.process(this, cycles); if (finished) { - this.finishNEWWork(false); + this.finishWork(false); } } export function finish(this: IPlayer, cancelled: boolean): void { diff --git a/src/Programs/ui/ProgramsRoot.tsx b/src/Programs/ui/ProgramsRoot.tsx index 0a4b8017c..d50e4750f 100644 --- a/src/Programs/ui/ProgramsRoot.tsx +++ b/src/Programs/ui/ProgramsRoot.tsx @@ -97,7 +97,7 @@ export function ProgramsRoot(): React.ReactElement { sx={{ my: 1, width: "100%" }} onClick={(event) => { if (!event.isTrusted) return; - player.startNEWWork( + player.startWork( new CreateProgramWork({ player: player, singularity: false, programName: program.name }), ); player.startFocusing(); diff --git a/src/Work/CrimeWork.tsx b/src/Work/CrimeWork.tsx index 4e59afbc1..1ac4ea2bd 100644 --- a/src/Work/CrimeWork.tsx +++ b/src/Work/CrimeWork.tsx @@ -5,9 +5,7 @@ import { CONSTANTS } from "../Constants"; import { determineCrimeSuccess } from "../Crime/CrimeHelpers"; import { Crimes } from "../Crime/Crimes"; import { IPlayer } from "../PersonObjects/IPlayer"; -import { numeralWrapper } from "../ui/numeralFormat"; import { dialogBoxCreate } from "../ui/React/DialogBox"; -import { Money } from "../ui/React/Money"; import { CrimeType } from "../utils/WorkType"; import { Work, WorkType } from "./Work"; @@ -20,10 +18,12 @@ export const isCrimeWork = (w: Work | null): w is CrimeWork => w !== null && w.t export class CrimeWork extends Work { crimeType: CrimeType; + unitCompleted: number; constructor(params?: CrimeWorkParams) { super(WorkType.CRIME, params?.singularity ?? true); this.crimeType = params?.crimeType ?? CrimeType.Shoplift; + this.unitCompleted = 0; } getCrime(): Crime { @@ -35,11 +35,15 @@ export class CrimeWork extends Work { process(player: IPlayer, cycles = 1): boolean { this.cyclesWorked += cycles; const time = Object.values(Crimes).find((c) => c.type === this.crimeType)?.time ?? 0; - return this.cyclesWorked * CONSTANTS._idleSpeed >= time; + this.unitCompleted += CONSTANTS._idleSpeed * cycles; + if (this.unitCompleted >= time) { + this.commit(player); + this.unitCompleted -= time; + } + return false; } - finish(player: IPlayer, cancelled: boolean): void { - if (cancelled) return; + commit(player: IPlayer): void { let crime = null; for (const i of Object.keys(Crimes)) { if (Crimes[i].type == this.crimeType) { @@ -53,6 +57,7 @@ export class CrimeWork extends Work { ); return; } + const focusPenalty = player.focusPenalty(); // exp times 2 because were trying to maintain the same numbers as before the conversion // Technically the definition of Crimes should have the success numbers and failure should divide by 4 let hackExp = crime.hacking_exp * 2; @@ -64,9 +69,9 @@ export class CrimeWork extends Work { let karma = crime.karma; const success = determineCrimeSuccess(player, crime.type); if (success) { - player.gainMoney(crime.money, "crime"); + player.gainMoney(crime.money * focusPenalty, "crime"); player.numPeopleKilled += crime.kills; - player.gainIntelligenceExp(crime.intelligence_exp); + player.gainIntelligenceExp(crime.intelligence_exp * focusPenalty); } else { hackExp /= 4; StrExp /= 4; @@ -76,42 +81,17 @@ export class CrimeWork extends Work { ChaExp /= 4; karma /= 4; } + player.gainHackingExp(hackExp * focusPenalty); + player.gainStrengthExp(StrExp * focusPenalty); + player.gainDefenseExp(DefExp * focusPenalty); + player.gainDexterityExp(DexExp * focusPenalty); + player.gainAgilityExp(AgiExp * focusPenalty); + player.gainCharismaExp(ChaExp * focusPenalty); + player.karma -= karma * focusPenalty; + } - player.gainHackingExp(hackExp); - player.gainStrengthExp(StrExp); - player.gainDefenseExp(DefExp); - player.gainDexterityExp(DexExp); - player.gainAgilityExp(AgiExp); - player.gainCharismaExp(ChaExp); - player.karma -= karma; - - if (!this.singularity) { - dialogBoxCreate( - <> - Crime {success ? "successful" : "failed"}! -
-
- You gained: - {success && ( - <> -
- - - )} -
- {numeralWrapper.formatExp(hackExp)} hacking experience
- {numeralWrapper.formatExp(StrExp)} strength experience -
- {numeralWrapper.formatExp(DefExp)} defense experience -
- {numeralWrapper.formatExp(DexExp)} dexterity experience -
- {numeralWrapper.formatExp(AgiExp)} agility experience -
- {numeralWrapper.formatExp(ChaExp)} charisma experience - , - ); - } + finish(player: IPlayer, cancelled: boolean): void { + if (cancelled) return; } /** diff --git a/src/Work/WorkStats.ts b/src/Work/WorkStats.ts index 1388560e9..f0783617e 100644 --- a/src/Work/WorkStats.ts +++ b/src/Work/WorkStats.ts @@ -1,5 +1,3 @@ -import { AugmentationNames } from "../Augmentation/data/AugmentationNames"; -import { CONSTANTS } from "../Constants"; import { IPlayer } from "../PersonObjects/IPlayer"; export interface WorkStats { diff --git a/src/engine.tsx b/src/engine.tsx index f82c93905..7bace0775 100644 --- a/src/engine.tsx +++ b/src/engine.tsx @@ -50,8 +50,6 @@ import { setupUncaughtPromiseHandler } from "./UncaughtPromiseHandler"; import { Button, Typography } from "@mui/material"; import { SnackbarEvents, ToastVariant } from "./ui/React/Snackbar"; -import { WorkType } from "./utils/WorkType"; - const Engine: { _lastUpdate: number; updateGame: (numCycles?: number) => void; @@ -96,7 +94,7 @@ const Engine: { Terminal.process(Router, Player, numCycles); - Player.processNEWWork(numCycles); + Player.processWork(numCycles); // Update stock prices if (Player.hasWseAccount) { @@ -295,7 +293,7 @@ const Engine: { loadAllRunningScripts(Player); // This also takes care of offline production for those scripts if (Player.currentWork !== null) { Player.focus = true; - Player.processNEWWork(numCyclesOffline); + Player.processWork(numCyclesOffline); } else { for (let i = 0; i < Player.factions.length; i++) { const facName = Player.factions[i]; diff --git a/src/ui/React/CharacterOverview.tsx b/src/ui/React/CharacterOverview.tsx index 3922b419a..e62ec6fad 100644 --- a/src/ui/React/CharacterOverview.tsx +++ b/src/ui/React/CharacterOverview.tsx @@ -152,7 +152,7 @@ function Work(): React.ReactElement { let innerText = <>; if (isCrimeWork(player.currentWork)) { const crime = player.currentWork.getCrime(); - const perc = ((player.currentWork.cyclesWorked * CONSTANTS._idleSpeed) / crime.time) * 100; + const perc = (player.currentWork.unitCompleted / crime.time) * 100; details = <>{player.currentWork.crimeType}; header = <>You are attempting to {player.currentWork.crimeType}; diff --git a/src/ui/WorkInProgressRoot.tsx b/src/ui/WorkInProgressRoot.tsx index 95f975915..82e378774 100644 --- a/src/ui/WorkInProgressRoot.tsx +++ b/src/ui/WorkInProgressRoot.tsx @@ -18,7 +18,6 @@ import { ProgressBar } from "./React/Progress"; import { Reputation } from "./React/Reputation"; import { ReputationRate } from "./React/ReputationRate"; import { StatsRow } from "./React/StatsRow"; -import { WorkType } from "../utils/WorkType"; import { isCrimeWork } from "../Work/CrimeWork"; import { isClassWork } from "../Work/ClassWork"; import { WorkStats } from "../Work/WorkStats"; @@ -145,13 +144,13 @@ export function WorkInProgressRoot(): React.ReactElement { if (player.currentWork !== null) { if (isCrimeWork(player.currentWork)) { const crime = player.currentWork.getCrime(); - const completion = ((player.currentWork.cyclesWorked * CONSTANTS._idleSpeed) / crime.time) * 100; + const completion = (player.currentWork.unitCompleted / crime.time) * 100; workInfo = { buttons: { cancel: () => { router.toLocation(Locations[LocationName.Slums]); - player.finishNEWWork(true); + player.finishWork(true); }, unfocus: () => { router.toCity(); @@ -161,18 +160,18 @@ export function WorkInProgressRoot(): React.ReactElement { title: `You are attempting to ${crime.type}`, progress: { - remaining: crime.time - player.currentWork.cyclesWorked * CONSTANTS._idleSpeed, + remaining: crime.time - player.currentWork.unitCompleted, percentage: completion, }, - stopText: "Cancel crime", + stopText: "Stop commiting crime", }; } if (isClassWork(player.currentWork)) { const classWork = player.currentWork; function cancel(): void { - player.finishNEWWork(true); + player.finishWork(true); router.toCity(); } @@ -219,7 +218,7 @@ export function WorkInProgressRoot(): React.ReactElement { if (isCreateProgramWork(player.currentWork)) { const create = player.currentWork; function cancel(): void { - player.finishNEWWork(true); + player.finishWork(true); router.toTerminal(); } function unfocus(): void { @@ -253,7 +252,7 @@ export function WorkInProgressRoot(): React.ReactElement { if (isGraftingWork(player.currentWork)) { const graft = player.currentWork; function cancel(): void { - player.finishNEWWork(true); + player.finishWork(true); router.toTerminal(); } function unfocus(): void { @@ -303,7 +302,7 @@ export function WorkInProgressRoot(): React.ReactElement { function cancel(): void { router.toFaction(faction); - player.finishNEWWork(true); + player.finishWork(true); } function unfocus(): void { router.toFaction(faction); @@ -362,7 +361,7 @@ export function WorkInProgressRoot(): React.ReactElement { const companyRep = comp.playerReputation; function cancel(): void { - player.finishNEWWork(true); + player.finishWork(true); router.toJob(); } function unfocus(): void { diff --git a/src/utils/WorkType.ts b/src/utils/WorkType.ts index 3acea0fe1..58c003fd7 100644 --- a/src/utils/WorkType.ts +++ b/src/utils/WorkType.ts @@ -1,14 +1,3 @@ -export enum WorkType { - None = "", - Company = "Working for Company", - CompanyPartTime = "Working for Company part-time", - Faction = "Working for Faction", - CreateProgram = "Working on Create a Program", - StudyClass = "Studying or Taking a class at university", - Crime = "Committing a crime", - GraftAugmentation = "Grafting an Augmentation", -} - export enum CrimeType { None = "", Shoplift = "shoplift",