mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-27 19:37:07 +02:00
mostly convert terminal to react
This commit is contained in:
+14
-15
@@ -2,8 +2,9 @@ import * as React from "react";
|
||||
import { DarkWebItems } from "./DarkWebItems";
|
||||
|
||||
import { Player } from "../Player";
|
||||
import { Terminal } from "../Terminal";
|
||||
import { SpecialServerIps } from "../Server/SpecialServerIps";
|
||||
import { post, postElement } from "../ui/postToTerminal";
|
||||
import { numeralWrapper } from "../ui/numeralFormat";
|
||||
import { Money } from "../ui/React/Money";
|
||||
|
||||
import { isValidIPAddress } from "../../utils/helpers/isValidIPAddress";
|
||||
@@ -16,7 +17,7 @@ export function checkIfConnectedToDarkweb(): void {
|
||||
return;
|
||||
}
|
||||
if (darkwebIp == Player.getCurrentServer().ip) {
|
||||
post(
|
||||
Terminal.print(
|
||||
"You are now connected to the dark web. From the dark web you can purchase illegal items. " +
|
||||
"Use the 'buy -l' command to display a list of all the items you can buy. Use 'buy [item-name] " +
|
||||
"to purchase an item.",
|
||||
@@ -35,9 +36,9 @@ export function executeDarkwebTerminalCommand(commandArray: string[]): void {
|
||||
switch (commandArray[0]) {
|
||||
case "buy": {
|
||||
if (commandArray.length != 2) {
|
||||
post("Incorrect number of arguments. Usage: ");
|
||||
post("buy -l");
|
||||
post("buy [item name]");
|
||||
Terminal.error("Incorrect number of arguments. Usage: ");
|
||||
Terminal.print("buy -l");
|
||||
Terminal.print("buy [item name]");
|
||||
return;
|
||||
}
|
||||
const arg = commandArray[1];
|
||||
@@ -49,7 +50,7 @@ export function executeDarkwebTerminalCommand(commandArray: string[]): void {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
post("Command not found");
|
||||
Terminal.error("Command not found");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -57,11 +58,7 @@ export function executeDarkwebTerminalCommand(commandArray: string[]): void {
|
||||
export function listAllDarkwebItems(): void {
|
||||
for (const key in DarkWebItems) {
|
||||
const item = DarkWebItems[key];
|
||||
postElement(
|
||||
<>
|
||||
{item.program} - <Money money={item.price} player={Player} /> - {item.description}
|
||||
</>,
|
||||
);
|
||||
Terminal.print(`${item.program} - ${numeralWrapper.formatMoney(item.price)} - ${item.description}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,24 +76,26 @@ export function buyDarkwebItem(itemName: string): void {
|
||||
|
||||
// return if invalid
|
||||
if (item === null) {
|
||||
post("Unrecognized item: " + itemName);
|
||||
Terminal.print("Unrecognized item: " + itemName);
|
||||
return;
|
||||
}
|
||||
|
||||
// return if the player already has it.
|
||||
if (Player.hasProgram(item.program)) {
|
||||
post("You already have the " + item.program + " program");
|
||||
Terminal.print("You already have the " + item.program + " program");
|
||||
return;
|
||||
}
|
||||
|
||||
// return if the player doesn't have enough money
|
||||
if (Player.money.lt(item.price)) {
|
||||
post("Not enough money to purchase " + item.program);
|
||||
Terminal.print("Not enough money to purchase " + item.program);
|
||||
return;
|
||||
}
|
||||
|
||||
// buy and push
|
||||
Player.loseMoney(item.price);
|
||||
Player.getHomeComputer().programs.push(item.program);
|
||||
post("You have purchased the " + item.program + " program. The new program can be found on your home computer.");
|
||||
Terminal.print(
|
||||
"You have purchased the " + item.program + " program. The new program can be found on your home computer.",
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user