Moved Player initialization point (#452)

Now initialized as side effect in PlayerObject, instead of in Player file that is imported everywhere.
This commit is contained in:
David Walker
2023-03-28 21:30:27 -07:00
committed by GitHub
parent 798da75d83
commit 8445af5f2b
15 changed files with 43 additions and 11 deletions
+3
View File
@@ -6,6 +6,7 @@ import * as generalMethods from "./PlayerObjectGeneralMethods";
import * as serverMethods from "./PlayerObjectServerMethods";
import * as workMethods from "./PlayerObjectWorkMethods";
import { setPlayer } from "../../Player";
import { Sleeve } from "../Sleeve/Sleeve";
import { PlayerOwnedSourceFile } from "../../SourceFile/PlayerOwnedSourceFile";
import { Exploit } from "../../Exploits/Exploit";
@@ -172,4 +173,6 @@ export class PlayerObject extends Person implements IPlayer {
}
}
setPlayer(new PlayerObject());
Reviver.constructors.PlayerObject = PlayerObject;
@@ -1,7 +1,8 @@
/** Augmentation-related methods for the Player class (PlayerObject) */
import { PlayerObject } from "./PlayerObject";
import { calculateEntropy } from "../Grafting/EntropyAccumulation";
import type { PlayerObject } from "./PlayerObject";
export function applyEntropy(this: PlayerObject, stacks = 1): void {
// Re-apply all multipliers
this.reapplyAllAugmentations();
@@ -1,5 +1,6 @@
import { Bladeburner } from "../../Bladeburner/Bladeburner";
import { PlayerObject } from "./PlayerObject";
import type { PlayerObject } from "./PlayerObject";
export function canAccessBladeburner(this: PlayerObject): boolean {
return this.bitNodeN === 6 || this.bitNodeN === 7 || this.sourceFileLvl(6) > 0 || this.sourceFileLvl(7) > 0;
@@ -3,9 +3,10 @@ import {
CorporationUnlockUpgradeIndex,
CorporationUnlockUpgrades,
} from "../../Corporation/data/CorporationUnlockUpgrades";
import { PlayerObject } from "./PlayerObject";
import { resetIndustryResearchTrees } from "../../Corporation/IndustryData";
import type { PlayerObject } from "./PlayerObject";
export function canAccessCorporation(this: PlayerObject): boolean {
return this.bitNodeN === 3 || this.sourceFileLvl(3) > 0;
}
@@ -1,10 +1,11 @@
import { Factions } from "../../Faction/Factions";
import { Faction } from "../../Faction/Faction";
import { Gang } from "../../Gang/Gang";
import { PlayerObject } from "./PlayerObject";
import { GangConstants } from "../../Gang/data/Constants";
import { isFactionWork } from "../../Work/FactionWork";
import type { PlayerObject } from "./PlayerObject";
export function canAccessGang(this: PlayerObject): boolean {
if (this.bitNodeN === 2) {
return true;
@@ -1,4 +1,3 @@
import { PlayerObject } from "./PlayerObject";
import { applyAugmentation } from "../../Augmentation/AugmentationHelpers";
import { PlayerOwnedAugmentation } from "../../Augmentation/PlayerOwnedAugmentation";
import { AugmentationNames } from "../../Augmentation/data/AugmentationNames";
@@ -45,6 +44,8 @@ import { FactionNames } from "../../Faction/data/FactionNames";
import { isCompanyWork } from "../../Work/CompanyWork";
import { serverMetadata } from "../../Server/data/servers";
import type { PlayerObject } from "./PlayerObject";
export function init(this: PlayerObject): void {
/* Initialize Player's home computer */
const t_homeComp = safelyCreateUniqueServer({
@@ -1,6 +1,4 @@
// Server and HacknetServer-related methods for the Player class (PlayerObject)
import { PlayerObject } from "./PlayerObject";
import { CONSTANTS } from "../../Constants";
import { BitNodeMultipliers } from "../../BitNode/BitNodeMultipliers";
@@ -11,6 +9,8 @@ import { GetServer, AddToAllServers, createUniqueRandomIp } from "../../Server/A
import { SpecialServers } from "../../Server/data/SpecialServers";
import { hasHacknetServers } from "../../Hacknet/HacknetHelpers";
import type { PlayerObject } from "./PlayerObject";
export function hasTorRouter(this: PlayerObject): boolean {
return this.getHomeComputer().serversOnNetwork.includes(SpecialServers.DarkWeb);
}
@@ -1,5 +1,6 @@
import { Work } from "../../Work/Work";
import { PlayerObject } from "./PlayerObject";
import type { PlayerObject } from "./PlayerObject";
export function startWork(this: PlayerObject, w: Work): void {
if (this.currentWork !== null) {