Fix setAutoAssignJob parameter validation. (#339)

This commit is contained in:
Christian Roy 2023-01-29 04:39:01 -08:00 committed by GitHub
parent c1d3664955
commit d7439aae52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -616,10 +616,13 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
);
const office = getOffice(divisionName, cityName);
if (office.employeeJobs[EmployeePositions.Unassigned] < amount)
const totalNewEmployees = amount - office.employeeNextJobs[job];
if (office.employeeNextJobs[EmployeePositions.Unassigned] < totalNewEmployees)
throw helpers.makeRuntimeErrorMsg(
ctx,
`Tried to assign more Employees to '${job}' than are unassigned. Amount:'${amount}'`,
`Unable to bring '${job} employees to ${amount}. Requires ${totalNewEmployees} unassigned employees`,
);
return AutoAssignJob(office, job, amount);
},