diff --git a/src/PersonObjects/Player/PlayerObjectBladeburnerMethods.js b/src/PersonObjects/Player/PlayerObjectBladeburnerMethods.ts similarity index 68% rename from src/PersonObjects/Player/PlayerObjectBladeburnerMethods.js rename to src/PersonObjects/Player/PlayerObjectBladeburnerMethods.ts index ebf4cf7aa..37d6562e7 100644 --- a/src/PersonObjects/Player/PlayerObjectBladeburnerMethods.js +++ b/src/PersonObjects/Player/PlayerObjectBladeburnerMethods.ts @@ -1,7 +1,8 @@ import { Bladeburner } from "../../Bladeburner/Bladeburner"; import { SourceFileFlags } from "../../SourceFile/SourceFileFlags"; +import { IPlayer } from "../IPlayer"; -export function canAccessBladeburner() { +export function canAccessBladeburner(this: IPlayer) { if (this.bitNodeN === 8) { return false; } @@ -9,13 +10,13 @@ export function canAccessBladeburner() { return this.bitNodeN === 6 || this.bitNodeN === 7 || SourceFileFlags[6] > 0 || SourceFileFlags[7] > 0; } -export function inBladeburner() { +export function inBladeburner(this: IPlayer): boolean { if (this.bladeburner == null) { return false; } return this.bladeburner instanceof Bladeburner; } -export function startBladeburner() { +export function startBladeburner(this: IPlayer): void { this.bladeburner = new Bladeburner(this); } diff --git a/src/PersonObjects/Player/PlayerObjectCorporationMethods.js b/src/PersonObjects/Player/PlayerObjectCorporationMethods.ts similarity index 62% rename from src/PersonObjects/Player/PlayerObjectCorporationMethods.js rename to src/PersonObjects/Player/PlayerObjectCorporationMethods.ts index 776716831..c00380606 100644 --- a/src/PersonObjects/Player/PlayerObjectCorporationMethods.js +++ b/src/PersonObjects/Player/PlayerObjectCorporationMethods.ts @@ -1,18 +1,19 @@ import { Corporation } from "../../Corporation/Corporation"; import { SourceFileFlags } from "../../SourceFile/SourceFileFlags"; +import { IPlayer } from "../IPlayer"; -export function canAccessCorporation() { +export function canAccessCorporation(this: IPlayer): boolean { return this.bitNodeN === 3 || SourceFileFlags[3] > 0; } -export function hasCorporation() { +export function hasCorporation(this: IPlayer): boolean { if (this.corporation == null) { return false; } return this.corporation instanceof Corporation; } -export function startCorporation(corpName, additionalShares = 0) { +export function startCorporation(this: IPlayer, corpName: string, additionalShares = 0): void { this.corporation = new Corporation({ name: corpName, }); diff --git a/src/PersonObjects/Player/PlayerObjectGangMethods.js b/src/PersonObjects/Player/PlayerObjectGangMethods.ts similarity index 71% rename from src/PersonObjects/Player/PlayerObjectGangMethods.js rename to src/PersonObjects/Player/PlayerObjectGangMethods.ts index 9770c77c8..b8aea304f 100644 --- a/src/PersonObjects/Player/PlayerObjectGangMethods.js +++ b/src/PersonObjects/Player/PlayerObjectGangMethods.ts @@ -1,12 +1,14 @@ import { Factions } from "../../Faction/Factions"; +import { Faction } from "../../Faction/Faction"; import { Gang } from "../../Gang/Gang"; import { SourceFileFlags } from "../../SourceFile/SourceFileFlags"; import { BitNodeMultipliers } from "../../BitNode/BitNodeMultipliers"; +import { IPlayer } from "../IPlayer"; // Amount of negative karma needed to manage a gang in BitNodes other than 2 const GangKarmaRequirement = -54000; -export function canAccessGang() { +export function canAccessGang(this: IPlayer): boolean { if (this.bitNodeN === 2) { return true; } @@ -17,7 +19,7 @@ export function canAccessGang() { return this.karma <= BitNodeMultipliers.GangKarmaRequirement * GangKarmaRequirement; } -export function getGangFaction() { +export function getGangFaction(this: IPlayer): Faction { const fac = Factions[this.gang.facName]; if (fac == null) { throw new Error(`Gang has invalid faction name: ${this.gang.facName}`); @@ -26,15 +28,15 @@ export function getGangFaction() { return fac; } -export function getGangName() { +export function getGangName(this: IPlayer): string { return this.inGang() ? this.gang.facName : ""; } -export function hasGangWith(facName) { +export function hasGangWith(this: IPlayer, facName: string): boolean { return this.inGang() && this.gang.facName === facName; } -export function inGang() { +export function inGang(this: IPlayer): boolean { if (this.gang == null || this.gang == undefined) { return false; } @@ -42,7 +44,7 @@ export function inGang() { return this.gang instanceof Gang; } -export function startGang(factionName, hacking) { +export function startGang(this: IPlayer, factionName: string, hacking: boolean): void { this.gang = new Gang(factionName, hacking); const fac = Factions[factionName];