Added check if factionWork is from faction of gang (#243)

This commit is contained in:
G4mingJon4s 2022-12-04 04:58:40 +01:00 committed by GitHub
parent 49f732d1ee
commit 633296da15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -3,6 +3,7 @@ import { Faction } from "../../Faction/Faction";
import { Gang } from "../../Gang/Gang"; import { Gang } from "../../Gang/Gang";
import { PlayerObject } from "./PlayerObject"; import { PlayerObject } from "./PlayerObject";
import { GangConstants } from "../../Gang/data/Constants"; import { GangConstants } from "../../Gang/data/Constants";
import { isFactionWork } from "../../Work/FactionWork";
export function canAccessGang(this: PlayerObject): boolean { export function canAccessGang(this: PlayerObject): boolean {
if (this.bitNodeN === 2) { if (this.bitNodeN === 2) {
@ -40,6 +41,9 @@ export function hasGangWith(this: PlayerObject, facName: string): boolean {
} }
export function startGang(this: PlayerObject, factionName: string, hacking: boolean): void { export function startGang(this: PlayerObject, factionName: string, 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);
this.gang = new Gang(factionName, hacking); this.gang = new Gang(factionName, hacking);
const fac = Factions[factionName]; const fac = Factions[factionName];