refactor some stuff

This commit is contained in:
Olivier Gagnon
2022-07-14 17:43:08 -04:00
parent a5088f1136
commit 0550bc188c
22 changed files with 149 additions and 119 deletions
+8 -6
View File
@@ -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 {
@@ -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;
}
@@ -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 {