diff --git a/src/PersonObjects/IPlayer.ts b/src/PersonObjects/IPlayer.ts index c5c3ef8c9..3153cb2b5 100644 --- a/src/PersonObjects/IPlayer.ts +++ b/src/PersonObjects/IPlayer.ts @@ -242,6 +242,7 @@ export interface IPlayer { getIntelligenceBonus(weight: number): number; getCasinoWinnings(): number; quitJob(company: string): void; + hasJob(): boolean; createHacknetServer(): HacknetServer; startCreateProgramWork(router: IRouter, programName: string, time: number, reqLevel: number): void; queueAugmentation(augmentationName: string): void; diff --git a/src/PersonObjects/Player/PlayerObject.ts b/src/PersonObjects/Player/PlayerObject.ts index bce4ec3c6..8497e94a1 100644 --- a/src/PersonObjects/Player/PlayerObject.ts +++ b/src/PersonObjects/Player/PlayerObject.ts @@ -247,6 +247,7 @@ export class PlayerObject implements IPlayer { getIntelligenceBonus: (weight: number) => number; getCasinoWinnings: () => number; quitJob: (company: string) => void; + hasJob: () => boolean; process: (router: IRouter, numCycles?: number) => void; createHacknetServer: () => HacknetServer; startCreateProgramWork: (router: IRouter, programName: string, time: number, reqLevel: number) => void; @@ -531,6 +532,7 @@ export class PlayerObject implements IPlayer { this.applyForJob = generalMethods.applyForJob; this.getNextCompanyPosition = generalMethods.getNextCompanyPosition; this.quitJob = generalMethods.quitJob; + this.hasJob = generalMethods.hasJob; this.applyForSoftwareJob = generalMethods.applyForSoftwareJob; this.applyForSoftwareConsultantJob = generalMethods.applyForSoftwareConsultantJob; this.applyForItJob = generalMethods.applyForItJob; diff --git a/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx b/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx index 9847bc170..5d343dfe5 100644 --- a/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx +++ b/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx @@ -1782,6 +1782,15 @@ export function quitJob(this: IPlayer, company: string): void { delete this.jobs[company]; } +/** + * Method to see if the player has at least one job assigned to them + * @param this The player instance + * @returns Whether the user has at least one job + */ +export function hasJob(this: IPlayer): boolean { + return Boolean(Object.keys(this.jobs).length); +} + export function applyForSoftwareJob(this: IPlayer, sing = false): boolean { return this.applyForJob(CompanyPositions[posNames.SoftwareCompanyPositions[0]], sing); } diff --git a/src/Sidebar/ui/SidebarRoot.tsx b/src/Sidebar/ui/SidebarRoot.tsx index eb0877872..a974fbba9 100644 --- a/src/Sidebar/ui/SidebarRoot.tsx +++ b/src/Sidebar/ui/SidebarRoot.tsx @@ -292,7 +292,7 @@ export function SidebarRoot(props: IProps): React.ReactElement { } else if (event.keyCode === KEY.W && event.altKey) { event.preventDefault(); clickCity(); - } else if (event.keyCode === KEY.J && event.altKey && !event.ctrlKey && !event.metaKey) { + } else if (event.keyCode === KEY.J && event.altKey && !event.ctrlKey && !event.metaKey && props.player.hasJob()) { // ctrl/cmd + alt + j is shortcut to open Chrome dev tools event.preventDefault(); clickJob();