mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-25 10:42:51 +02:00
finish convert to hostname
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { Server } from "./Server";
|
||||
import { BaseServer } from "./BaseServer";
|
||||
import { SpecialServerIps } from "./SpecialServerIps";
|
||||
import { serverMetadata } from "./data/servers";
|
||||
|
||||
import { HacknetServer } from "../Hacknet/HacknetServer";
|
||||
@@ -90,13 +89,11 @@ export function createUniqueRandomIp(): string {
|
||||
// Saftely add a Server to the AllServers map
|
||||
export function AddToAllServers(server: Server | HacknetServer): void {
|
||||
if (GetServer(server.hostname)) {
|
||||
console.warn(`IP of server that's being added: ${server.ip}`);
|
||||
console.warn(`Hostname of the server thats being added: ${server.hostname}`);
|
||||
console.warn(`The server that already has this IP is: ${AllServers[server.hostname].hostname}`);
|
||||
throw new Error("Error: Trying to add a server with an existing IP");
|
||||
}
|
||||
|
||||
console.log(`adding ${server.hostname}`);
|
||||
AllServers[server.hostname] = server;
|
||||
}
|
||||
|
||||
@@ -164,10 +161,6 @@ export function initForeignServers(homeComputer: Server): void {
|
||||
server.messages.push(filename);
|
||||
}
|
||||
|
||||
if (metadata.specialName !== undefined) {
|
||||
SpecialServerIps.addIp(metadata.specialName, server.ip);
|
||||
}
|
||||
|
||||
AddToAllServers(server);
|
||||
if (metadata.networkLayer !== undefined) {
|
||||
networkLayers[toNumber(metadata.networkLayer) - 1].push(server);
|
||||
@@ -176,8 +169,8 @@ export function initForeignServers(homeComputer: Server): void {
|
||||
|
||||
/* Create a randomized network for all the foreign servers */
|
||||
const linkComputers = (server1: Server, server2: Server): void => {
|
||||
server1.serversOnNetwork.push(server2.ip);
|
||||
server2.serversOnNetwork.push(server1.ip);
|
||||
server1.serversOnNetwork.push(server2.hostname);
|
||||
server2.serversOnNetwork.push(server1.hostname);
|
||||
};
|
||||
|
||||
const getRandomArrayItem = (arr: any[]): any => arr[Math.floor(Math.random() * arr.length)];
|
||||
|
||||
@@ -267,7 +267,7 @@ export class BaseServer {
|
||||
}
|
||||
|
||||
// Otherwise, create a new script
|
||||
const newScript = new Script(fn, code, this.ip, this.scripts);
|
||||
const newScript = new Script(fn, code, this.hostname, this.scripts);
|
||||
this.scripts.push(newScript);
|
||||
ret.success = true;
|
||||
return ret;
|
||||
|
||||
@@ -80,12 +80,12 @@ export function purchaseServer(hostname: string, ram: number, cost: number, p: I
|
||||
AddToAllServers(newServ);
|
||||
|
||||
// Add to Player's purchasedServers array
|
||||
p.purchasedServers.push(newServ.ip);
|
||||
p.purchasedServers.push(newServ.hostname);
|
||||
|
||||
// Connect new server to home computer
|
||||
const homeComputer = p.getHomeComputer();
|
||||
homeComputer.serversOnNetwork.push(newServ.ip);
|
||||
newServ.serversOnNetwork.push(homeComputer.ip);
|
||||
homeComputer.serversOnNetwork.push(newServ.hostname);
|
||||
newServ.serversOnNetwork.push(homeComputer.hostname);
|
||||
|
||||
p.loseMoney(cost);
|
||||
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
import { IMap } from "../types";
|
||||
import { Reviver, Generic_toJSON, Generic_fromJSON } from "../utils/JSONReviver";
|
||||
|
||||
/* Holds IP of Special Servers */
|
||||
export const SpecialServerNames: IMap<string> = {
|
||||
FulcrumSecretTechnologies: "Fulcrum Secret Technologies Server",
|
||||
CyberSecServer: "CyberSec Server",
|
||||
NiteSecServer: "NiteSec Server",
|
||||
TheBlackHandServer: "The Black Hand Server",
|
||||
BitRunnersServer: "BitRunners Server",
|
||||
TheDarkArmyServer: "The Dark Army Server",
|
||||
DaedalusServer: "Daedalus Server",
|
||||
WorldDaemon: "w0r1d_d43m0n",
|
||||
};
|
||||
|
||||
export class SpecialServerIpsMap {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
[key: string]: Function | string;
|
||||
|
||||
addIp(name: string, ip: string): void {
|
||||
this[name] = ip;
|
||||
}
|
||||
|
||||
getIp(name: string): string {
|
||||
return this[name] as string;
|
||||
}
|
||||
|
||||
// Serialize the current object to a JSON save state
|
||||
toJSON(): any {
|
||||
return Generic_toJSON("SpecialServerIpsMap", this);
|
||||
}
|
||||
|
||||
// Initializes a SpecialServerIpsMap Object from a JSON save state
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
static fromJSON(value: any): SpecialServerIpsMap {
|
||||
return Generic_fromJSON(SpecialServerIpsMap, value.data);
|
||||
}
|
||||
}
|
||||
|
||||
Reviver.constructors.SpecialServerIpsMap = SpecialServerIpsMap;
|
||||
|
||||
export let SpecialServerIps: SpecialServerIpsMap = new SpecialServerIpsMap();
|
||||
|
||||
export function prestigeSpecialServerIps(): void {
|
||||
for (const member in SpecialServerIps) {
|
||||
delete SpecialServerIps[member];
|
||||
}
|
||||
|
||||
SpecialServerIps = new SpecialServerIpsMap();
|
||||
}
|
||||
|
||||
export function loadSpecialServerIps(saveString: string): void {
|
||||
SpecialServerIps = JSON.parse(saveString, Reviver);
|
||||
}
|
||||
|
||||
export function initSpecialServerIps(): void {
|
||||
SpecialServerIps = new SpecialServerIpsMap();
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/* Holds IP of Special Servers */
|
||||
export const SpecialServers: {
|
||||
[key: string]: string | undefined;
|
||||
|
||||
Home: string;
|
||||
FulcrumSecretTechnologies: string;
|
||||
CyberSecServer: string;
|
||||
NiteSecServer: string;
|
||||
TheBlackHandServer: string;
|
||||
BitRunnersServer: string;
|
||||
TheDarkArmyServer: string;
|
||||
DaedalusServer: string;
|
||||
WorldDaemon: string;
|
||||
DarkWeb: string;
|
||||
} = {
|
||||
Home: "home",
|
||||
FulcrumSecretTechnologies: "fulcrumassets",
|
||||
CyberSecServer: "CSEC",
|
||||
NiteSecServer: "avmnite-02h",
|
||||
TheBlackHandServer: "I.I.I.I",
|
||||
BitRunnersServer: "run4theh111z",
|
||||
TheDarkArmyServer: ".",
|
||||
DaedalusServer: "The-Cave",
|
||||
WorldDaemon: "w0r1d_d43m0n",
|
||||
DarkWeb: "darkweb",
|
||||
};
|
||||
@@ -4,6 +4,7 @@
|
||||
import { IMinMaxRange } from "../../types";
|
||||
import { LocationName } from "../../Locations/data/LocationNames";
|
||||
import { LiteratureNames } from "../../Literature/data/LiteratureNames";
|
||||
import { SpecialServers } from "./SpecialServers";
|
||||
|
||||
/**
|
||||
* The metadata describing the base state of servers on the network.
|
||||
@@ -319,7 +320,7 @@ export const serverMetadata: IServerMetadata[] = [
|
||||
min: 1100,
|
||||
},
|
||||
serverGrowth: 1,
|
||||
specialName: "Fulcrum Secret Technologies Server",
|
||||
specialName: SpecialServers.FulcrumSecretTechnologies,
|
||||
},
|
||||
{
|
||||
hackDifficulty: {
|
||||
@@ -1470,7 +1471,7 @@ export const serverMetadata: IServerMetadata[] = [
|
||||
min: 505,
|
||||
},
|
||||
serverGrowth: 0,
|
||||
specialName: "BitRunners Server",
|
||||
specialName: SpecialServers.BitRunnersServer,
|
||||
},
|
||||
{
|
||||
hackDifficulty: 0,
|
||||
@@ -1489,7 +1490,7 @@ export const serverMetadata: IServerMetadata[] = [
|
||||
min: 340,
|
||||
},
|
||||
serverGrowth: 0,
|
||||
specialName: "The Black Hand Server",
|
||||
specialName: SpecialServers.TheBlackHandServer,
|
||||
},
|
||||
{
|
||||
hackDifficulty: 0,
|
||||
@@ -1508,7 +1509,7 @@ export const serverMetadata: IServerMetadata[] = [
|
||||
min: 202,
|
||||
},
|
||||
serverGrowth: 0,
|
||||
specialName: "NiteSec Server",
|
||||
specialName: SpecialServers.NiteSecServer,
|
||||
},
|
||||
{
|
||||
hackDifficulty: 0,
|
||||
@@ -1523,7 +1524,7 @@ export const serverMetadata: IServerMetadata[] = [
|
||||
min: 505,
|
||||
},
|
||||
serverGrowth: 0,
|
||||
specialName: "The Dark Army Server",
|
||||
specialName: SpecialServers.TheDarkArmyServer,
|
||||
},
|
||||
{
|
||||
hackDifficulty: 0,
|
||||
@@ -1539,7 +1540,7 @@ export const serverMetadata: IServerMetadata[] = [
|
||||
min: 51,
|
||||
},
|
||||
serverGrowth: 0,
|
||||
specialName: "CyberSec Server",
|
||||
specialName: SpecialServers.CyberSecServer,
|
||||
},
|
||||
{
|
||||
hackDifficulty: 0,
|
||||
@@ -1551,7 +1552,7 @@ export const serverMetadata: IServerMetadata[] = [
|
||||
organizationName: "Helios",
|
||||
requiredHackingSkill: 925,
|
||||
serverGrowth: 0,
|
||||
specialName: "Daedalus Server",
|
||||
specialName: SpecialServers.DaedalusServer,
|
||||
},
|
||||
{
|
||||
hackDifficulty: 0,
|
||||
@@ -1561,6 +1562,6 @@ export const serverMetadata: IServerMetadata[] = [
|
||||
organizationName: "w0r1d_d43m0n",
|
||||
requiredHackingSkill: 3000,
|
||||
serverGrowth: 0,
|
||||
specialName: "w0r1d_d43m0n",
|
||||
specialName: SpecialServers.WorldDaemon,
|
||||
},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user