Fixes 1862 Combat gang members can do hacking tasks via API and vice versa

This commit is contained in:
TheMas3212 2022-01-05 22:02:25 +11:00
parent fc888505ae
commit c9f0c9c553
No known key found for this signature in database
GPG Key ID: 62A173A4FDA683CA

@ -194,6 +194,15 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
helper.updateDynamicRam("setMemberTask", getRamCost(player, "gang", "setMemberTask"));
checkGangApiAccess("setMemberTask");
const member = getGangMember("setMemberTask", memberName);
const gang = player.gang;
if (gang === null) throw new Error("Should not be called without Gang");
if (!gang.getAllTaskNames().includes(taskName)) {
workerScript.log(
"gang.setMemberTask",
() => `Failed to assign Gang Member '${memberName}' to Invalid task '${taskName}'. '${memberName}' is now Unassigned`,
);
return member.assignToTask('Unassigned');
}
const success = member.assignToTask(taskName);
if (success) {
workerScript.log(