mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-29 19:13:49 +01:00
convert some files to ts
This commit is contained in:
parent
cdd9c174e7
commit
8fd6b2e7da
@ -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);
|
||||
}
|
@ -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,
|
||||
});
|
@ -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];
|
Loading…
Reference in New Issue
Block a user