Merge pull request #4062 from Snarling/sleevesQuitToo

SLEEVES: FIX #4051 Sleeves no longer crash when player quits company sleeve was working
This commit is contained in:
hydroflame 2022-08-29 11:05:27 -03:00 committed by GitHub
commit 2f7463d092
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -23,6 +23,7 @@ import { Locations } from "../../Locations/Locations";
import { CityName } from "../../Locations/data/CityNames";
import { LocationName } from "../../Locations/data/LocationNames";
import { Sleeve } from "../Sleeve/Sleeve";
import { SleeveCompanyWork } from "../Sleeve/Work/SleeveCompanyWork";
import {
calculateSkill as calculateSkillF,
calculateSkillProgress as calculateSkillProgressF,
@ -593,6 +594,12 @@ export function quitJob(this: IPlayer, company: string): void {
if (isCompanyWork(this.currentWork) && this.currentWork.companyName === company) {
this.finishWork(true);
}
for (const sleeve of this.sleeves) {
if (sleeve.currentWork instanceof SleeveCompanyWork && sleeve.currentWork.companyName === company){
sleeve.stopWork(this);
dialogBoxCreate(`You quit ${company} while one of your sleeves was working there. The sleeve is now idle.`)
}
}
delete this.jobs[company];
}