mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-03 14:27:03 +02:00
BUGFIX: Fix inconsistencies of error handling in promise-based API (#1377)
This commit is contained in:
@@ -2,7 +2,6 @@ import { Terminal } from "../../Terminal";
|
||||
import { Player } from "@player";
|
||||
import { BaseServer } from "../../Server/BaseServer";
|
||||
import { Server } from "../../Server/Server";
|
||||
import { HacknetServer } from "../../Hacknet/HacknetServer";
|
||||
|
||||
export function backdoor(args: (string | number | boolean)[], server: BaseServer): void {
|
||||
if (args.length !== 0) {
|
||||
@@ -11,24 +10,24 @@ export function backdoor(args: (string | number | boolean)[], server: BaseServer
|
||||
}
|
||||
|
||||
if (!(server instanceof Server)) {
|
||||
Terminal.error("Can only backdoor normal servers");
|
||||
Terminal.error("Can only install a backdoor on normal servers");
|
||||
return;
|
||||
}
|
||||
|
||||
const normalServer = server as Server;
|
||||
|
||||
if (normalServer.purchasedByPlayer) {
|
||||
if (server.purchasedByPlayer) {
|
||||
Terminal.error(
|
||||
"Cannot use backdoor on your own machines! You are currently connected to your home PC or one of your purchased servers",
|
||||
"Cannot install a backdoor on your own machines! You are currently connected to your home PC or one of your purchased servers.",
|
||||
);
|
||||
} else if (!normalServer.hasAdminRights) {
|
||||
Terminal.error("You do not have admin rights for this machine! Cannot backdoor");
|
||||
} else if (normalServer.requiredHackingSkill > Player.skills.hacking) {
|
||||
Terminal.error(
|
||||
"Your hacking skill is not high enough to use backdoor on this machine. Try analyzing the machine to determine the required hacking skill",
|
||||
);
|
||||
} else if (normalServer instanceof HacknetServer) {
|
||||
Terminal.error("Cannot use backdoor on this type of Server");
|
||||
} else {
|
||||
Terminal.startBackdoor();
|
||||
return;
|
||||
}
|
||||
if (!server.hasAdminRights) {
|
||||
Terminal.error("You do not have admin rights for this machine");
|
||||
return;
|
||||
}
|
||||
if (server.requiredHackingSkill > Player.skills.hacking) {
|
||||
Terminal.error(
|
||||
"Your hacking skill is not high enough to install a backdoor on this machine. Try analyzing the machine to determine the required hacking skill.",
|
||||
);
|
||||
return;
|
||||
}
|
||||
Terminal.startBackdoor();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user