mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-25 18:50:56 +02:00
Refactored stock buying/selling code into its own file. Refactored WorkerScript & NetscriptEnvironment into their own Typescript classes. Refactored a ton of code to remove circular dependencies
This commit is contained in:
+1
-15
@@ -1,9 +1,6 @@
|
||||
// Class representing a single hackable Server
|
||||
import { BaseServer } from "./BaseServer";
|
||||
|
||||
// TODO This import is a circular import. Try to fix it in the future
|
||||
import { GetServerByHostname } from "./ServerHelpers";
|
||||
|
||||
import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers";
|
||||
|
||||
import { createRandomString } from "../utils/helpers/createRandomString";
|
||||
@@ -12,7 +9,7 @@ import { Generic_fromJSON,
|
||||
Generic_toJSON,
|
||||
Reviver } from "../../utils/JSONReviver";
|
||||
|
||||
interface IConstructorParams {
|
||||
export interface IConstructorParams {
|
||||
adminRights?: boolean;
|
||||
hackDifficulty?: number;
|
||||
hostname: string;
|
||||
@@ -77,17 +74,6 @@ export class Server extends BaseServer {
|
||||
this.hostname = createRandomString(10);
|
||||
}
|
||||
|
||||
// Validate hostname by ensuring there are no repeats
|
||||
if (GetServerByHostname(this.hostname) != null) {
|
||||
// Use a for loop to ensure that we don't get suck in an infinite loop somehow
|
||||
let hostname: string = this.hostname;
|
||||
for (let i = 0; i < 200; ++i) {
|
||||
hostname = `${this.hostname}-${i}`;
|
||||
if (GetServerByHostname(hostname) == null) { break; }
|
||||
}
|
||||
this.hostname = hostname;
|
||||
}
|
||||
|
||||
this.purchasedByPlayer = params.purchasedByPlayer != null ? params.purchasedByPlayer : false;
|
||||
|
||||
//RAM, CPU speed and Scripts
|
||||
|
||||
Reference in New Issue
Block a user