diff --git a/src/Achievements/Achievements.ts b/src/Achievements/Achievements.ts index a1758310f..7a2a72698 100644 --- a/src/Achievements/Achievements.ts +++ b/src/Achievements/Achievements.ts @@ -391,12 +391,10 @@ export const achievements: IMap = { WORKOUT: { ...achievementData["WORKOUT"], Icon: "WORKOUT", - Condition: () => { - if (Player.className === null) return false; - return [ClassType.GymStrength, ClassType.GymDefense, ClassType.GymDexterity, ClassType.GymAgility].includes( + Condition: () => + [ClassType.GymStrength, ClassType.GymDefense, ClassType.GymDexterity, ClassType.GymAgility].includes( Player.className, - ); - }, + ), }, TOR: { ...achievementData["TOR"], diff --git a/src/NetscriptFunctions.ts b/src/NetscriptFunctions.ts index 68cfc37be..14d953f1f 100644 --- a/src/NetscriptFunctions.ts +++ b/src/NetscriptFunctions.ts @@ -2460,7 +2460,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS { crime_money_mult: Player.crime_money_mult, crime_success_mult: Player.crime_success_mult, isWorking: Player.isWorking, - workType: Player.workType ?? "", // Avoids breaking scripts that for some reason rely on this + workType: Player.workType, currentWorkFactionName: Player.currentWorkFactionName, currentWorkFactionDescription: Player.currentWorkFactionDescription, workHackExpGainRate: Player.workHackExpGainRate, @@ -2482,8 +2482,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS { workMoneyGained: Player.workMoneyGained, createProgramName: Player.createProgramName, createProgramReqLvl: Player.createProgramReqLvl, - className: Player.className ?? "", // ditto - crimeType: Player.crimeType ?? "", // ditto (*2) + className: Player.className, + crimeType: Player.crimeType, 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, diff --git a/src/PersonObjects/IPlayer.ts b/src/PersonObjects/IPlayer.ts index 303fad840..63a50ae9f 100644 --- a/src/PersonObjects/IPlayer.ts +++ b/src/PersonObjects/IPlayer.ts @@ -131,14 +131,14 @@ export interface IPlayer { timeWorkedCreateProgram: number; graftAugmentationName: string; timeWorkedGraftAugmentation: number; - crimeType: CrimeType | null; + crimeType: CrimeType; committingCrimeThruSingFn: boolean; singFnCrimeWorkerScript: WorkerScript | null; timeNeededToCompleteWork: number; focus: boolean; - className: ClassType | null; + className: ClassType; currentWorkFactionName: string; - workType: WorkType | null; + workType: WorkType; workCostMult: number; workExpMult: number; currentWorkFactionDescription: string; diff --git a/src/PersonObjects/Player/PlayerObject.ts b/src/PersonObjects/Player/PlayerObject.ts index 66b9f05f9..7582ec133 100644 --- a/src/PersonObjects/Player/PlayerObject.ts +++ b/src/PersonObjects/Player/PlayerObject.ts @@ -38,7 +38,7 @@ import { PlayerAchievement } from "../../Achievements/Achievements"; import { cyrb53 } from "../../utils/StringHelperFunctions"; import { getRandomInt } from "../../utils/helpers/getRandomInt"; import { CONSTANTS } from "../../Constants"; -import { WorkType, ClassType, CrimeType } from "../../utils/WorkType"; +import { WorkType, ClassType, CrimeType, PlayerFactionWorkType } from "../../utils/WorkType"; export class PlayerObject implements IPlayer { // Class members @@ -136,19 +136,19 @@ export class PlayerObject implements IPlayer { bladeburner_success_chance_mult: number; createProgramReqLvl: number; - factionWorkType: string; + factionWorkType: PlayerFactionWorkType; createProgramName: string; timeWorkedCreateProgram: number; graftAugmentationName: string; timeWorkedGraftAugmentation: number; - crimeType: CrimeType | null; + crimeType: CrimeType; committingCrimeThruSingFn: boolean; singFnCrimeWorkerScript: WorkerScript | null; timeNeededToCompleteWork: number; focus: boolean; - className: ClassType | null; + className: ClassType; currentWorkFactionName: string; - workType: WorkType | null; + workType: WorkType; workCostMult: number; workExpMult: number; currentWorkFactionDescription: string; @@ -399,7 +399,7 @@ export class PlayerObject implements IPlayer { //Flags/variables for working (Company, Faction, Creating Program, Taking Class) this.isWorking = false; this.focus = false; - this.workType = null; + this.workType = WorkType.None; this.workCostMult = 1; this.workExpMult = 1; @@ -431,9 +431,9 @@ export class PlayerObject implements IPlayer { this.graftAugmentationName = ""; this.timeWorkedGraftAugmentation = 0; - this.className = null; + this.className = ClassType.None; - this.crimeType = null; + this.crimeType = CrimeType.None; this.timeWorked = 0; //in m; this.timeWorkedCreateProgram = 0; @@ -619,7 +619,7 @@ export class PlayerObject implements IPlayer { this.getUpgradeHomeRamCost = serverMethods.getUpgradeHomeRamCost; this.getUpgradeHomeCoresCost = serverMethods.getUpgradeHomeCoresCost; this.createHacknetServer = serverMethods.createHacknetServer; - this.factionWorkType = ""; + this.factionWorkType = PlayerFactionWorkType.None; this.committingCrimeThruSingFn = false; this.singFnCrimeWorkerScript = null; diff --git a/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx b/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx index 218fcdc29..d7455cb35 100644 --- a/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx +++ b/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx @@ -66,7 +66,7 @@ import { achievements } from "../../Achievements/Achievements"; import { FactionNames } from "../../Faction/data/FactionNames"; import { graftingIntBonus } from "../Grafting/GraftingHelpers"; -import { WorkType, FactionWorkType, ClassType, CrimeType } from "../../utils/WorkType"; +import { WorkType, PlayerFactionWorkType, ClassType, CrimeType } from "../../utils/WorkType"; export function init(this: IPlayer): void { /* Initialize Player's home computer */ @@ -142,8 +142,8 @@ export function prestigeAugmentation(this: PlayerObject): void { this.currentWorkFactionName = ""; this.currentWorkFactionDescription = ""; this.createProgramName = ""; - this.className = null; - this.crimeType = null; + this.className = ClassType.None; + this.crimeType = CrimeType.None; this.workHackExpGainRate = 0; this.workStrExpGainRate = 0; @@ -534,8 +534,8 @@ export function resetWorkStatus(this: IPlayer, generalType?: WorkType, group?: s this.currentWorkFactionDescription = ""; this.createProgramName = ""; this.graftAugmentationName = ""; - this.className = null; - this.workType = null; + this.className = ClassType.None; + this.workType = WorkType.None; } export function processWorkEarnings(this: IPlayer, numCycles = 1): void { @@ -889,19 +889,19 @@ export function startFactionWork(this: IPlayer, faction: Faction): void { } export function startFactionHackWork(this: IPlayer, faction: Faction): void { - this.resetWorkStatus(WorkType.Faction, faction.name, FactionWorkType.Hacking); + this.resetWorkStatus(WorkType.Faction, faction.name, PlayerFactionWorkType.Hacking); this.workHackExpGainRate = 0.15 * this.hacking_exp_mult * BitNodeMultipliers.FactionWorkExpGain; this.workRepGainRate = getHackingWorkRepGain(this, faction); - this.factionWorkType = FactionWorkType.Hacking; + this.factionWorkType = PlayerFactionWorkType.Hacking; this.currentWorkFactionDescription = "carrying out hacking contracts"; this.startFactionWork(faction); } export function startFactionFieldWork(this: IPlayer, faction: Faction): void { - this.resetWorkStatus(WorkType.Faction, faction.name, FactionWorkType.Field); + this.resetWorkStatus(WorkType.Faction, faction.name, PlayerFactionWorkType.Field); this.workHackExpGainRate = 0.1 * this.hacking_exp_mult * BitNodeMultipliers.FactionWorkExpGain; this.workStrExpGainRate = 0.1 * this.strength_exp_mult * BitNodeMultipliers.FactionWorkExpGain; @@ -911,14 +911,14 @@ export function startFactionFieldWork(this: IPlayer, faction: Faction): void { this.workChaExpGainRate = 0.1 * this.charisma_exp_mult * BitNodeMultipliers.FactionWorkExpGain; this.workRepGainRate = getFactionFieldWorkRepGain(this, faction); - this.factionWorkType = FactionWorkType.Field; + this.factionWorkType = PlayerFactionWorkType.Field; this.currentWorkFactionDescription = "carrying out field missions"; this.startFactionWork(faction); } export function startFactionSecurityWork(this: IPlayer, faction: Faction): void { - this.resetWorkStatus(WorkType.Faction, faction.name, FactionWorkType.Security); + this.resetWorkStatus(WorkType.Faction, faction.name, PlayerFactionWorkType.Security); this.workHackExpGainRate = 0.05 * this.hacking_exp_mult * BitNodeMultipliers.FactionWorkExpGain; this.workStrExpGainRate = 0.15 * this.strength_exp_mult * BitNodeMultipliers.FactionWorkExpGain; @@ -928,7 +928,7 @@ export function startFactionSecurityWork(this: IPlayer, faction: Faction): void this.workChaExpGainRate = 0.0 * this.charisma_exp_mult * BitNodeMultipliers.FactionWorkExpGain; this.workRepGainRate = getFactionSecurityWorkRepGain(this, faction); - this.factionWorkType = FactionWorkType.Security; + this.factionWorkType = PlayerFactionWorkType.Security; this.currentWorkFactionDescription = "performing security detail"; this.startFactionWork(faction); @@ -943,13 +943,13 @@ export function workForFaction(this: IPlayer, numCycles: number): boolean { //Constantly update the rep gain rate switch (this.factionWorkType) { - case FactionWorkType.Hacking: + case PlayerFactionWorkType.Hacking: this.workRepGainRate = getHackingWorkRepGain(this, faction); break; - case FactionWorkType.Field: + case PlayerFactionWorkType.Field: this.workRepGainRate = getFactionFieldWorkRepGain(this, faction); break; - case FactionWorkType.Security: + case PlayerFactionWorkType.Security: this.workRepGainRate = getFactionSecurityWorkRepGain(this, faction); break; default: @@ -1536,7 +1536,7 @@ export function commitCrime(this: IPlayer, numCycles: number): boolean { export function finishCrime(this: IPlayer, cancelled: boolean): string { //Determine crime success/failure if (!cancelled) { - if (determineCrimeSuccess(this, this.crimeType ?? "")) { + if (determineCrimeSuccess(this, this.crimeType)) { //Handle Karma and crime statistics let crime = null; for (const i of Object.keys(Crimes)) { @@ -1669,7 +1669,7 @@ export function finishCrime(this: IPlayer, cancelled: boolean): string { this.committingCrimeThruSingFn = false; this.singFnCrimeWorkerScript = null; this.isWorking = false; - this.crimeType = null; + this.crimeType = CrimeType.None; this.resetWorkStatus(); return ""; } diff --git a/src/utils/WorkType.ts b/src/utils/WorkType.ts index 67a77f31c..e43890698 100644 --- a/src/utils/WorkType.ts +++ b/src/utils/WorkType.ts @@ -1,4 +1,5 @@ export enum WorkType { + None = "", Company = "Working for Company", CompanyPartTime = "Working for Company part-time", Faction = "Working for Faction", @@ -8,13 +9,15 @@ export enum WorkType { GraftAugmentation = "Grafting an Augmentation", } -export enum FactionWorkType { +export enum PlayerFactionWorkType { + None = "", Hacking = "Faction Hacking Work", Field = "Faction Field Work", Security = "Faction Security Work", } export enum ClassType { + None = "", StudyComputerScience = "studying Computer Science", DataStructures = "taking a Data Structures course", Networks = "taking a Networks course", @@ -30,6 +33,7 @@ export enum ClassType { } export enum CrimeType { + None = "", Shoplift = "shoplift", RobStore = "rob a store", Mug = "mug someone",