added early out for when faction isnt found

This commit is contained in:
phyzical 2022-03-05 13:56:11 +08:00
parent fb4812b530
commit 7a6e7ed992

@ -859,10 +859,8 @@ export class Sleeve extends Person {
* Returns boolean indicating success
*/
workForFaction(p: IPlayer, factionName: string, workType: string): boolean {
if (factionName === "") {
return false;
}
if (!(Factions[factionName] instanceof Faction) || !p.factions.includes(factionName)) {
const faction = Factions[factionName]
if (factionName === "" || !faction || !(faction instanceof Faction) || !p.factions.includes(factionName)) {
return false;
}
@ -872,7 +870,7 @@ export class Sleeve extends Person {
this.resetTaskStatus();
}
const factionInfo = Factions[factionName].getInfo();
const factionInfo = faction.getInfo();
// Set type of work (hacking/field/security), and the experience gains
const sanitizedWorkType: string = workType.toLowerCase();