remove so many fields and values used by the old system

This commit is contained in:
Olivier Gagnon 2022-07-12 23:13:40 -04:00
parent 598e47766e
commit fac6633347
15 changed files with 27 additions and 954 deletions

@ -1988,7 +1988,7 @@ export class Bladeburner implements IBladeburner {
if (!router.isInitialized) return;
// If the Player starts doing some other actions, set action to idle and alert
if (!player.hasAugmentation(AugmentationNames.BladesSimulacrum, true) && player.isWorking) {
if (!player.hasAugmentation(AugmentationNames.BladesSimulacrum, true) && player.currentWork) {
if (this.action.type !== ActionTypes["Idle"]) {
let msg = "Your Bladeburner action was cancelled because you started doing something else.";
if (this.automateEnabled) {

@ -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.singularityStopWork();
if (!player.hasAugmentation(AugmentationNames.BladesSimulacrum, true)) player.finishNEWWork(true);
props.bladeburner.startAction(player, props.bladeburner.action);
props.rerender();
}

@ -76,8 +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.isWorking = false;
Player.resetWorkStatus();
Player.finishNEWWork(true);
}
Terminal.print(

@ -2397,25 +2397,6 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
companyName: Player.companyName,
crime_money_mult: Player.crime_money_mult,
crime_success_mult: Player.crime_success_mult,
isWorking: Player.isWorking,
workType: Player.workType,
workHackExpGainRate: Player.workHackExpGainRate,
workStrExpGainRate: Player.workStrExpGainRate,
workDefExpGainRate: Player.workDefExpGainRate,
workDexExpGainRate: Player.workDexExpGainRate,
workAgiExpGainRate: Player.workAgiExpGainRate,
workChaExpGainRate: Player.workChaExpGainRate,
workRepGainRate: Player.workRepGainRate,
workMoneyGainRate: Player.workMoneyGainRate,
workMoneyLossRate: Player.workMoneyLossRate,
workHackExpGained: Player.workHackExpGained,
workStrExpGained: Player.workStrExpGained,
workDefExpGained: Player.workDefExpGained,
workDexExpGained: Player.workDexExpGained,
workAgiExpGained: Player.workAgiExpGained,
workChaExpGained: Player.workChaExpGained,
workRepGained: Player.workRepGained,
workMoneyGained: Player.workMoneyGained,
work_money_mult: Player.work_money_mult,
hacknet_node_money_mult: Player.hacknet_node_money_mult,
hacknet_node_purchase_cost_mult: Player.hacknet_node_purchase_cost_mult,

@ -64,10 +64,6 @@ export function NetscriptGrafting(player: IPlayer): InternalAPI<IGrafting> {
}
const wasFocusing = player.focus;
if (player.isWorking) {
const txt = player.singularityStopWork();
ctx.log(() => txt);
}
const craftableAug = new GraftableAugmentation(StaticAugmentations[augName]);
if (player.money < craftableAug.cost) {

@ -54,6 +54,7 @@ import { ClassWork, ClassType } from "../Work/ClassWork";
import { CreateProgramWork, isCreateProgramWork } from "../Work/CreateProgramWork";
import { FactionWork } from "../Work/FactionWork";
import { FactionWorkType } from "../Work/data/FactionWorkType";
import { CompanyWork } from "../Work/CompanyWork";
export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript): InternalAPI<ISingularity> {
const getAugmentation = function (_ctx: NetscriptContext, name: string): Augmentation {
@ -268,10 +269,6 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
const className = _ctx.helper.string("className", _className);
const focus = _ctx.helper.boolean(_focus);
const wasFocusing = player.focus;
if (player.currentWork) {
const txt = player.singularityStopWork();
_ctx.log(() => txt);
}
switch (universityName.toLowerCase()) {
case LocationName.AevumSummitUniversity.toLowerCase():
@ -351,10 +348,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
const stat = _ctx.helper.string("stat", _stat);
const focus = _ctx.helper.boolean(_focus);
const wasFocusing = player.focus;
if (player.isWorking) {
const txt = player.singularityStopWork();
_ctx.log(() => txt);
}
switch (gymName.toLowerCase()) {
case LocationName.AevumCrushFitnessGym.toLowerCase():
if (player.city != CityName.Aevum) {
@ -532,8 +526,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.isWorking = false;
player.resetWorkStatus();
player.finishNEWWork(true);
}
player.loseMoney(item.price, "other");
@ -643,20 +636,10 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
function (_focus: unknown): boolean {
_ctx.helper.checkSingularityAccess();
const focus = _ctx.helper.boolean(_focus);
if (!player.isWorking) {
if (player.currentWork === null) {
throw _ctx.helper.makeRuntimeErrorMsg("Not currently working");
}
if (
!(
player.workType === WorkType.Faction ||
player.workType === WorkType.Company ||
player.workType === WorkType.CompanyPartTime ||
player.workType === WorkType.CreateProgram ||
player.workType === WorkType.StudyClass
)
) {
throw _ctx.helper.makeRuntimeErrorMsg("Cannot change focus for current job");
}
if (!player.focus && focus) {
player.startFocusing();
Router.toWork();
@ -715,16 +698,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
strengthExp: player.strength_exp_mult,
workMoney: player.work_money_mult,
},
timeWorked: player.timeWorked,
tor: player.hasTorRouter(),
workHackExpGain: player.workHackExpGained,
workStrExpGain: player.workStrExpGained,
workDefExpGain: player.workDefExpGained,
workDexExpGain: player.workDexExpGained,
workAgiExpGain: player.workAgiExpGained,
workChaExpGain: player.workChaExpGained,
workRepGain: player.workRepGained,
workMoneyGain: player.workMoneyGained,
hackingExp: player.hacking_exp,
strengthExp: player.strength_exp,
defenseExp: player.defense_exp,
@ -736,7 +710,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
hospitalize: (_ctx: NetscriptContext) =>
function (): void {
_ctx.helper.checkSingularityAccess();
if (player.isWorking || Router.page() === Page.Infiltration || Router.page() === Page.BitVerse) {
if (player.currentWork || Router.page() === Page.Infiltration || Router.page() === Page.BitVerse) {
_ctx.log(() => "Cannot go to the hospital because the player is busy.");
return;
}
@ -745,21 +719,14 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
isBusy: (_ctx: NetscriptContext) =>
function (): boolean {
_ctx.helper.checkSingularityAccess();
return player.isWorking || Router.page() === Page.Infiltration || Router.page() === Page.BitVerse;
return player.currentWork !== null || Router.page() === Page.Infiltration || Router.page() === Page.BitVerse;
},
stopAction: (_ctx: NetscriptContext) =>
function (): boolean {
_ctx.helper.checkSingularityAccess();
if (player.isWorking) {
if (player.focus) {
player.stopFocusing();
Router.toTerminal();
}
const txt = player.singularityStopWork();
_ctx.log(() => txt);
return true;
}
return false;
const wasWorking = player.currentWork !== null;
player.finishNEWWork(true);
return wasWorking;
},
upgradeHomeCores: (_ctx: NetscriptContext) =>
function (): boolean {
@ -858,17 +825,13 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
}
const wasFocused = player.focus;
if (player.isWorking) {
const txt = player.singularityStopWork();
_ctx.log(() => txt);
}
if (companyPosition.isPartTimeJob()) {
player.startWorkPartTime(companyName);
} else {
player.startWork(companyName);
}
player.startNEWWork(
new CompanyWork({
singularity: true,
companyName: companyName,
}),
);
if (focus) {
player.startFocusing();
Router.toWork();
@ -1022,10 +985,6 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
}
const wasFocusing = player.focus;
if (player.isWorking) {
const txt = player.singularityStopWork();
_ctx.log(() => txt);
}
switch (type.toLowerCase()) {
case "hacking":
@ -1175,10 +1134,6 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
const focus = _ctx.helper.boolean(_focus);
const wasFocusing = player.focus;
if (player.isWorking) {
const txt = player.singularityStopWork();
_ctx.log(() => txt);
}
const p = Object.values(Programs).find((p) => p.name.toLowerCase() === programName);
@ -1225,11 +1180,6 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
_ctx.helper.checkSingularityAccess();
const crimeRoughName = _ctx.helper.string("crimeRoughName", _crimeRoughName);
if (player.isWorking) {
const txt = player.singularityStopWork();
_ctx.log(() => txt);
}
if (player.currentWork !== null) {
player.finishNEWWork(true);
}

@ -52,7 +52,6 @@ export interface IPlayer extends IPerson {
hp: number;
jobs: IMap<string>;
init: () => void;
isWorking: boolean;
karma: number;
numPeopleKilled: number;
location: LocationName;
@ -125,27 +124,7 @@ export interface IPlayer extends IPerson {
bladeburner_success_chance_mult: number;
currentWork: Work | null;
timeNeededToCompleteWork: number;
focus: boolean;
workType: WorkType;
timeWorked: number;
workMoneyGained: number;
workMoneyGainRate: number;
workRepGained: number;
workRepGainRate: number;
workHackExpGained: number;
workHackExpGainRate: number;
workStrExpGained: number;
workStrExpGainRate: number;
workDefExpGained: number;
workDefExpGainRate: number;
workDexExpGained: number;
workDexExpGainRate: number;
workAgiExpGained: number;
workAgiExpGainRate: number;
workChaExpGained: number;
workChaExpGainRate: number;
workMoneyLossRate: number;
entropy: number;
@ -153,8 +132,6 @@ export interface IPlayer extends IPerson {
startNEWWork(w: Work): void;
processNEWWork(cycles: number): void;
finishNEWWork(cancelled: boolean): void;
work(numCycles: number): boolean;
workPartTime(numCycles: number): boolean;
applyForAgentJob(sing?: boolean): boolean;
applyForBusinessConsultantJob(sing?: boolean): boolean;
applyForBusinessJob(sing?: boolean): boolean;
@ -193,17 +170,13 @@ export interface IPlayer extends IPerson {
isAwareOfGang(): boolean;
isQualified(company: Company, position: CompanyPosition): boolean;
loseMoney(money: number, source: string): void;
process(router: IRouter, numCycles?: number): void;
reapplyAllAugmentations(resetMultipliers?: boolean): void;
reapplyAllSourceFiles(): void;
setMoney(amt: number): void;
singularityStopWork(): string;
startBladeburner(p: any): void;
startCorporation(corpName: string, additionalShares?: number): void;
startFocusing(): void;
startGang(facName: string, isHacking: boolean): void;
startWork(companyName: string): void;
startWorkPartTime(companyName: string): void;
travel(to: CityName): boolean;
giveExploit(exploit: Exploit): void;
giveAchievement(achievementId: string): void;
@ -216,23 +189,10 @@ export interface IPlayer extends IPerson {
updateSkillLevels(): void;
gainCodingContractReward(reward: ICodingContractReward, difficulty?: number): string;
stopFocusing(): void;
finishWork(cancelled: boolean, sing?: boolean): string;
cancelationPenalty(): number;
finishWorkPartTime(sing?: boolean): string;
resetMultipliers(): void;
prestigeAugmentation(): void;
prestigeSourceFile(): void;
calculateSkillProgress(exp: number, mult?: number): ISkillProgress;
resetWorkStatus(generalType?: WorkType, group?: string, workType?: string): void;
getWorkHackExpGain(): number;
getWorkStrExpGain(): number;
getWorkDefExpGain(): number;
getWorkDexExpGain(): number;
getWorkAgiExpGain(): number;
getWorkChaExpGain(): number;
getWorkRepGain(): number;
getWorkMoneyGain(): number;
processWorkEarnings(cycles: number): void;
hospitalize(): void;
checkForFactionInvitations(): Faction[];
setBitNodeNumber(n: number): void;

@ -17,7 +17,6 @@ import { HacknetServer } from "../../Hacknet/HacknetServer";
import { Faction } from "../../Faction/Faction";
import { Company } from "../../Company/Company";
import { Augmentation } from "../../Augmentation/Augmentation";
import { IRouter } from "../../ui/Router";
import { ICodingContractReward } from "../../CodingContracts";
import { IPlayer } from "../IPlayer";
@ -39,7 +38,6 @@ import { cyrb53 } from "../../utils/StringHelperFunctions";
import { getRandomInt } from "../../utils/helpers/getRandomInt";
import { ITaskTracker } from "../ITaskTracker";
import { CONSTANTS } from "../../Constants";
import { WorkType } from "../../utils/WorkType";
import { Work } from "src/Work/Work";
export class PlayerObject implements IPlayer {
@ -63,7 +61,6 @@ export class PlayerObject implements IPlayer {
hp: number;
jobs: IMap<string>;
init: () => void;
isWorking: boolean;
karma: number;
numPeopleKilled: number;
location: LocationName;
@ -138,27 +135,7 @@ export class PlayerObject implements IPlayer {
bladeburner_success_chance_mult: number;
currentWork: Work | null;
timeNeededToCompleteWork: number;
focus: boolean;
workType: WorkType;
timeWorked: number;
workMoneyGained: number;
workMoneyGainRate: number;
workRepGained: number;
workRepGainRate: number;
workHackExpGained: number;
workHackExpGainRate: number;
workStrExpGained: number;
workStrExpGainRate: number;
workDefExpGained: number;
workDefExpGainRate: number;
workDexExpGained: number;
workDexExpGainRate: number;
workAgiExpGained: number;
workAgiExpGainRate: number;
workChaExpGained: number;
workChaExpGainRate: number;
workMoneyLossRate: number;
entropy: number;
@ -166,8 +143,6 @@ export class PlayerObject implements IPlayer {
startNEWWork: (w: Work) => void;
processNEWWork: (cycles: number) => void;
finishNEWWork: (cancelled: boolean) => void;
work: (numCycles: number) => boolean;
workPartTime: (numCycles: number) => boolean;
applyForAgentJob: (sing?: boolean) => boolean;
applyForBusinessConsultantJob: (sing?: boolean) => boolean;
applyForBusinessJob: (sing?: boolean) => boolean;
@ -219,13 +194,10 @@ export class PlayerObject implements IPlayer {
regenerateHp: (amt: number) => void;
recordMoneySource: (amt: number, source: string) => void;
setMoney: (amt: number) => void;
singularityStopWork: () => string;
startBladeburner: (p: any) => void;
startCorporation: (corpName: string, additionalShares?: number) => void;
startFocusing: () => void;
startGang: (facName: string, isHacking: boolean) => void;
startWork: (companyName: string) => void;
startWorkPartTime: (companyName: string) => void;
takeDamage: (amt: number) => boolean;
travel: (to: CityName) => boolean;
giveExploit: (exploit: Exploit) => void;
@ -235,31 +207,17 @@ export class PlayerObject implements IPlayer {
getCasinoWinnings: () => number;
quitJob: (company: string, sing?: boolean) => void;
hasJob: () => boolean;
process: (router: IRouter, numCycles?: number) => void;
createHacknetServer: () => HacknetServer;
queueAugmentation: (augmentationName: string) => void;
receiveInvite: (factionName: string) => void;
updateSkillLevels: () => void;
gainCodingContractReward: (reward: ICodingContractReward, difficulty?: number) => string;
stopFocusing: () => void;
finishWork: (cancelled: boolean, sing?: boolean) => string;
cancelationPenalty: () => number;
finishWorkPartTime: (sing?: boolean) => string;
resetMultipliers: () => void;
prestigeAugmentation: () => void;
prestigeSourceFile: () => void;
calculateSkill: (exp: number, mult?: number) => number;
calculateSkillProgress: (exp: number, mult?: number) => ISkillProgress;
resetWorkStatus: (generalType?: WorkType, group?: string, workType?: string) => void;
getWorkHackExpGain: () => number;
getWorkStrExpGain: () => number;
getWorkDefExpGain: () => number;
getWorkDexExpGain: () => number;
getWorkAgiExpGain: () => number;
getWorkChaExpGain: () => number;
getWorkRepGain: () => number;
getWorkMoneyGain: () => number;
processWorkEarnings: (cycles: number) => void;
hospitalize: () => void;
checkForFactionInvitations: () => Faction[];
setBitNodeNumber: (n: number) => void;
@ -360,31 +318,7 @@ export class PlayerObject implements IPlayer {
this.crime_success_mult = 1;
//Flags/variables for working (Company, Faction, Creating Program, Taking Class)
this.isWorking = false;
this.focus = false;
this.workType = WorkType.None;
this.workHackExpGainRate = 0;
this.workStrExpGainRate = 0;
this.workDefExpGainRate = 0;
this.workDexExpGainRate = 0;
this.workAgiExpGainRate = 0;
this.workChaExpGainRate = 0;
this.workRepGainRate = 0;
this.workMoneyGainRate = 0;
this.workMoneyLossRate = 0;
this.workHackExpGained = 0;
this.workStrExpGained = 0;
this.workDefExpGained = 0;
this.workDexExpGained = 0;
this.workAgiExpGained = 0;
this.workChaExpGained = 0;
this.workRepGained = 0;
this.workMoneyGained = 0;
this.timeWorked = 0; //in m;
this.timeNeededToCompleteWork = 0;
this.work_money_mult = 1;
@ -475,30 +409,11 @@ export class PlayerObject implements IPlayer {
this.gainIntelligenceExp = generalMethods.gainIntelligenceExp;
this.gainStats = generalMethods.gainStats;
this.queryStatFromString = generalMethods.queryStatFromString;
this.resetWorkStatus = generalMethods.resetWorkStatus;
this.processWorkEarnings = generalMethods.processWorkEarnings;
this.startWork = generalMethods.startWork;
this.cancelationPenalty = generalMethods.cancelationPenalty;
this.startNEWWork = workMethods.start;
this.processNEWWork = workMethods.process;
this.finishNEWWork = workMethods.finish;
this.work = generalMethods.work;
this.finishWork = generalMethods.finishWork;
this.startWorkPartTime = generalMethods.startWorkPartTime;
this.workPartTime = generalMethods.workPartTime;
this.finishWorkPartTime = generalMethods.finishWorkPartTime;
this.startFocusing = generalMethods.startFocusing;
this.stopFocusing = generalMethods.stopFocusing;
this.getWorkMoneyGain = generalMethods.getWorkMoneyGain;
this.getWorkHackExpGain = generalMethods.getWorkHackExpGain;
this.getWorkStrExpGain = generalMethods.getWorkStrExpGain;
this.getWorkDefExpGain = generalMethods.getWorkDefExpGain;
this.getWorkDexExpGain = generalMethods.getWorkDexExpGain;
this.getWorkAgiExpGain = generalMethods.getWorkAgiExpGain;
this.getWorkChaExpGain = generalMethods.getWorkChaExpGain;
this.getWorkRepGain = generalMethods.getWorkRepGain;
this.process = generalMethods.process;
this.singularityStopWork = generalMethods.singularityStopWork;
this.takeDamage = generalMethods.takeDamage;
this.regenerateHp = generalMethods.regenerateHp;
this.hospitalize = generalMethods.hospitalize;

@ -60,6 +60,7 @@ import { IPerson } from "../IPerson";
import { Player } from "../../Player";
import { WorkType } from "../../utils/WorkType";
import { isCompanyWork } from "../../Work/CompanyWork";
export function init(this: IPlayer): void {
/* Initialize Player's home computer */
@ -131,28 +132,6 @@ export function prestigeAugmentation(this: PlayerObject): void {
}
}
this.isWorking = false;
this.workHackExpGainRate = 0;
this.workStrExpGainRate = 0;
this.workDefExpGainRate = 0;
this.workDexExpGainRate = 0;
this.workAgiExpGainRate = 0;
this.workChaExpGainRate = 0;
this.workRepGainRate = 0;
this.workMoneyGainRate = 0;
this.workHackExpGained = 0;
this.workStrExpGained = 0;
this.workDefExpGained = 0;
this.workDexExpGained = 0;
this.workAgiExpGained = 0;
this.workChaExpGained = 0;
this.workRepGained = 0;
this.workMoneyGained = 0;
this.timeWorked = 0;
this.lastUpdate = new Date().getTime();
// Statistics Trackers
@ -188,8 +167,6 @@ export function prestigeSourceFile(this: IPlayer): void {
}
}
this.timeWorked = 0;
// Gang
this.gang = null;
resetGangs();
@ -499,340 +476,6 @@ export function queryStatFromString(this: IPlayer, str: string): number {
return 0;
}
/******* Working functions *******/
export function resetWorkStatus(this: IPlayer, generalType?: WorkType, group?: string): void {
if (this.workType !== WorkType.Faction && generalType === this.workType && group === this.companyName) return;
if (generalType === this.workType) return;
if (this.isWorking) this.singularityStopWork();
this.workHackExpGainRate = 0;
this.workStrExpGainRate = 0;
this.workDefExpGainRate = 0;
this.workDexExpGainRate = 0;
this.workAgiExpGainRate = 0;
this.workChaExpGainRate = 0;
this.workRepGainRate = 0;
this.workMoneyGainRate = 0;
this.workMoneyLossRate = 0;
this.workHackExpGained = 0;
this.workStrExpGained = 0;
this.workDefExpGained = 0;
this.workDexExpGained = 0;
this.workAgiExpGained = 0;
this.workChaExpGained = 0;
this.workRepGained = 0;
this.workMoneyGained = 0;
this.timeWorked = 0;
this.workType = WorkType.None;
}
export function processWorkEarnings(this: IPlayer, numCycles = 1): void {
let focusBonus = 1;
if (!this.hasAugmentation(AugmentationNames["NeuroreceptorManager"])) {
focusBonus = this.focus ? 1 : CONSTANTS.BaseFocusBonus;
}
const hackExpGain = focusBonus * this.workHackExpGainRate * numCycles;
const strExpGain = focusBonus * this.workStrExpGainRate * numCycles;
const defExpGain = focusBonus * this.workDefExpGainRate * numCycles;
const dexExpGain = focusBonus * this.workDexExpGainRate * numCycles;
const agiExpGain = focusBonus * this.workAgiExpGainRate * numCycles;
const chaExpGain = focusBonus * this.workChaExpGainRate * numCycles;
const moneyGain = (this.workMoneyGainRate - this.workMoneyLossRate) * numCycles;
this.gainHackingExp(hackExpGain);
this.gainStrengthExp(strExpGain);
this.gainDefenseExp(defExpGain);
this.gainDexterityExp(dexExpGain);
this.gainAgilityExp(agiExpGain);
this.gainCharismaExp(chaExpGain);
this.gainMoney(moneyGain, "work");
this.workHackExpGained += hackExpGain;
this.workStrExpGained += strExpGain;
this.workDefExpGained += defExpGain;
this.workDexExpGained += dexExpGain;
this.workAgiExpGained += agiExpGain;
this.workChaExpGained += chaExpGain;
this.workRepGained += focusBonus * this.workRepGainRate * numCycles;
this.workMoneyGained += focusBonus * this.workMoneyGainRate * numCycles;
this.workMoneyGained -= focusBonus * this.workMoneyLossRate * numCycles;
}
/* Working for Company */
export function startWork(this: IPlayer, companyName: string): void {
this.resetWorkStatus(WorkType.Company, companyName);
this.isWorking = true;
this.companyName = companyName;
this.workType = WorkType.Company;
this.workHackExpGainRate = this.getWorkHackExpGain();
this.workStrExpGainRate = this.getWorkStrExpGain();
this.workDefExpGainRate = this.getWorkDefExpGain();
this.workDexExpGainRate = this.getWorkDexExpGain();
this.workAgiExpGainRate = this.getWorkAgiExpGain();
this.workChaExpGainRate = this.getWorkChaExpGain();
this.workRepGainRate = this.getWorkRepGain();
this.workMoneyGainRate = this.getWorkMoneyGain();
this.timeNeededToCompleteWork = CONSTANTS.MillisecondsPer8Hours;
}
export function process(this: IPlayer, router: IRouter, numCycles = 1): void {
// Working
if (this.isWorking) {
if (this.workType === WorkType.CompanyPartTime) {
if (this.workPartTime(numCycles)) {
router.toCity();
}
} else if (this.work(numCycles)) {
router.toCity();
}
}
}
export function cancelationPenalty(this: IPlayer): number {
const data = serverMetadata.find((s) => s.specialName === this.companyName);
if (!data) return 0.5; // Does not have special server.
const server = GetServer(data.hostname);
if (server instanceof Server) {
if (server && server.backdoorInstalled) return 0.75;
}
return 0.5;
}
export function work(this: IPlayer, numCycles: number): boolean {
// Cap the number of cycles being processed to whatever would put you at
// the work time limit (8 hours)
let overMax = false;
if (this.timeWorked + CONSTANTS._idleSpeed * numCycles >= CONSTANTS.MillisecondsPer8Hours) {
overMax = true;
numCycles = Math.round((CONSTANTS.MillisecondsPer8Hours - this.timeWorked) / CONSTANTS._idleSpeed);
}
this.timeWorked += CONSTANTS._idleSpeed * numCycles;
this.workRepGainRate = this.getWorkRepGain();
this.workMoneyGainRate = this.getWorkMoneyGain();
this.processWorkEarnings(numCycles);
const comp = Companies[this.companyName];
influenceStockThroughCompanyWork(comp, this.workRepGainRate, numCycles);
// If timeWorked == 8 hours, then finish. You can only gain 8 hours worth of exp and money
if (overMax || this.timeWorked >= CONSTANTS.MillisecondsPer8Hours) {
this.finishWork(false);
return true;
}
return false;
}
export function finishWork(this: IPlayer, cancelled: boolean, sing = false): string {
//Since the work was cancelled early, player only gains half of what they've earned so far
if (cancelled) {
this.workRepGained *= this.cancelationPenalty();
}
const penaltyString = this.cancelationPenalty() === 0.5 ? "half" : "three-quarters";
const company = Companies[this.companyName];
company.playerReputation += this.workRepGained;
this.updateSkillLevels();
let content = (
<>
You earned a total of: <br />
<Money money={this.workMoneyGained} />
<br />
<Reputation reputation={this.workRepGained} /> reputation for the company <br />
{this.workHackExpGained > 0 && (
<>
{numeralWrapper.formatExp(this.workHackExpGained)} hacking exp <br />
</>
)}
{this.workStrExpGained > 0 && (
<>
{numeralWrapper.formatExp(this.workStrExpGained)} strength exp <br />
</>
)}
{this.workDefExpGained > 0 && (
<>
{numeralWrapper.formatExp(this.workDefExpGained)} defense exp <br />
</>
)}
{this.workDexExpGained > 0 && (
<>
{numeralWrapper.formatExp(this.workDexExpGained)} dexterity exp <br />
</>
)}
{this.workAgiExpGained > 0 && (
<>
{numeralWrapper.formatExp(this.workAgiExpGained)} agility exp <br />
</>
)}
{this.workChaExpGained > 0 && (
<>
{numeralWrapper.formatExp(this.workChaExpGained)} charisma exp <br />
</>
)}
<br />
</>
);
if (cancelled) {
content = (
<>
You worked a short shift of {convertTimeMsToTimeElapsedString(this.timeWorked)} <br />
<br />
Since you cancelled your work early, you only gained {penaltyString} of the reputation you earned. <br />
<br />
{content}
</>
);
} else {
content = (
<>
You worked a full shift of 8 hours! <br />
<br />
{content}
</>
);
}
if (!sing) {
dialogBoxCreate(content);
}
this.isWorking = false;
this.focus = false;
this.resetWorkStatus();
if (sing) {
const res =
"You worked a short shift of " +
convertTimeMsToTimeElapsedString(this.timeWorked) +
" and " +
"earned $" +
numeralWrapper.formatMoney(this.workMoneyGained) +
", " +
numeralWrapper.formatReputation(this.workRepGained) +
" reputation, " +
numeralWrapper.formatExp(this.workHackExpGained) +
" hacking exp, " +
numeralWrapper.formatExp(this.workStrExpGained) +
" strength exp, " +
numeralWrapper.formatExp(this.workDefExpGained) +
" defense exp, " +
numeralWrapper.formatExp(this.workDexExpGained) +
" dexterity exp, " +
numeralWrapper.formatExp(this.workAgiExpGained) +
" agility exp, and " +
numeralWrapper.formatExp(this.workChaExpGained) +
" charisma exp.";
return res;
}
return "";
}
export function startWorkPartTime(this: IPlayer, companyName: string): void {
this.resetWorkStatus(WorkType.CompanyPartTime, companyName);
this.isWorking = true;
this.companyName = companyName;
this.workType = WorkType.CompanyPartTime;
this.workHackExpGainRate = this.getWorkHackExpGain();
this.workStrExpGainRate = this.getWorkStrExpGain();
this.workDefExpGainRate = this.getWorkDefExpGain();
this.workDexExpGainRate = this.getWorkDexExpGain();
this.workAgiExpGainRate = this.getWorkAgiExpGain();
this.workChaExpGainRate = this.getWorkChaExpGain();
this.workRepGainRate = this.getWorkRepGain();
this.workMoneyGainRate = this.getWorkMoneyGain();
this.timeNeededToCompleteWork = CONSTANTS.MillisecondsPer8Hours;
}
export function workPartTime(this: IPlayer, numCycles: number): boolean {
//Cap the number of cycles being processed to whatever would put you at the
//work time limit (8 hours)
let overMax = false;
if (this.timeWorked + CONSTANTS._idleSpeed * numCycles >= CONSTANTS.MillisecondsPer8Hours) {
overMax = true;
numCycles = Math.round((CONSTANTS.MillisecondsPer8Hours - this.timeWorked) / CONSTANTS._idleSpeed);
}
this.timeWorked += CONSTANTS._idleSpeed * numCycles;
this.workRepGainRate = this.getWorkRepGain();
this.processWorkEarnings(numCycles);
//If timeWorked == 8 hours, then finish. You can only gain 8 hours worth of exp and money
if (overMax || this.timeWorked >= CONSTANTS.MillisecondsPer8Hours) {
this.finishWorkPartTime();
return true;
}
return false;
}
export function finishWorkPartTime(this: IPlayer, sing = false): string {
const company = Companies[this.companyName];
company.playerReputation += this.workRepGained;
this.updateSkillLevels();
const content = (
<>
You worked for {convertTimeMsToTimeElapsedString(this.timeWorked)}
<br />
<br />
You earned a total of: <br />
<Money money={this.workMoneyGained} />
<br />
<Reputation reputation={this.workRepGained} /> reputation for the company <br />
{numeralWrapper.formatExp(this.workHackExpGained)} hacking exp <br />
{numeralWrapper.formatExp(this.workStrExpGained)} strength exp <br />
{numeralWrapper.formatExp(this.workDefExpGained)} defense exp <br />
{numeralWrapper.formatExp(this.workDexExpGained)} dexterity exp <br />
{numeralWrapper.formatExp(this.workAgiExpGained)} agility exp <br />
{numeralWrapper.formatExp(this.workChaExpGained)} charisma exp
<br />
</>
);
if (!sing) {
dialogBoxCreate(content);
}
this.isWorking = false;
this.resetWorkStatus();
if (sing) {
const res =
"You worked for " +
convertTimeMsToTimeElapsedString(this.timeWorked) +
" and " +
"earned a total of " +
"$" +
numeralWrapper.formatMoney(this.workMoneyGained) +
", " +
numeralWrapper.formatReputation(this.workRepGained) +
" reputation, " +
numeralWrapper.formatExp(this.workHackExpGained) +
" hacking exp, " +
numeralWrapper.formatExp(this.workStrExpGained) +
" strength exp, " +
numeralWrapper.formatExp(this.workDefExpGained) +
" defense exp, " +
numeralWrapper.formatExp(this.workDexExpGained) +
" dexterity exp, " +
numeralWrapper.formatExp(this.workAgiExpGained) +
" agility exp, and " +
numeralWrapper.formatExp(this.workChaExpGained) +
" charisma exp";
return res;
}
return "";
}
export function startFocusing(this: IPlayer): void {
this.focus = true;
}
@ -841,236 +484,6 @@ export function stopFocusing(this: IPlayer): void {
this.focus = false;
}
//Money gained per game cycle
export function getWorkMoneyGain(this: IPlayer): number {
// If player has SF-11, calculate salary multiplier from favor
let bn11Mult = 1;
const company = Companies[this.companyName];
if (this.sourceFileLvl(11) > 0) {
bn11Mult = 1 + company.favor / 100;
}
// Get base salary
const companyPositionName = this.jobs[this.companyName];
const companyPosition = CompanyPositions[companyPositionName];
if (companyPosition == null) {
console.error(`Could not find CompanyPosition object for ${companyPositionName}. Work salary will be 0`);
return 0;
}
return (
companyPosition.baseSalary *
company.salaryMultiplier *
this.work_money_mult *
BitNodeMultipliers.CompanyWorkMoney *
bn11Mult
);
}
//Hack exp gained per game cycle
export function getWorkHackExpGain(this: IPlayer): number {
const company = Companies[this.companyName];
const companyPositionName = this.jobs[this.companyName];
const companyPosition = CompanyPositions[companyPositionName];
if (company == null || companyPosition == null) {
console.error(
[
`Could not find Company object for ${this.companyName}`,
`or CompanyPosition object for ${companyPositionName}.`,
`Work hack exp gain will be 0`,
].join(" "),
);
return 0;
}
return (
companyPosition.hackingExpGain *
company.expMultiplier *
this.hacking_exp_mult *
BitNodeMultipliers.CompanyWorkExpGain
);
}
//Str exp gained per game cycle
export function getWorkStrExpGain(this: IPlayer): number {
const company = Companies[this.companyName];
const companyPositionName = this.jobs[this.companyName];
const companyPosition = CompanyPositions[companyPositionName];
if (company == null || companyPosition == null) {
console.error(
[
`Could not find Company object for ${this.companyName}`,
`or CompanyPosition object for ${companyPositionName}.`,
`Work str exp gain will be 0`,
].join(" "),
);
return 0;
}
return (
companyPosition.strengthExpGain *
company.expMultiplier *
this.strength_exp_mult *
BitNodeMultipliers.CompanyWorkExpGain
);
}
//Def exp gained per game cycle
export function getWorkDefExpGain(this: IPlayer): number {
const company = Companies[this.companyName];
const companyPositionName = this.jobs[this.companyName];
const companyPosition = CompanyPositions[companyPositionName];
if (company == null || companyPosition == null) {
console.error(
[
`Could not find Company object for ${this.companyName}`,
`or CompanyPosition object for ${companyPositionName}.`,
`Work def exp gain will be 0`,
].join(" "),
);
return 0;
}
return (
companyPosition.defenseExpGain *
company.expMultiplier *
this.defense_exp_mult *
BitNodeMultipliers.CompanyWorkExpGain
);
}
//Dex exp gained per game cycle
export function getWorkDexExpGain(this: IPlayer): number {
const company = Companies[this.companyName];
const companyPositionName = this.jobs[this.companyName];
const companyPosition = CompanyPositions[companyPositionName];
if (company == null || companyPosition == null) {
console.error(
[
`Could not find Company object for ${this.companyName}`,
`or CompanyPosition object for ${companyPositionName}.`,
`Work dex exp gain will be 0`,
].join(" "),
);
return 0;
}
return (
companyPosition.dexterityExpGain *
company.expMultiplier *
this.dexterity_exp_mult *
BitNodeMultipliers.CompanyWorkExpGain
);
}
//Agi exp gained per game cycle
export function getWorkAgiExpGain(this: IPlayer): number {
const company = Companies[this.companyName];
const companyPositionName = this.jobs[this.companyName];
const companyPosition = CompanyPositions[companyPositionName];
if (company == null || companyPosition == null) {
console.error(
[
`Could not find Company object for ${this.companyName}`,
`or CompanyPosition object for ${companyPositionName}.`,
`Work agi exp gain will be 0`,
].join(" "),
);
return 0;
}
return (
companyPosition.agilityExpGain *
company.expMultiplier *
this.agility_exp_mult *
BitNodeMultipliers.CompanyWorkExpGain
);
}
//Charisma exp gained per game cycle
export function getWorkChaExpGain(this: IPlayer): number {
const company = Companies[this.companyName];
const companyPositionName = this.jobs[this.companyName];
const companyPosition = CompanyPositions[companyPositionName];
if (company == null || companyPosition == null) {
console.error(
[
`Could not find Company object for ${this.companyName}`,
`or CompanyPosition object for ${companyPositionName}.`,
`Work cha exp gain will be 0`,
].join(" "),
);
return 0;
}
return (
companyPosition.charismaExpGain *
company.expMultiplier *
this.charisma_exp_mult *
BitNodeMultipliers.CompanyWorkExpGain
);
}
//Reputation gained per game cycle
export function getWorkRepGain(this: IPlayer): number {
const company = Companies[this.companyName];
const companyPositionName = this.jobs[this.companyName];
const companyPosition = CompanyPositions[companyPositionName];
if (company == null || companyPosition == null) {
console.error(
[
`Could not find Company object for ${this.companyName}`,
`or CompanyPosition object for ${companyPositionName}.`,
`Work rep gain will be 0`,
].join(" "),
);
return 0;
}
let jobPerformance = companyPosition.calculateJobPerformance(
this.hacking,
this.strength,
this.defense,
this.dexterity,
this.agility,
this.charisma,
);
//Intelligence provides a flat bonus to job performance
jobPerformance += this.intelligence / CONSTANTS.MaxSkillLevel;
//Update reputation gain rate to account for company favor
let favorMult = 1 + company.favor / 100;
if (isNaN(favorMult)) {
favorMult = 1;
}
return jobPerformance * this.company_rep_mult * favorMult;
}
//Cancels the player's current "work" assignment and gives the proper rewards
//Used only for Singularity functions, so no popups are created
export function singularityStopWork(this: IPlayer): string {
if (this.currentWork !== null) {
this.finishNEWWork(true);
}
if (!this.isWorking) {
return "";
}
let res = ""; //Earnings text for work
switch (this.workType) {
case WorkType.Company:
res = this.finishWork(true, true);
break;
case WorkType.CompanyPartTime:
res = this.finishWorkPartTime(true);
break;
default:
console.error(`Unrecognized work type (${this.workType})`);
return "";
}
return res;
}
// Returns true if hospitalized, false otherwise
export function takeDamage(this: IPlayer, amt: number): boolean {
if (typeof amt !== "number") {
@ -1155,7 +568,6 @@ export function applyForJob(this: IPlayer, entryPosType: CompanyPosition, sing =
}
this.jobs[company.name] = pos.name;
if (!this.isWorking || this.workType !== WorkType.Company) this.companyName = company.name;
if (!sing) {
dialogBoxCreate("Congratulations! You were offered a new job at " + company.name + " as a " + pos.name + "!");
@ -1204,12 +616,8 @@ export function getNextCompanyPosition(
}
export function quitJob(this: IPlayer, company: string, _sing = false): void {
if (
this.isWorking === true &&
[WorkType.Company, WorkType.CompanyPartTime].includes(this.workType) &&
this.companyName === company
) {
this.finishWork(true);
if (isCompanyWork(this.currentWork) && this.currentWork.companyName === company) {
this.finishNEWWork(true);
}
delete this.jobs[company];
if (this.companyName === company) {
@ -1299,7 +707,6 @@ export function applyForEmployeeJob(this: IPlayer, sing = false): boolean {
}
if (this.isQualified(company, CompanyPositions[position])) {
this.jobs[company.name] = position;
if (!this.focus && this.isWorking && this.companyName !== company.name) this.resetWorkStatus();
this.companyName = company.name;
if (!sing) {
@ -1325,7 +732,6 @@ export function applyForPartTimeEmployeeJob(this: IPlayer, sing = false): boolea
}
if (this.isQualified(company, CompanyPositions[position])) {
this.jobs[company.name] = position;
if (!this.focus && this.isWorking && this.companyName !== company.name) this.resetWorkStatus();
this.companyName = company.name;
if (!sing) {
dialogBoxCreate("Congratulations, you are now employed part-time at " + this.location);
@ -1350,7 +756,6 @@ export function applyForWaiterJob(this: IPlayer, sing = false): boolean {
}
if (this.isQualified(company, CompanyPositions[position])) {
this.jobs[company.name] = position;
if (!this.focus && this.isWorking && this.companyName !== company.name) this.resetWorkStatus();
this.companyName = company.name;
if (!sing) {
dialogBoxCreate("Congratulations, you are now employed as a waiter at " + this.location);
@ -1373,7 +778,6 @@ export function applyForPartTimeWaiterJob(this: IPlayer, sing = false): boolean
}
if (this.isQualified(company, CompanyPositions[position])) {
this.jobs[company.name] = position;
if (!this.focus && this.isWorking && this.companyName !== company.name) this.resetWorkStatus();
this.companyName = company.name;
if (!sing) {
dialogBoxCreate("Congratulations, you are now employed as a part-time waiter at " + this.location);

@ -47,25 +47,6 @@ interface Player {
companyName: string;
crime_money_mult: number;
crime_success_mult: number;
isWorking: boolean;
workType: string;
workHackExpGainRate: number;
workStrExpGainRate: number;
workDefExpGainRate: number;
workDexExpGainRate: number;
workAgiExpGainRate: number;
workChaExpGainRate: number;
workRepGainRate: number;
workMoneyGainRate: number;
workMoneyLossRate: number;
workHackExpGained: number;
workStrExpGained: number;
workDefExpGained: number;
workDexExpGained: number;
workAgiExpGained: number;
workChaExpGained: number;
workRepGained: number;
workMoneyGained: number;
work_money_mult: number;
hacknet_node_money_mult: number;
hacknet_node_purchase_cost_mult: number;
@ -737,24 +718,6 @@ export interface CharacterInfo {
tor: boolean;
/** Object with many of the player's multipliers from Augmentations/Source Files */
mult: CharacterMult;
/** Timed worked in ms */
timeWorked: number;
/** Hacking experience earned so far from work */
workHackExpGain: number;
/** Str experience earned so far from work */
workStrExpGain: number;
/** Def experience earned so far from work */
workDefExpGain: number;
/** Dex experience earned so far from work */
workDexExpGain: number;
/** Agi experience earned so far from work */
workAgiExpGain: number;
/** Cha experience earned so far from work */
workChaExpGain: number;
/** Reputation earned so far from work, if applicable */
workRepGain: number;
/** Money earned so far from work, if applicable */
workMoneyGain: number;
/** total hacking exp */
hackingExp: number;
/** total strength exp */

@ -276,7 +276,7 @@ export function SidebarRoot(props: IProps): React.ReactElement {
// Alt-g - Gang
function handleShortcuts(this: Document, event: KeyboardEvent): any {
if (Settings.DisableHotkeys) return;
if ((props.player.isWorking && props.player.focus) || props.router.page() === Page.BitVerse) return;
if ((props.player.currentWork && props.player.focus) || props.router.page() === Page.BitVerse) return;
if (event.code === KEYCODE.T && event.altKey) {
event.preventDefault();
clickTerminal();

@ -96,11 +96,7 @@ const Engine: {
Terminal.process(Router, Player, numCycles);
if (Player.currentWork !== null) {
Player.processNEWWork(numCycles);
} else {
Player.process(Router, numCycles);
}
Player.processNEWWork(numCycles);
// Update stock prices
if (Player.hasWseAccount) {
@ -300,15 +296,6 @@ const Engine: {
if (Player.currentWork !== null) {
Player.focus = true;
Player.processNEWWork(numCyclesOffline);
} else if (Player.isWorking) {
Player.focus = true;
switch (Player.workType) {
case WorkType.CompanyPartTime:
Player.workPartTime(numCyclesOffline);
break;
default:
Player.work(numCyclesOffline);
}
} else {
for (let i = 0; i < Player.factions.length; i++) {
const facName = Player.factions[i];

@ -155,7 +155,7 @@ export let Router: IRouter = {
function determineStartPage(player: IPlayer): Page {
if (RecoveryMode) return Page.Recovery;
if (player.isWorking || player.currentWork !== null) return Page.Work;
if (player.currentWork !== null) return Page.Work;
return Page.Terminal;
}

@ -144,7 +144,7 @@ function Work(): React.ReactElement {
player.startFocusing();
router.toWork();
};
if ((!player.isWorking && player.currentWork === null) || player.focus) return <></>;
if (player.currentWork === null || player.focus) return <></>;
let details = <></>;
let header = <></>;

@ -134,87 +134,6 @@ export function WorkInProgressRoot(): React.ReactElement {
const player = use.Player();
const router = use.Router();
let expGains = [
player.workHackExpGained > 0 ? (
<StatsRow
name="Hacking Exp"
color={Settings.theme.hack}
data={{
content: `${numeralWrapper.formatExp(player.workHackExpGained)} (${numeralWrapper.formatExp(
player.workHackExpGainRate * CYCLES_PER_SEC,
)} / sec)`,
}}
/>
) : (
<></>
),
player.workStrExpGained > 0 ? (
<StatsRow
name="Strength Exp"
color={Settings.theme.combat}
data={{
content: `${numeralWrapper.formatExp(player.workStrExpGained)} (${numeralWrapper.formatExp(
player.workStrExpGainRate * CYCLES_PER_SEC,
)} / sec)`,
}}
/>
) : (
<></>
),
player.workDefExpGained > 0 ? (
<StatsRow
name="Defense Exp"
color={Settings.theme.combat}
data={{
content: `${numeralWrapper.formatExp(player.workDefExpGained)} (${numeralWrapper.formatExp(
player.workDefExpGainRate * CYCLES_PER_SEC,
)} / sec)`,
}}
/>
) : (
<></>
),
player.workDexExpGained > 0 ? (
<StatsRow
name="Dexterity Exp"
color={Settings.theme.combat}
data={{
content: `${numeralWrapper.formatExp(player.workDexExpGained)} (${numeralWrapper.formatExp(
player.workDexExpGainRate * CYCLES_PER_SEC,
)} / sec)`,
}}
/>
) : (
<></>
),
player.workAgiExpGained > 0 ? (
<StatsRow
name="Agility Exp"
color={Settings.theme.combat}
data={{
content: `${numeralWrapper.formatExp(player.workAgiExpGained)} (${numeralWrapper.formatExp(
player.workAgiExpGainRate * CYCLES_PER_SEC,
)} / sec)`,
}}
/>
) : (
<></>
),
player.workChaExpGained > 0 ? (
<StatsRow
name="Charisma Exp"
color={Settings.theme.cha}
data={{
content: `${numeralWrapper.formatExp(player.workChaExpGained)} (${numeralWrapper.formatExp(
player.workChaExpGainRate * CYCLES_PER_SEC,
)} / sec)`,
}}
/>
) : (
<></>
),
];
let workInfo: IWorkInfo = {
buttons: {
cancel: () => undefined,
@ -266,7 +185,6 @@ export function WorkInProgressRoot(): React.ReactElement {
}
const rates = classWork.calculateRates(player);
expGains = ExpRows(rates);
workInfo = {
buttons: {
cancel: cancel,
@ -284,7 +202,7 @@ export function WorkInProgressRoot(): React.ReactElement {
<Money money={classWork.earnings.money} /> (<MoneyRate money={rates.money * CYCLES_PER_SEC} />)
</Typography>
</StatsRow>,
...expGains,
...ExpRows(rates),
],
progress: {
elapsed: classWork.cyclesWorked * CONSTANTS._idleSpeed,