mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-24 15:12:27 +01:00
CORPORATION: added Checks to setAutoJobAssignment (#307)
This commit is contained in:
parent
593b860241
commit
b4743a9841
@ -608,7 +608,18 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
|
|||||||
const job = helpers.string(ctx, "job", _job);
|
const job = helpers.string(ctx, "job", _job);
|
||||||
|
|
||||||
if (!checkEnum(EmployeePositions, job)) throw new Error(`'${job}' is not a valid job.`);
|
if (!checkEnum(EmployeePositions, job)) throw new Error(`'${job}' is not a valid job.`);
|
||||||
|
if (amount < 0 || !Number.isInteger(amount))
|
||||||
|
throw helpers.makeRuntimeErrorMsg(
|
||||||
|
ctx,
|
||||||
|
`Invalid value for amount! Must be an integer and greater than or be 0". Amount:'${amount}'`,
|
||||||
|
);
|
||||||
|
|
||||||
const office = getOffice(divisionName, cityName);
|
const office = getOffice(divisionName, cityName);
|
||||||
|
if (office.employeeJobs[EmployeePositions.Unassigned] < amount)
|
||||||
|
throw helpers.makeRuntimeErrorMsg(
|
||||||
|
ctx,
|
||||||
|
`Tried to assign more Employees to '${job}' than are unassigned. Amount:'${amount}'`,
|
||||||
|
);
|
||||||
return AutoAssignJob(office, job, amount);
|
return AutoAssignJob(office, job, amount);
|
||||||
},
|
},
|
||||||
hireEmployee: (ctx) => (_divisionName, _cityName, _position?) => {
|
hireEmployee: (ctx) => (_divisionName, _cityName, _position?) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user