Remove sleeve message when quitting job from a script (#1357)

This commit is contained in:
Kelenius 2024-06-06 01:25:54 +03:00 committed by GitHub
parent bd5c502f53
commit 653d531d0a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

@ -747,7 +747,7 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
quitJob: (ctx) => (_companyName) => { quitJob: (ctx) => (_companyName) => {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const companyName = getEnumHelper("CompanyName").nsGetMember(ctx, _companyName); const companyName = getEnumHelper("CompanyName").nsGetMember(ctx, _companyName);
Player.quitJob(companyName); Player.quitJob(companyName, true);
}, },
getCompanyRep: (ctx) => (_companyName) => { getCompanyRep: (ctx) => (_companyName) => {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);

@ -361,14 +361,16 @@ export function getNextCompanyPosition(
return pos; return pos;
} }
export function quitJob(this: PlayerObject, company: CompanyName): void { export function quitJob(this: PlayerObject, company: CompanyName, suppressDialog?: boolean): void {
if (isCompanyWork(this.currentWork) && this.currentWork.companyName === company) { if (isCompanyWork(this.currentWork) && this.currentWork.companyName === company) {
this.finishWork(true); this.finishWork(true);
} }
for (const sleeve of this.sleeves) { for (const sleeve of this.sleeves) {
if (sleeve.currentWork?.type === SleeveWorkType.COMPANY && sleeve.currentWork.companyName === company) { if (sleeve.currentWork?.type === SleeveWorkType.COMPANY && sleeve.currentWork.companyName === company) {
sleeve.stopWork(); sleeve.stopWork();
dialogBoxCreate(`You quit ${company} while one of your sleeves was working there. The sleeve is now idle.`); if (!suppressDialog) {
dialogBoxCreate(`You quit ${company} while one of your sleeves was working there. The sleeve is now idle.`);
}
} }
} }
delete this.jobs[company]; delete this.jobs[company];