fix(shortcut): job shortcut only run when have job

The shortcut was always allowed to run, meaning when the player doesn't
have a job, they were sent to the job screen with no job and lost the
view context/sidebar.

- Add utility method to check if the player 'hasJob', being at least 1
job.
- Check if player has job when the key combination is pressed

Resolves danielyxie/bitburner#2013
This commit is contained in:
Dan
2021-12-19 15:20:02 +00:00
parent 8c2b969026
commit 2f9eb324b4
4 changed files with 13 additions and 1 deletions
+1 -1
View File
@@ -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();