bitburner-src/src/Locations/LocationsHelpers.tsx

49 lines
1.5 KiB
TypeScript
Raw Normal View History

/**
* Location and traveling-related helper functions.
* Mostly used for UI
*/
import { CONSTANTS } from "../Constants";
import { IPlayer } from "../PersonObjects/IPlayer";
2021-09-05 01:09:30 +02:00
import { AddToAllServers, createUniqueRandomIp } from "../Server/AllServers";
import { safetlyCreateUniqueServer } from "../Server/ServerHelpers";
import { SpecialServerIps } from "../Server/SpecialServerIps";
import { dialogBoxCreate } from "../../utils/DialogBox";
/**
* Attempt to purchase a TOR router
2019-05-18 00:51:28 +02:00
* @param {IPlayer} p - Player object
*/
2021-05-01 09:17:31 +02:00
export function purchaseTorRouter(p: IPlayer): void {
2021-09-05 01:09:30 +02:00
if (p.hasTorRouter()) {
dialogBoxCreate(`You already have a TOR Router!`);
return;
}
if (!p.canAfford(CONSTANTS.TorRouterCost)) {
dialogBoxCreate("You cannot afford to purchase the TOR router!");
return;
}
p.loseMoney(CONSTANTS.TorRouterCost);
const darkweb = safetlyCreateUniqueServer({
ip: createUniqueRandomIp(),
hostname: "darkweb",
organizationName: "",
isConnectedTo: false,
adminRights: false,
purchasedByPlayer: false,
maxRam: 1,
});
AddToAllServers(darkweb);
SpecialServerIps.addIp("Darkweb Server", darkweb.ip);
p.getHomeComputer().serversOnNetwork.push(darkweb.ip);
darkweb.serversOnNetwork.push(p.getHomeComputer().ip);
dialogBoxCreate(
"You have purchased a TOR router!<br>" +
"You now have access to the dark web from your home computer.<br>" +
"Use the scan/scan-analyze commands to search for the dark web connection.",
);
}