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

38 lines
1.2 KiB
TypeScript
Raw Normal View History

2021-09-16 01:50:44 +02:00
import { ITerminal } from "../ITerminal";
2021-09-17 08:58:02 +02:00
import { IRouter } from "../../ui/Router";
2021-09-16 01:50:44 +02:00
import { IPlayer } from "../../PersonObjects/IPlayer";
import { BaseServer } from "../../Server/BaseServer";
import { listAllDarkwebItems, buyAllDarkwebItems, buyDarkwebItem } from "../../DarkWeb/DarkWeb";
2021-10-07 23:55:49 +02:00
import { SpecialServers } from "../../Server/data/SpecialServers";
import { GetServer } from "../../Server/AllServers";
2021-09-16 01:50:44 +02:00
export function buy(
terminal: ITerminal,
2021-09-17 08:58:02 +02:00
router: IRouter,
2021-09-16 01:50:44 +02:00
player: IPlayer,
server: BaseServer,
2021-12-03 20:44:32 +01:00
args: (string | number | boolean)[],
2021-09-16 01:50:44 +02:00
): void {
2021-10-07 23:55:49 +02:00
if (!GetServer(SpecialServers.DarkWeb)) {
2021-09-16 01:50:44 +02:00
terminal.error(
"You need to be able to connect to the Dark Web to use the buy command. (Maybe there's a TOR router you can buy somewhere)",
);
return;
}
if (args.length != 1) {
terminal.print("Incorrect number of arguments. Usage: ");
terminal.print("buy -l");
terminal.print("buy -a");
2021-09-16 01:50:44 +02:00
terminal.print("buy [item name]");
return;
}
const arg = args[0] + "";
if (arg == "-l" || arg == "-1" || arg == "--list") {
listAllDarkwebItems();
} else if (arg == "-a" || arg == "--all") {
buyAllDarkwebItems();
2021-09-16 01:50:44 +02:00
} else {
buyDarkwebItem(arg);
}
}