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

@ -33,7 +33,7 @@ export function StartButton(props: IProps): React.ReactElement {
if (disabled) return; if (disabled) return;
props.bladeburner.action.type = props.type; props.bladeburner.action.type = props.type;
props.bladeburner.action.name = props.name; 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.bladeburner.startAction(player, props.bladeburner.action);
props.rerender(); props.rerender();
} }

@ -101,7 +101,7 @@ export class Crime {
if (div <= 0) { if (div <= 0) {
div = 1; div = 1;
} }
p.startNEWWork( p.startWork(
new CrimeWork({ new CrimeWork({
crimeType: this.type, crimeType: this.type,
singularity: workerScript !== null, singularity: workerScript !== null,

@ -76,7 +76,7 @@ export function buyDarkwebItem(itemName: string): void {
Player.getHomeComputer().pushProgram(item.program); Player.getHomeComputer().pushProgram(item.program);
// Cancel if the program is in progress of writing // Cancel if the program is in progress of writing
if (isCreateProgramWork(Player.currentWork) && Player.currentWork.programName === item.program) { if (isCreateProgramWork(Player.currentWork) && Player.currentWork.programName === item.program) {
Player.finishNEWWork(true); Player.finishWork(true);
} }
Terminal.print( Terminal.print(

@ -69,7 +69,7 @@ function MainPage({ faction, rerender, onAugmentations }: IMainProps): React.Rea
} }
function startFieldWork(faction: Faction): void { function startFieldWork(faction: Faction): void {
player.startNEWWork( player.startWork(
new FactionWork({ new FactionWork({
singularity: false, singularity: false,
faction: faction.name, faction: faction.name,
@ -80,7 +80,7 @@ function MainPage({ faction, rerender, onAugmentations }: IMainProps): React.Rea
} }
function startHackingContracts(faction: Faction): void { function startHackingContracts(faction: Faction): void {
player.startNEWWork( player.startWork(
new FactionWork({ new FactionWork({
singularity: false, singularity: false,
faction: faction.name, faction: faction.name,
@ -91,7 +91,7 @@ function MainPage({ faction, rerender, onAugmentations }: IMainProps): React.Rea
} }
function startSecurityWork(faction: Faction): void { function startSecurityWork(faction: Faction): void {
player.startNEWWork( player.startWork(
new FactionWork({ new FactionWork({
singularity: false, singularity: false,
faction: faction.name, faction: faction.name,

@ -176,7 +176,7 @@ export function CompanyLocation(props: IProps): React.ReactElement {
const pos = companyPosition; const pos = companyPosition;
if (pos instanceof CompanyPosition) { if (pos instanceof CompanyPosition) {
p.startNEWWork( p.startWork(
new CompanyWork({ new CompanyWork({
singularity: false, singularity: false,
companyName: props.locName, companyName: props.locName,

@ -24,7 +24,7 @@ type IProps = {
export function GymLocation(props: IProps): React.ReactElement { export function GymLocation(props: IProps): React.ReactElement {
function train(stat: ClassType): void { function train(stat: ClassType): void {
props.p.startNEWWork( props.p.startWork(
new ClassWork({ new ClassWork({
classType: stat, classType: stat,
location: props.loc.name, location: props.loc.name,

@ -25,7 +25,7 @@ export function UniversityLocation(props: IProps): React.ReactElement {
const router = use.Router(); const router = use.Router();
function take(classType: ClassType): void { function take(classType: ClassType): void {
player.startNEWWork( player.startWork(
new ClassWork({ new ClassWork({
classType: classType, classType: classType,
location: props.loc.name, location: props.loc.name,

@ -76,7 +76,7 @@ export function NetscriptGrafting(player: IPlayer): InternalAPI<IGrafting> {
return false; return false;
} }
player.startNEWWork( player.startWork(
new GraftingWork({ new GraftingWork({
singularity: true, singularity: true,
augmentation: augName, augmentation: augName,

@ -49,7 +49,6 @@ import { InternalAPI, NetscriptContext } from "src/Netscript/APIWrapper";
import { BlackOperationNames } from "../Bladeburner/data/BlackOperationNames"; import { BlackOperationNames } from "../Bladeburner/data/BlackOperationNames";
import { enterBitNode } from "../RedPill"; import { enterBitNode } from "../RedPill";
import { FactionNames } from "../Faction/data/FactionNames"; import { FactionNames } from "../Faction/data/FactionNames";
import { WorkType } from "../utils/WorkType";
import { ClassWork, ClassType } from "../Work/ClassWork"; import { ClassWork, ClassType } from "../Work/ClassWork";
import { CreateProgramWork, isCreateProgramWork } from "../Work/CreateProgramWork"; import { CreateProgramWork, isCreateProgramWork } from "../Work/CreateProgramWork";
import { FactionWork } from "../Work/FactionWork"; import { FactionWork } from "../Work/FactionWork";
@ -323,7 +322,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
_ctx.log(() => `Invalid class name: ${className}.`); _ctx.log(() => `Invalid class name: ${className}.`);
return false; return false;
} }
player.startNEWWork( player.startWork(
new ClassWork({ new ClassWork({
classType: task, classType: task,
location: player.location, location: player.location,
@ -408,25 +407,25 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
switch (stat.toLowerCase()) { switch (stat.toLowerCase()) {
case "strength".toLowerCase(): case "strength".toLowerCase():
case "str".toLowerCase(): case "str".toLowerCase():
player.startNEWWork( player.startWork(
new ClassWork({ classType: ClassType.GymStrength, location: player.location, singularity: true }), new ClassWork({ classType: ClassType.GymStrength, location: player.location, singularity: true }),
); );
break; break;
case "defense".toLowerCase(): case "defense".toLowerCase():
case "def".toLowerCase(): case "def".toLowerCase():
player.startNEWWork( player.startWork(
new ClassWork({ classType: ClassType.GymDefense, location: player.location, singularity: true }), new ClassWork({ classType: ClassType.GymDefense, location: player.location, singularity: true }),
); );
break; break;
case "dexterity".toLowerCase(): case "dexterity".toLowerCase():
case "dex".toLowerCase(): case "dex".toLowerCase():
player.startNEWWork( player.startWork(
new ClassWork({ classType: ClassType.GymDexterity, location: player.location, singularity: true }), new ClassWork({ classType: ClassType.GymDexterity, location: player.location, singularity: true }),
); );
break; break;
case "agility".toLowerCase(): case "agility".toLowerCase():
case "agi".toLowerCase(): case "agi".toLowerCase():
player.startNEWWork( player.startWork(
new ClassWork({ classType: ClassType.GymAgility, location: player.location, singularity: true }), new ClassWork({ classType: ClassType.GymAgility, location: player.location, singularity: true }),
); );
break; break;
@ -526,7 +525,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
player.getHomeComputer().pushProgram(item.program); player.getHomeComputer().pushProgram(item.program);
// Cancel if the program is in progress of writing // Cancel if the program is in progress of writing
if (isCreateProgramWork(player.currentWork) && player.currentWork.programName === item.program) { if (isCreateProgramWork(player.currentWork) && player.currentWork.programName === item.program) {
player.finishNEWWork(true); player.finishWork(true);
} }
player.loseMoney(item.price, "other"); player.loseMoney(item.price, "other");
@ -725,7 +724,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
function (): boolean { function (): boolean {
_ctx.helper.checkSingularityAccess(); _ctx.helper.checkSingularityAccess();
const wasWorking = player.currentWork !== null; const wasWorking = player.currentWork !== null;
player.finishNEWWork(true); player.finishWork(true);
return wasWorking; return wasWorking;
}, },
upgradeHomeCores: (_ctx: NetscriptContext) => upgradeHomeCores: (_ctx: NetscriptContext) =>
@ -826,7 +825,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
const wasFocused = player.focus; const wasFocused = player.focus;
player.startNEWWork( player.startWork(
new CompanyWork({ new CompanyWork({
singularity: true, singularity: true,
companyName: companyName, 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.`); _ctx.log(() => `Faction '${faction.name}' do not need help with hacking contracts.`);
return false; return false;
} }
player.startNEWWork( player.startWork(
new FactionWork({ new FactionWork({
singularity: true, singularity: true,
factionWorkType: FactionWorkType.HACKING, 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.`); _ctx.log(() => `Faction '${faction.name}' do not need help with field missions.`);
return false; return false;
} }
player.startNEWWork( player.startWork(
new FactionWork({ new FactionWork({
singularity: true, singularity: true,
factionWorkType: FactionWorkType.FIELD, 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.`); _ctx.log(() => `Faction '${faction.name}' do not need help with security work.`);
return false; return false;
} }
player.startNEWWork( player.startWork(
new FactionWork({ new FactionWork({
singularity: true, singularity: true,
factionWorkType: FactionWorkType.SECURITY, factionWorkType: FactionWorkType.SECURITY,
@ -1158,7 +1157,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
return false; return false;
} }
player.startNEWWork( player.startWork(
new CreateProgramWork({ new CreateProgramWork({
programName: p.name, programName: p.name,
singularity: true, singularity: true,
@ -1181,7 +1180,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
const crimeRoughName = _ctx.helper.string("crimeRoughName", _crimeRoughName); const crimeRoughName = _ctx.helper.string("crimeRoughName", _crimeRoughName);
if (player.currentWork !== null) { if (player.currentWork !== null) {
player.finishNEWWork(true); player.finishWork(true);
} }
// Set Location to slums // Set Location to slums

@ -155,7 +155,7 @@ export const GraftingRoot = (): React.ReactElement => {
open={graftOpen} open={graftOpen}
onClose={() => setGraftOpen(false)} onClose={() => setGraftOpen(false)}
onConfirm={() => { onConfirm={() => {
player.startNEWWork( player.startWork(
new GraftingWork({ new GraftingWork({
augmentation: selectedAug, augmentation: selectedAug,
singularity: false, singularity: false,

@ -25,12 +25,10 @@ import { ICorporation } from "../Corporation/ICorporation";
import { IGang } from "../Gang/IGang"; import { IGang } from "../Gang/IGang";
import { IBladeburner } from "../Bladeburner/IBladeburner"; import { IBladeburner } from "../Bladeburner/IBladeburner";
import { ICodingContractReward } from "../CodingContracts"; import { ICodingContractReward } from "../CodingContracts";
import { IRouter } from "../ui/Router";
import { HacknetServer } from "../Hacknet/HacknetServer"; import { HacknetServer } from "../Hacknet/HacknetServer";
import { ISkillProgress } from "./formulas/skill"; import { ISkillProgress } from "./formulas/skill";
import { PlayerAchievement } from "../Achievements/Achievements"; import { PlayerAchievement } from "../Achievements/Achievements";
import { IPerson } from "./IPerson"; import { IPerson } from "./IPerson";
import { WorkType } from "../utils/WorkType";
import { Work } from "src/Work/Work"; import { Work } from "src/Work/Work";
export interface IPlayer extends IPerson { export interface IPlayer extends IPerson {
@ -51,7 +49,6 @@ export interface IPlayer extends IPerson {
hasWseAccount: boolean; hasWseAccount: boolean;
hp: number; hp: number;
jobs: IMap<string>; jobs: IMap<string>;
init: () => void;
karma: number; karma: number;
numPeopleKilled: number; numPeopleKilled: number;
location: LocationName; location: LocationName;
@ -129,9 +126,10 @@ export interface IPlayer extends IPerson {
entropy: number; entropy: number;
// Methods // Methods
startNEWWork(w: Work): void; init: () => void;
processNEWWork(cycles: number): void; startWork(w: Work): void;
finishNEWWork(cancelled: boolean): void; processWork(cycles: number): void;
finishWork(cancelled: boolean): void;
applyForAgentJob(sing?: boolean): boolean; applyForAgentJob(sing?: boolean): boolean;
applyForBusinessConsultantJob(sing?: boolean): boolean; applyForBusinessConsultantJob(sing?: boolean): boolean;
applyForBusinessJob(sing?: boolean): boolean; applyForBusinessJob(sing?: boolean): boolean;
@ -201,4 +199,5 @@ export interface IPlayer extends IPerson {
canAccessCotMG(): boolean; canAccessCotMG(): boolean;
sourceFileLvl(n: number): number; sourceFileLvl(n: number): number;
applyEntropy(stacks?: number): void; applyEntropy(stacks?: number): void;
focusPenalty(): number;
} }

@ -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,
};
};

@ -140,9 +140,9 @@ export class PlayerObject implements IPlayer {
entropy: number; entropy: number;
// Methods // Methods
startNEWWork: (w: Work) => void; startWork: (w: Work) => void;
processNEWWork: (cycles: number) => void; processWork: (cycles: number) => void;
finishNEWWork: (cancelled: boolean) => void; finishWork: (cancelled: boolean) => void;
applyForAgentJob: (sing?: boolean) => boolean; applyForAgentJob: (sing?: boolean) => boolean;
applyForBusinessConsultantJob: (sing?: boolean) => boolean; applyForBusinessConsultantJob: (sing?: boolean) => boolean;
applyForBusinessJob: (sing?: boolean) => boolean; applyForBusinessJob: (sing?: boolean) => boolean;
@ -226,6 +226,7 @@ export class PlayerObject implements IPlayer {
canAccessCotMG: () => boolean; canAccessCotMG: () => boolean;
sourceFileLvl: (n: number) => number; sourceFileLvl: (n: number) => number;
applyEntropy: (stacks?: number) => void; applyEntropy: (stacks?: number) => void;
focusPenalty: () => number;
constructor() { constructor() {
//Skills and stats //Skills and stats
@ -409,9 +410,9 @@ export class PlayerObject implements IPlayer {
this.gainIntelligenceExp = generalMethods.gainIntelligenceExp; this.gainIntelligenceExp = generalMethods.gainIntelligenceExp;
this.gainStats = generalMethods.gainStats; this.gainStats = generalMethods.gainStats;
this.queryStatFromString = generalMethods.queryStatFromString; this.queryStatFromString = generalMethods.queryStatFromString;
this.startNEWWork = workMethods.start; this.startWork = workMethods.start;
this.processNEWWork = workMethods.process; this.processWork = workMethods.process;
this.finishNEWWork = workMethods.finish; this.finishWork = workMethods.finish;
this.startFocusing = generalMethods.startFocusing; this.startFocusing = generalMethods.startFocusing;
this.stopFocusing = generalMethods.stopFocusing; this.stopFocusing = generalMethods.stopFocusing;
this.takeDamage = generalMethods.takeDamage; this.takeDamage = generalMethods.takeDamage;
@ -477,6 +478,7 @@ export class PlayerObject implements IPlayer {
this.sourceFileLvl = generalMethods.sourceFileLvl; this.sourceFileLvl = generalMethods.sourceFileLvl;
this.applyEntropy = augmentationMethods.applyEntropy; this.applyEntropy = augmentationMethods.applyEntropy;
this.focusPenalty = generalMethods.focusPenalty;
} }
whoAmI(): string { whoAmI(): string {

@ -37,21 +37,13 @@ import { SpecialServers } from "../../Server/data/SpecialServers";
import { applySourceFile } from "../../SourceFile/applySourceFile"; import { applySourceFile } from "../../SourceFile/applySourceFile";
import { applyExploit } from "../../Exploits/applyExploits"; import { applyExploit } from "../../Exploits/applyExploits";
import { SourceFiles } from "../../SourceFile/SourceFiles"; import { SourceFiles } from "../../SourceFile/SourceFiles";
import { influenceStockThroughCompanyWork } from "../../StockMarket/PlayerInfluencing";
import { getHospitalizationCost } from "../../Hospital/Hospital"; import { getHospitalizationCost } from "../../Hospital/Hospital";
import { HacknetServer } from "../../Hacknet/HacknetServer"; import { HacknetServer } from "../../Hacknet/HacknetServer";
import { numeralWrapper } from "../../ui/numeralFormat"; import { numeralWrapper } from "../../ui/numeralFormat";
import { IRouter } from "../../ui/Router";
import { MoneySourceTracker } from "../../utils/MoneySourceTracker"; import { MoneySourceTracker } from "../../utils/MoneySourceTracker";
import { dialogBoxCreate } from "../../ui/React/DialogBox"; 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 { SnackbarEvents, ToastVariant } from "../../ui/React/Snackbar";
import { achievements } from "../../Achievements/Achievements"; import { achievements } from "../../Achievements/Achievements";
import { FactionNames } from "../../Faction/data/FactionNames"; import { FactionNames } from "../../Faction/data/FactionNames";
@ -59,7 +51,6 @@ import { ITaskTracker } from "../ITaskTracker";
import { IPerson } from "../IPerson"; import { IPerson } from "../IPerson";
import { Player } from "../../Player"; import { Player } from "../../Player";
import { WorkType } from "../../utils/WorkType";
import { isCompanyWork } from "../../Work/CompanyWork"; import { isCompanyWork } from "../../Work/CompanyWork";
export function init(this: IPlayer): void { export function init(this: IPlayer): void {
@ -617,7 +608,7 @@ export function getNextCompanyPosition(
export function quitJob(this: IPlayer, company: string, _sing = false): void { export function quitJob(this: IPlayer, company: string, _sing = false): void {
if (isCompanyWork(this.currentWork) && this.currentWork.companyName === company) { if (isCompanyWork(this.currentWork) && this.currentWork.companyName === company) {
this.finishNEWWork(true); this.finishWork(true);
} }
delete this.jobs[company]; delete this.jobs[company];
if (this.companyName === company) { if (this.companyName === company) {
@ -1487,3 +1478,11 @@ export function sourceFileLvl(this: IPlayer, n: number): number {
if (!sf) return 0; if (!sf) return 0;
return sf.lvl; 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; if (this.currentWork === null) return;
const finished = this.currentWork.process(this, cycles); const finished = this.currentWork.process(this, cycles);
if (finished) { if (finished) {
this.finishNEWWork(false); this.finishWork(false);
} }
} }
export function finish(this: IPlayer, cancelled: boolean): void { export function finish(this: IPlayer, cancelled: boolean): void {

@ -97,7 +97,7 @@ export function ProgramsRoot(): React.ReactElement {
sx={{ my: 1, width: "100%" }} sx={{ my: 1, width: "100%" }}
onClick={(event) => { onClick={(event) => {
if (!event.isTrusted) return; if (!event.isTrusted) return;
player.startNEWWork( player.startWork(
new CreateProgramWork({ player: player, singularity: false, programName: program.name }), new CreateProgramWork({ player: player, singularity: false, programName: program.name }),
); );
player.startFocusing(); player.startFocusing();

@ -5,9 +5,7 @@ import { CONSTANTS } from "../Constants";
import { determineCrimeSuccess } from "../Crime/CrimeHelpers"; import { determineCrimeSuccess } from "../Crime/CrimeHelpers";
import { Crimes } from "../Crime/Crimes"; import { Crimes } from "../Crime/Crimes";
import { IPlayer } from "../PersonObjects/IPlayer"; import { IPlayer } from "../PersonObjects/IPlayer";
import { numeralWrapper } from "../ui/numeralFormat";
import { dialogBoxCreate } from "../ui/React/DialogBox"; import { dialogBoxCreate } from "../ui/React/DialogBox";
import { Money } from "../ui/React/Money";
import { CrimeType } from "../utils/WorkType"; import { CrimeType } from "../utils/WorkType";
import { Work, WorkType } from "./Work"; 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 { export class CrimeWork extends Work {
crimeType: CrimeType; crimeType: CrimeType;
unitCompleted: number;
constructor(params?: CrimeWorkParams) { constructor(params?: CrimeWorkParams) {
super(WorkType.CRIME, params?.singularity ?? true); super(WorkType.CRIME, params?.singularity ?? true);
this.crimeType = params?.crimeType ?? CrimeType.Shoplift; this.crimeType = params?.crimeType ?? CrimeType.Shoplift;
this.unitCompleted = 0;
} }
getCrime(): Crime { getCrime(): Crime {
@ -35,11 +35,15 @@ export class CrimeWork extends Work {
process(player: IPlayer, cycles = 1): boolean { process(player: IPlayer, cycles = 1): boolean {
this.cyclesWorked += cycles; this.cyclesWorked += cycles;
const time = Object.values(Crimes).find((c) => c.type === this.crimeType)?.time ?? 0; 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 { commit(player: IPlayer): void {
if (cancelled) return;
let crime = null; let crime = null;
for (const i of Object.keys(Crimes)) { for (const i of Object.keys(Crimes)) {
if (Crimes[i].type == this.crimeType) { if (Crimes[i].type == this.crimeType) {
@ -53,6 +57,7 @@ export class CrimeWork extends Work {
); );
return; return;
} }
const focusPenalty = player.focusPenalty();
// exp times 2 because were trying to maintain the same numbers as before the conversion // 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 // Technically the definition of Crimes should have the success numbers and failure should divide by 4
let hackExp = crime.hacking_exp * 2; let hackExp = crime.hacking_exp * 2;
@ -64,9 +69,9 @@ export class CrimeWork extends Work {
let karma = crime.karma; let karma = crime.karma;
const success = determineCrimeSuccess(player, crime.type); const success = determineCrimeSuccess(player, crime.type);
if (success) { if (success) {
player.gainMoney(crime.money, "crime"); player.gainMoney(crime.money * focusPenalty, "crime");
player.numPeopleKilled += crime.kills; player.numPeopleKilled += crime.kills;
player.gainIntelligenceExp(crime.intelligence_exp); player.gainIntelligenceExp(crime.intelligence_exp * focusPenalty);
} else { } else {
hackExp /= 4; hackExp /= 4;
StrExp /= 4; StrExp /= 4;
@ -76,42 +81,17 @@ export class CrimeWork extends Work {
ChaExp /= 4; ChaExp /= 4;
karma /= 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); finish(player: IPlayer, cancelled: boolean): void {
player.gainStrengthExp(StrExp); if (cancelled) return;
player.gainDefenseExp(DefExp);
player.gainDexterityExp(DexExp);
player.gainAgilityExp(AgiExp);
player.gainCharismaExp(ChaExp);
player.karma -= karma;
if (!this.singularity) {
dialogBoxCreate(
<>
Crime {success ? "successful" : "failed"}!
<br />
<br />
You gained:
{success && (
<>
<br />
<Money money={crime.money} />
</>
)}
<br />
{numeralWrapper.formatExp(hackExp)} hacking experience <br />
{numeralWrapper.formatExp(StrExp)} strength experience
<br />
{numeralWrapper.formatExp(DefExp)} defense experience
<br />
{numeralWrapper.formatExp(DexExp)} dexterity experience
<br />
{numeralWrapper.formatExp(AgiExp)} agility experience
<br />
{numeralWrapper.formatExp(ChaExp)} charisma experience
</>,
);
}
} }
/** /**

@ -1,5 +1,3 @@
import { AugmentationNames } from "../Augmentation/data/AugmentationNames";
import { CONSTANTS } from "../Constants";
import { IPlayer } from "../PersonObjects/IPlayer"; import { IPlayer } from "../PersonObjects/IPlayer";
export interface WorkStats { export interface WorkStats {

@ -50,8 +50,6 @@ import { setupUncaughtPromiseHandler } from "./UncaughtPromiseHandler";
import { Button, Typography } from "@mui/material"; import { Button, Typography } from "@mui/material";
import { SnackbarEvents, ToastVariant } from "./ui/React/Snackbar"; import { SnackbarEvents, ToastVariant } from "./ui/React/Snackbar";
import { WorkType } from "./utils/WorkType";
const Engine: { const Engine: {
_lastUpdate: number; _lastUpdate: number;
updateGame: (numCycles?: number) => void; updateGame: (numCycles?: number) => void;
@ -96,7 +94,7 @@ const Engine: {
Terminal.process(Router, Player, numCycles); Terminal.process(Router, Player, numCycles);
Player.processNEWWork(numCycles); Player.processWork(numCycles);
// Update stock prices // Update stock prices
if (Player.hasWseAccount) { if (Player.hasWseAccount) {
@ -295,7 +293,7 @@ const Engine: {
loadAllRunningScripts(Player); // This also takes care of offline production for those scripts loadAllRunningScripts(Player); // This also takes care of offline production for those scripts
if (Player.currentWork !== null) { if (Player.currentWork !== null) {
Player.focus = true; Player.focus = true;
Player.processNEWWork(numCyclesOffline); Player.processWork(numCyclesOffline);
} else { } else {
for (let i = 0; i < Player.factions.length; i++) { for (let i = 0; i < Player.factions.length; i++) {
const facName = Player.factions[i]; const facName = Player.factions[i];

@ -152,7 +152,7 @@ function Work(): React.ReactElement {
let innerText = <></>; let innerText = <></>;
if (isCrimeWork(player.currentWork)) { if (isCrimeWork(player.currentWork)) {
const crime = player.currentWork.getCrime(); 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}</>; details = <>{player.currentWork.crimeType}</>;
header = <>You are attempting to {player.currentWork.crimeType}</>; header = <>You are attempting to {player.currentWork.crimeType}</>;

@ -18,7 +18,6 @@ import { ProgressBar } from "./React/Progress";
import { Reputation } from "./React/Reputation"; import { Reputation } from "./React/Reputation";
import { ReputationRate } from "./React/ReputationRate"; import { ReputationRate } from "./React/ReputationRate";
import { StatsRow } from "./React/StatsRow"; import { StatsRow } from "./React/StatsRow";
import { WorkType } from "../utils/WorkType";
import { isCrimeWork } from "../Work/CrimeWork"; import { isCrimeWork } from "../Work/CrimeWork";
import { isClassWork } from "../Work/ClassWork"; import { isClassWork } from "../Work/ClassWork";
import { WorkStats } from "../Work/WorkStats"; import { WorkStats } from "../Work/WorkStats";
@ -145,13 +144,13 @@ export function WorkInProgressRoot(): React.ReactElement {
if (player.currentWork !== null) { if (player.currentWork !== null) {
if (isCrimeWork(player.currentWork)) { if (isCrimeWork(player.currentWork)) {
const crime = player.currentWork.getCrime(); const crime = player.currentWork.getCrime();
const completion = ((player.currentWork.cyclesWorked * CONSTANTS._idleSpeed) / crime.time) * 100; const completion = (player.currentWork.unitCompleted / crime.time) * 100;
workInfo = { workInfo = {
buttons: { buttons: {
cancel: () => { cancel: () => {
router.toLocation(Locations[LocationName.Slums]); router.toLocation(Locations[LocationName.Slums]);
player.finishNEWWork(true); player.finishWork(true);
}, },
unfocus: () => { unfocus: () => {
router.toCity(); router.toCity();
@ -161,18 +160,18 @@ export function WorkInProgressRoot(): React.ReactElement {
title: `You are attempting to ${crime.type}`, title: `You are attempting to ${crime.type}`,
progress: { progress: {
remaining: crime.time - player.currentWork.cyclesWorked * CONSTANTS._idleSpeed, remaining: crime.time - player.currentWork.unitCompleted,
percentage: completion, percentage: completion,
}, },
stopText: "Cancel crime", stopText: "Stop commiting crime",
}; };
} }
if (isClassWork(player.currentWork)) { if (isClassWork(player.currentWork)) {
const classWork = player.currentWork; const classWork = player.currentWork;
function cancel(): void { function cancel(): void {
player.finishNEWWork(true); player.finishWork(true);
router.toCity(); router.toCity();
} }
@ -219,7 +218,7 @@ export function WorkInProgressRoot(): React.ReactElement {
if (isCreateProgramWork(player.currentWork)) { if (isCreateProgramWork(player.currentWork)) {
const create = player.currentWork; const create = player.currentWork;
function cancel(): void { function cancel(): void {
player.finishNEWWork(true); player.finishWork(true);
router.toTerminal(); router.toTerminal();
} }
function unfocus(): void { function unfocus(): void {
@ -253,7 +252,7 @@ export function WorkInProgressRoot(): React.ReactElement {
if (isGraftingWork(player.currentWork)) { if (isGraftingWork(player.currentWork)) {
const graft = player.currentWork; const graft = player.currentWork;
function cancel(): void { function cancel(): void {
player.finishNEWWork(true); player.finishWork(true);
router.toTerminal(); router.toTerminal();
} }
function unfocus(): void { function unfocus(): void {
@ -303,7 +302,7 @@ export function WorkInProgressRoot(): React.ReactElement {
function cancel(): void { function cancel(): void {
router.toFaction(faction); router.toFaction(faction);
player.finishNEWWork(true); player.finishWork(true);
} }
function unfocus(): void { function unfocus(): void {
router.toFaction(faction); router.toFaction(faction);
@ -362,7 +361,7 @@ export function WorkInProgressRoot(): React.ReactElement {
const companyRep = comp.playerReputation; const companyRep = comp.playerReputation;
function cancel(): void { function cancel(): void {
player.finishNEWWork(true); player.finishWork(true);
router.toJob(); router.toJob();
} }
function unfocus(): void { function unfocus(): void {

@ -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 { export enum CrimeType {
None = "", None = "",
Shoplift = "shoplift", Shoplift = "shoplift",