TYPESAFETY: FactionName (#644)

This commit is contained in:
Snarling
2023-06-25 22:53:35 -04:00
committed by GitHub
parent 1de676972f
commit 9a0a843ffc
31 changed files with 295 additions and 751 deletions
@@ -1,11 +1,12 @@
import type { PlayerObject } from "./PlayerObject";
import type { FactionName } from "@enums";
import type { Faction } from "../../Faction/Faction";
import { Factions } from "../../Faction/Factions";
import { Faction } from "../../Faction/Faction";
import { Gang } from "../../Gang/Gang";
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;
@@ -36,12 +37,12 @@ export function getGangName(this: PlayerObject): string {
return gang ? gang.facName : "";
}
export function hasGangWith(this: PlayerObject, facName: string): boolean {
export function hasGangWith(this: PlayerObject, facName: FactionName): boolean {
const gang = this.gang;
return gang ? gang.facName === facName : false;
}
export function startGang(this: PlayerObject, factionName: string, hacking: boolean): void {
export function startGang(this: PlayerObject, factionName: FactionName, hacking: boolean): void {
// isFactionWork handles null internally, finishWork might need to be run with true
if (isFactionWork(this.currentWork) && this.currentWork.factionName === factionName) this.finishWork(false);