2021-10-27 02:26:05 +02:00
|
|
|
import React from "react";
|
2021-09-05 01:09:30 +02:00
|
|
|
import { DarkWebItems } from "./DarkWebItems";
|
2017-08-30 19:44:29 +02:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
import { Player } from "../Player";
|
2021-09-16 08:52:45 +02:00
|
|
|
import { Terminal } from "../Terminal";
|
2021-10-07 23:55:49 +02:00
|
|
|
import { SpecialServers } from "../Server/data/SpecialServers";
|
2021-10-27 02:26:05 +02:00
|
|
|
import { Money } from "../ui/React/Money";
|
2017-08-30 19:44:29 +02:00
|
|
|
|
2017-05-05 17:50:55 +02:00
|
|
|
//Posts a "help" message if connected to DarkWeb
|
2021-03-14 07:08:24 +01:00
|
|
|
export function checkIfConnectedToDarkweb(): void {
|
2021-10-07 23:55:49 +02:00
|
|
|
const server = Player.getCurrentServer();
|
|
|
|
if (server !== null && SpecialServers.DarkWeb == server.hostname) {
|
|
|
|
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.",
|
|
|
|
);
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
2017-05-05 17:50:55 +02:00
|
|
|
}
|
|
|
|
|
2021-09-16 01:50:44 +02:00
|
|
|
export function listAllDarkwebItems(): void {
|
2021-09-05 01:09:30 +02:00
|
|
|
for (const key in DarkWebItems) {
|
|
|
|
const item = DarkWebItems[key];
|
2021-10-27 02:26:05 +02:00
|
|
|
Terminal.printRaw(
|
|
|
|
<>
|
2021-10-28 05:41:47 +02:00
|
|
|
{item.program} - <Money money={item.price} /> - {item.description}
|
2021-10-27 02:26:05 +02:00
|
|
|
</>,
|
|
|
|
);
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
2017-05-05 17:50:55 +02:00
|
|
|
}
|
|
|
|
|
2021-09-16 01:50:44 +02:00
|
|
|
export function buyDarkwebItem(itemName: string): void {
|
2021-09-05 01:09:30 +02:00
|
|
|
itemName = itemName.toLowerCase();
|
2018-06-01 23:05:05 +02:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
// find the program that matches, if any
|
|
|
|
let item = null;
|
|
|
|
for (const key in DarkWebItems) {
|
|
|
|
const i = DarkWebItems[key];
|
|
|
|
if (i.program.toLowerCase() == itemName) {
|
|
|
|
item = i;
|
2017-05-05 17:50:55 +02:00
|
|
|
}
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
2017-05-05 17:50:55 +02:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
// return if invalid
|
|
|
|
if (item === null) {
|
2021-10-27 02:26:05 +02:00
|
|
|
Terminal.error("Unrecognized item: " + itemName);
|
2021-09-05 01:09:30 +02:00
|
|
|
return;
|
|
|
|
}
|
2018-06-01 23:05:05 +02:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
// return if the player already has it.
|
|
|
|
if (Player.hasProgram(item.program)) {
|
2021-09-16 08:52:45 +02:00
|
|
|
Terminal.print("You already have the " + item.program + " program");
|
2021-09-05 01:09:30 +02:00
|
|
|
return;
|
|
|
|
}
|
2018-06-01 23:05:05 +02:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
// return if the player doesn't have enough money
|
|
|
|
if (Player.money.lt(item.price)) {
|
2021-10-27 02:26:05 +02:00
|
|
|
Terminal.error("Not enough money to purchase " + item.program);
|
2021-09-05 01:09:30 +02:00
|
|
|
return;
|
|
|
|
}
|
2018-06-01 23:05:05 +02:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
// buy and push
|
2021-10-27 20:18:33 +02:00
|
|
|
Player.loseMoney(item.price, "other");
|
2021-09-05 01:09:30 +02:00
|
|
|
Player.getHomeComputer().programs.push(item.program);
|
2021-09-16 08:52:45 +02:00
|
|
|
Terminal.print(
|
|
|
|
"You have purchased the " + item.program + " program. The new program can be found on your home computer.",
|
|
|
|
);
|
2018-06-01 23:05:05 +02:00
|
|
|
}
|