This commit is contained in:
Olivier Gagnon 2022-05-19 02:09:00 -04:00
parent ca1a2aad33
commit 9af553f63c
5 changed files with 43 additions and 15 deletions

@ -2,11 +2,11 @@
* Location and traveling-related helper functions. * Location and traveling-related helper functions.
* Mostly used for UI * Mostly used for UI
*/ */
import { SpecialServers } from "../Server/data/SpecialServers";
import { CONSTANTS } from "../Constants"; import { CONSTANTS } from "../Constants";
import { IPlayer } from "../PersonObjects/IPlayer"; import { IPlayer } from "../PersonObjects/IPlayer";
import { AddToAllServers, createUniqueRandomIp } from "../Server/AllServers"; import { GetServer } from "../Server/AllServers";
import { safetlyCreateUniqueServer } from "../Server/ServerHelpers";
import { dialogBoxCreate } from "../ui/React/DialogBox"; import { dialogBoxCreate } from "../ui/React/DialogBox";
@ -25,19 +25,14 @@ export function purchaseTorRouter(p: IPlayer): void {
} }
p.loseMoney(CONSTANTS.TorRouterCost, "other"); p.loseMoney(CONSTANTS.TorRouterCost, "other");
const darkweb = safetlyCreateUniqueServer({ const darkweb = GetServer(SpecialServers.DarkWeb);
ip: createUniqueRandomIp(), if (!darkweb) {
hostname: "darkweb", throw new Error("Dark web is not a server.");
organizationName: "", }
isConnectedTo: false,
adminRights: false,
purchasedByPlayer: false,
maxRam: 1,
});
AddToAllServers(darkweb);
p.getHomeComputer().serversOnNetwork.push(darkweb.hostname); p.getHomeComputer().serversOnNetwork.push(darkweb.hostname);
darkweb.serversOnNetwork.push(p.getHomeComputer().hostname); darkweb.serversOnNetwork.push(p.getHomeComputer().hostname);
console.log(darkweb);
dialogBoxCreate( dialogBoxCreate(
"You have purchased a TOR router!<br>" + "You have purchased a TOR router!<br>" +
"You now have access to the dark web from your home computer.<br>" + "You now have access to the dark web from your home computer.<br>" +

@ -32,7 +32,7 @@ export function RamButton(props: IProps): React.ReactElement {
} }
const bnMult = BitNodeMultipliers.HomeComputerRamCost === 1 ? "" : `\\cdot ${BitNodeMultipliers.HomeComputerRamCost}`; const bnMult = BitNodeMultipliers.HomeComputerRamCost === 1 ? "" : `\\cdot ${BitNodeMultipliers.HomeComputerRamCost}`;
console.log(BitNodeMultipliers.HomeComputerRamCost);
return ( return (
<Tooltip <Tooltip
title={ title={

@ -13,7 +13,7 @@ import { GetServer, AddToAllServers, createUniqueRandomIp } from "../../Server/A
import { SpecialServers } from "../../Server/data/SpecialServers"; import { SpecialServers } from "../../Server/data/SpecialServers";
export function hasTorRouter(this: IPlayer): boolean { export function hasTorRouter(this: IPlayer): boolean {
return !!GetServer(SpecialServers.DarkWeb); return this.getHomeComputer().serversOnNetwork.includes(SpecialServers.DarkWeb);
} }
export function getCurrentServer(this: IPlayer): BaseServer { export function getCurrentServer(this: IPlayer): BaseServer {

@ -4,7 +4,14 @@ import { CONSTANTS } from "./Constants";
import { Factions, loadFactions } from "./Faction/Factions"; import { Factions, loadFactions } from "./Faction/Factions";
import { loadAllGangs, AllGangs } from "./Gang/AllGangs"; import { loadAllGangs, AllGangs } from "./Gang/AllGangs";
import { Player, loadPlayer } from "./Player"; import { Player, loadPlayer } from "./Player";
import { saveAllServers, loadAllServers, GetAllServers } from "./Server/AllServers"; import {
saveAllServers,
loadAllServers,
GetAllServers,
createUniqueRandomIp,
AddToAllServers,
GetServer,
} from "./Server/AllServers";
import { Settings } from "./Settings/Settings"; import { Settings } from "./Settings/Settings";
import { loadStockMarket, StockMarket } from "./StockMarket/StockMarket"; import { loadStockMarket, StockMarket } from "./StockMarket/StockMarket";
import { staneksGift, loadStaneksGift } from "./CotMG/Helper"; import { staneksGift, loadStaneksGift } from "./CotMG/Helper";
@ -26,6 +33,8 @@ import { pushGameSaved } from "./Electron";
import { defaultMonacoTheme } from "./ScriptEditor/ui/themes"; import { defaultMonacoTheme } from "./ScriptEditor/ui/themes";
import { FactionNames } from "./Faction/data/FactionNames"; import { FactionNames } from "./Faction/data/FactionNames";
import { Faction } from "./Faction/Faction"; import { Faction } from "./Faction/Faction";
import { safetlyCreateUniqueServer } from "./Server/ServerHelpers";
import { SpecialServers } from "./Server/data/SpecialServers";
/* SaveObject.js /* SaveObject.js
* Defines the object used to save/load games * Defines the object used to save/load games
@ -434,6 +443,22 @@ function evaluateVersionCompatibility(ver: string | number): void {
Player.reapplyAllAugmentations(true); Player.reapplyAllAugmentations(true);
Player.reapplyAllSourceFiles(); Player.reapplyAllSourceFiles();
} }
if (ver < 18) {
// Create the darkweb for everyone but it won't be linked
const dw = GetServer(SpecialServers.DarkWeb);
if (!dw) {
const darkweb = safetlyCreateUniqueServer({
ip: createUniqueRandomIp(),
hostname: SpecialServers.DarkWeb,
organizationName: "",
isConnectedTo: false,
adminRights: false,
purchasedByPlayer: false,
maxRam: 1,
});
AddToAllServers(darkweb);
}
}
} }
} }

@ -1565,4 +1565,12 @@ export const serverMetadata: IServerMetadata[] = [
serverGrowth: 0, serverGrowth: 0,
specialName: SpecialServers.WorldDaemon, specialName: SpecialServers.WorldDaemon,
}, },
{
hostname: SpecialServers.DarkWeb,
moneyAvailable: 0,
numOpenPortsRequired: 5,
organizationName: SpecialServers.DarkWeb,
requiredHackingSkill: 1,
specialName: SpecialServers.DarkWeb,
},
]; ];