2019-04-01 11:23:25 +02:00
|
|
|
/**
|
|
|
|
* Location and traveling-related helper functions.
|
|
|
|
* Mostly used for UI
|
|
|
|
*/
|
2019-05-05 06:03:40 +02:00
|
|
|
import { CONSTANTS } from "../Constants";
|
|
|
|
|
|
|
|
import { IPlayer } from "../PersonObjects/IPlayer";
|
2021-09-05 01:09:30 +02:00
|
|
|
import { AddToAllServers, createUniqueRandomIp } from "../Server/AllServers";
|
2019-05-05 06:03:40 +02:00
|
|
|
import { safetlyCreateUniqueServer } from "../Server/ServerHelpers";
|
|
|
|
import { SpecialServerIps } from "../Server/SpecialServerIps";
|
|
|
|
|
2021-09-25 20:42:57 +02:00
|
|
|
import { dialogBoxCreate } from "../ui/React/DialogBox";
|
2019-04-01 11:23:25 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Attempt to purchase a TOR router
|
2019-05-18 00:51:28 +02:00
|
|
|
* @param {IPlayer} p - Player object
|
2019-04-01 11:23:25 +02:00
|
|
|
*/
|
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.",
|
|
|
|
);
|
2019-04-01 11:23:25 +02:00
|
|
|
}
|