Merge pull request #2406 from Ornedan/corporation-delay-check-stop

Make corporation delayed functions check if script has been stopped
This commit is contained in:
hydroflame 2022-01-06 13:05:06 -05:00 committed by GitHub
commit 4363aa43fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -311,6 +311,9 @@ export function NetscriptCorporation(
const job = helper.string("assignJob", "job", ajob); const job = helper.string("assignJob", "job", ajob);
const employee = getEmployee(divisionName, cityName, employeeName); const employee = getEmployee(divisionName, cityName, employeeName);
return netscriptDelay(1000, workerScript).then(function () { return netscriptDelay(1000, workerScript).then(function () {
if (workerScript.env.stopFlag) {
return Promise.reject(workerScript);
}
return Promise.resolve(AssignJob(employee, job)); return Promise.resolve(AssignJob(employee, job));
}); });
}, },
@ -341,6 +344,9 @@ export function NetscriptCorporation(
(60 * 1000) / (player.hacking_speed_mult * calculateIntelligenceBonus(player.intelligence, 1)), (60 * 1000) / (player.hacking_speed_mult * calculateIntelligenceBonus(player.intelligence, 1)),
workerScript, workerScript,
).then(function () { ).then(function () {
if (workerScript.env.stopFlag) {
return Promise.reject(workerScript);
}
return Promise.resolve(ThrowParty(corporation, office, costPerEmployee)); return Promise.resolve(ThrowParty(corporation, office, costPerEmployee));
}); });
}, },
@ -353,6 +359,9 @@ export function NetscriptCorporation(
(60 * 1000) / (player.hacking_speed_mult * calculateIntelligenceBonus(player.intelligence, 1)), (60 * 1000) / (player.hacking_speed_mult * calculateIntelligenceBonus(player.intelligence, 1)),
workerScript, workerScript,
).then(function () { ).then(function () {
if (workerScript.env.stopFlag) {
return Promise.reject(workerScript);
}
return Promise.resolve(BuyCoffee(corporation, getDivision(divisionName), getOffice(divisionName, cityName))); return Promise.resolve(BuyCoffee(corporation, getDivision(divisionName), getOffice(divisionName, cityName)));
}); });
}, },