bitburner-src/src/Terminal/commands/scananalyze.ts

38 lines
1.3 KiB
TypeScript
Raw Normal View History

2022-09-06 15:07:12 +02:00
import { Terminal } from "../../Terminal";
import { Player } from "@player";
2021-09-16 01:50:44 +02:00
import { Programs } from "../../Programs/Programs";
2022-09-06 15:07:12 +02:00
export function scananalyze(args: (string | number | boolean)[]): void {
2021-09-16 01:50:44 +02:00
if (args.length === 0) {
2022-09-06 15:07:12 +02:00
Terminal.executeScanAnalyzeCommand();
2021-09-16 01:50:44 +02:00
} else {
// # of args must be 2 or 3
if (args.length > 2) {
2022-09-06 15:07:12 +02:00
Terminal.error("Incorrect usage of scan-analyze command. usage: scan-analyze [depth]");
2021-09-16 01:50:44 +02:00
return;
}
let all = false;
if (args.length === 2 && args[1] === "-a") {
all = true;
}
const depth = parseInt(args[0] + "");
if (isNaN(depth) || depth < 0) {
2022-09-06 15:07:12 +02:00
Terminal.error("Incorrect usage of scan-analyze command. depth argument must be positive numeric");
2021-09-16 01:50:44 +02:00
return;
}
2022-09-06 15:07:12 +02:00
if (depth > 3 && !Player.hasProgram(Programs.DeepscanV1.name) && !Player.hasProgram(Programs.DeepscanV2.name)) {
Terminal.error("You cannot scan-analyze with that high of a depth. Maximum depth is 3");
2021-09-16 01:50:44 +02:00
return;
2022-09-06 15:07:12 +02:00
} else if (depth > 5 && !Player.hasProgram(Programs.DeepscanV2.name)) {
Terminal.error("You cannot scan-analyze with that high of a depth. Maximum depth is 5");
2021-09-16 01:50:44 +02:00
return;
} else if (depth > 10) {
2022-09-06 15:07:12 +02:00
Terminal.error("You cannot scan-analyze with that high of a depth. Maximum depth is 10");
2021-09-16 01:50:44 +02:00
return;
}
2022-09-06 15:07:12 +02:00
Terminal.executeScanAnalyzeCommand(depth, all);
2021-09-16 01:50:44 +02:00
}
}