Remove async from employee assignment functions

This commit is contained in:
Staszek Welsh 2022-06-01 18:18:53 +01:00
parent b9356ea782
commit 7d3a43f7b5
2 changed files with 7 additions and 14 deletions

@ -705,7 +705,7 @@ export function NetscriptCorporation(player: IPlayer, workerScript: WorkerScript
}, },
assignJob: assignJob:
(ctx: NetscriptContext) => (ctx: NetscriptContext) =>
(_divisionName: unknown, _cityName: unknown, _employeeName: unknown, _job: unknown): Promise<void> => { (_divisionName: unknown, _cityName: unknown, _employeeName: unknown, _job: unknown): void => {
checkAccess(ctx, 8); checkAccess(ctx, 8);
const divisionName = ctx.helper.string("divisionName", _divisionName); const divisionName = ctx.helper.string("divisionName", _divisionName);
const cityName = ctx.helper.city("cityName", _cityName); const cityName = ctx.helper.city("cityName", _cityName);
@ -715,14 +715,11 @@ export function NetscriptCorporation(player: IPlayer, workerScript: WorkerScript
if (!Object.values(EmployeePositions).includes(job)) throw new Error(`'${job}' is not a valid job.`); if (!Object.values(EmployeePositions).includes(job)) throw new Error(`'${job}' is not a valid job.`);
const office = getOffice(divisionName, cityName); const office = getOffice(divisionName, cityName);
return netscriptDelay(0, workerScript).then(function () { AssignJob(office, employeeName, job);
return Promise.resolve(AssignJob(office, employeeName, job));
});
//return AssignJob(office, employeeName, job);
}, },
setAutoJobAssignment: setAutoJobAssignment:
(ctx: NetscriptContext) => (ctx: NetscriptContext) =>
(_divisionName: unknown, _cityName: unknown, _job: unknown, _amount: unknown): Promise<boolean> => { (_divisionName: unknown, _cityName: unknown, _job: unknown, _amount: unknown): boolean => {
checkAccess(ctx, 8); checkAccess(ctx, 8);
const divisionName = ctx.helper.string("divisionName", _divisionName); const divisionName = ctx.helper.string("divisionName", _divisionName);
const cityName = ctx.helper.city("cityName", _cityName); const cityName = ctx.helper.city("cityName", _cityName);
@ -732,10 +729,7 @@ export function NetscriptCorporation(player: IPlayer, workerScript: WorkerScript
if (!Object.values(EmployeePositions).includes(job)) throw new Error(`'${job}' is not a valid job.`); if (!Object.values(EmployeePositions).includes(job)) throw new Error(`'${job}' is not a valid job.`);
const office = getOffice(divisionName, cityName); const office = getOffice(divisionName, cityName);
return netscriptDelay(0, workerScript).then(function () { return AutoAssignJob(office, job, amount);
return Promise.resolve(AutoAssignJob(office, job, amount));
});
//return AutoAssignJob(office, job, amount);
}, },
hireEmployee: hireEmployee:
(ctx: NetscriptContext) => (ctx: NetscriptContext) =>

@ -6618,9 +6618,8 @@ export interface OfficeAPI {
* @param cityName - Name of the city * @param cityName - Name of the city
* @param employeeName - name of the employee * @param employeeName - name of the employee
* @param job - Name of the job. * @param job - Name of the job.
* @returns A promise that is fulfilled when the assignment is complete.
*/ */
assignJob(divisionName: string, cityName: string, employeeName: string, job: string): Promise<void>; assignJob(divisionName: string, cityName: string, employeeName: string, job: string): void;
/** /**
* Hire an employee. * Hire an employee.
* @param divisionName - Name of the division * @param divisionName - Name of the division
@ -6708,9 +6707,9 @@ export interface OfficeAPI {
* @param cityName - Name of the city * @param cityName - Name of the city
* @param job - Name of the job * @param job - Name of the job
* @param amount - Number of employees to assign to that job * @param amount - Number of employees to assign to that job
* @returns A promise that is fulfilled when the assignment is complete. * @returns true if the employee count reached the target amount, false if not
*/ */
setAutoJobAssignment(divisionName: string, cityName: string, job: string, amount: number): Promise<boolean>; setAutoJobAssignment(divisionName: string, cityName: string, job: string, amount: number): boolean;
/** /**
* Cost to Upgrade office size. * Cost to Upgrade office size.
* @param divisionName - Name of the division * @param divisionName - Name of the division