Merge pull request #3070 from phyzical/bugfix/2832-2

Sleeve fix for when faction isnt found
This commit is contained in:
hydroflame 2022-03-08 16:32:10 -05:00 committed by GitHub
commit 4518b3a7cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -453,11 +453,11 @@ export class Sleeve extends Person {
// Reset augs and multipliers // Reset augs and multipliers
this.augmentations = []; this.augmentations = [];
this.resetMultipliers(); this.resetMultipliers();
// Reset Location // Reset Location
this.city=CityName.Sector12; this.city = CityName.Sector12;
// Reset sleeve-related stats // Reset sleeve-related stats
this.shock = 1; this.shock = 1;
this.storedCycles = 0; this.storedCycles = 0;
@ -859,10 +859,8 @@ export class Sleeve extends Person {
* Returns boolean indicating success * Returns boolean indicating success
*/ */
workForFaction(p: IPlayer, factionName: string, workType: string): boolean { workForFaction(p: IPlayer, factionName: string, workType: string): boolean {
if (factionName === "") { const faction = Factions[factionName]
return false; if (factionName === "" || !faction || !(faction instanceof Faction) || !p.factions.includes(factionName)) {
}
if (!(Factions[factionName] instanceof Faction) || !p.factions.includes(factionName)) {
return false; return false;
} }
@ -872,7 +870,7 @@ export class Sleeve extends Person {
this.resetTaskStatus(); this.resetTaskStatus();
} }
const factionInfo = Factions[factionName].getInfo(); const factionInfo = faction.getInfo();
// Set type of work (hacking/field/security), and the experience gains // Set type of work (hacking/field/security), and the experience gains
const sanitizedWorkType: string = workType.toLowerCase(); const sanitizedWorkType: string = workType.toLowerCase();