From 1dcde649becfc64016c1d4126426dd69cf113701 Mon Sep 17 00:00:00 2001 From: TheMas3212 Date: Sun, 2 Jan 2022 03:08:16 +1100 Subject: [PATCH] fixes #1752 add check when applying for job to make sure company actually has that job position --- .../Player/PlayerObjectGeneralMethods.tsx | 41 +++++++++++++++---- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx b/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx index e3723daea..3b77c2f7b 100644 --- a/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx +++ b/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx @@ -1690,6 +1690,11 @@ export function applyForJob(this: IPlayer, entryPosType: CompanyPosition, sing = return false; } + // Check if this company has the position + if (!company.hasPosition(pos)) { + return false; + } + while (true) { const newPos = getNextCompanyPositionHelper(pos); if (newPos == null) { @@ -1863,9 +1868,14 @@ export function applyForAgentJob(this: IPlayer, sing = false): boolean { export function applyForEmployeeJob(this: IPlayer, sing = false): boolean { const company = Companies[this.location]; //Company being applied to - if (this.isQualified(company, CompanyPositions[posNames.MiscCompanyPositions[1]])) { + const position = posNames.MiscCompanyPositions[1]; + // Check if this company has the position + if (!company.hasPosition(position)) { + return false; + } + if (this.isQualified(company, CompanyPositions[position])) { this.companyName = company.name; - this.jobs[company.name] = posNames.MiscCompanyPositions[1]; + this.jobs[company.name] = position; if (!sing) { dialogBoxCreate("Congratulations, you are now employed at " + this.location); } @@ -1882,8 +1892,13 @@ export function applyForEmployeeJob(this: IPlayer, sing = false): boolean { export function applyForPartTimeEmployeeJob(this: IPlayer, sing = false): boolean { const company = Companies[this.location]; //Company being applied to - if (this.isQualified(company, CompanyPositions[posNames.PartTimeCompanyPositions[1]])) { - this.jobs[company.name] = posNames.PartTimeCompanyPositions[1]; + const position = posNames.PartTimeCompanyPositions[1]; + // Check if this company has the position + if (!company.hasPosition(position)) { + return false; + } + if (this.isQualified(company, CompanyPositions[position])) { + this.jobs[company.name] = position; if (!sing) { dialogBoxCreate("Congratulations, you are now employed part-time at " + this.location); } @@ -1900,9 +1915,14 @@ export function applyForPartTimeEmployeeJob(this: IPlayer, sing = false): boolea export function applyForWaiterJob(this: IPlayer, sing = false): boolean { const company = Companies[this.location]; //Company being applied to - if (this.isQualified(company, CompanyPositions[posNames.MiscCompanyPositions[0]])) { + const position = posNames.MiscCompanyPositions[0]; + // Check if this company has the position + if (!company.hasPosition(position)) { + return false; + } + if (this.isQualified(company, CompanyPositions[position])) { this.companyName = company.name; - this.jobs[company.name] = posNames.MiscCompanyPositions[0]; + this.jobs[company.name] = position; if (!sing) { dialogBoxCreate("Congratulations, you are now employed as a waiter at " + this.location); } @@ -1917,9 +1937,14 @@ export function applyForWaiterJob(this: IPlayer, sing = false): boolean { export function applyForPartTimeWaiterJob(this: IPlayer, sing = false): boolean { const company = Companies[this.location]; //Company being applied to - if (this.isQualified(company, CompanyPositions[posNames.PartTimeCompanyPositions[0]])) { + const position = posNames.PartTimeCompanyPositions[0]; + // Check if this company has the position + if (!company.hasPosition(position)) { + return false; + } + if (this.isQualified(company, CompanyPositions[position])) { this.companyName = company.name; - this.jobs[company.name] = posNames.PartTimeCompanyPositions[0]; + this.jobs[company.name] = position; if (!sing) { dialogBoxCreate("Congratulations, you are now employed as a part-time waiter at " + this.location); }