mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-27 01:53:48 +01:00
Merge pull request #3552 from Snarling/jobSwitchFix
COMPANY: Fix #3551 Applying for a new job will not change active employer if player is performing company work
This commit is contained in:
commit
fc3d89e51f
@ -1751,14 +1751,6 @@ export function hospitalize(this: IPlayer): number {
|
|||||||
//The 'sing' argument designates whether or not this is being called from
|
//The 'sing' argument designates whether or not this is being called from
|
||||||
//the applyToCompany() Netscript Singularity function
|
//the applyToCompany() Netscript Singularity function
|
||||||
export function applyForJob(this: IPlayer, entryPosType: CompanyPosition, sing = false): boolean {
|
export function applyForJob(this: IPlayer, entryPosType: CompanyPosition, sing = false): boolean {
|
||||||
// Get current company and job
|
|
||||||
let currCompany = null;
|
|
||||||
if (this.companyName !== "") {
|
|
||||||
currCompany = Companies[this.companyName];
|
|
||||||
}
|
|
||||||
const currPositionName = this.jobs[this.companyName];
|
|
||||||
|
|
||||||
// Get company that's being applied to
|
|
||||||
const company = Companies[this.location]; //Company being applied to
|
const company = Companies[this.location]; //Company being applied to
|
||||||
if (!(company instanceof Company)) {
|
if (!(company instanceof Company)) {
|
||||||
console.error(`Could not find company that matches the location: ${this.location}. Player.applyToCompany() failed`);
|
console.error(`Could not find company that matches the location: ${this.location}. Player.applyToCompany() failed`);
|
||||||
@ -1768,66 +1760,44 @@ export function applyForJob(this: IPlayer, entryPosType: CompanyPosition, sing =
|
|||||||
let pos = entryPosType;
|
let pos = entryPosType;
|
||||||
|
|
||||||
if (!this.isQualified(company, pos)) {
|
if (!this.isQualified(company, pos)) {
|
||||||
const reqText = getJobRequirementText(company, pos);
|
|
||||||
if (!sing) {
|
if (!sing) {
|
||||||
dialogBoxCreate("Unfortunately, you do not qualify for this position<br>" + reqText);
|
dialogBoxCreate("Unfortunately, you do not qualify for this position<br>" + getJobRequirementText(company, pos));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if this company has the position
|
|
||||||
if (!company.hasPosition(pos)) {
|
if (!company.hasPosition(pos)) {
|
||||||
|
console.error(`Company ${company.name} does not have position ${pos}. Player.applyToCompany() failed`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
const newPos = getNextCompanyPositionHelper(pos);
|
const nextPos = getNextCompanyPositionHelper(pos);
|
||||||
if (newPos == null) {
|
if (nextPos == null) break;
|
||||||
break;
|
if (company.hasPosition(nextPos) && this.isQualified(company, nextPos)) {
|
||||||
}
|
pos = nextPos;
|
||||||
|
} else break;
|
||||||
//Check if this company has this position
|
|
||||||
if (company.hasPosition(newPos)) {
|
|
||||||
if (!this.isQualified(company, newPos)) {
|
|
||||||
//If player not qualified for next job, break loop so player will be given current job
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
pos = newPos;
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check if the determined job is the same as the player's current job
|
//Check if player already has the assigned job
|
||||||
if (currCompany != null) {
|
if (this.jobs[company.name] === pos.name) {
|
||||||
if (currCompany.name == company.name && pos.name == currPositionName) {
|
if (!sing) {
|
||||||
const nextPos = getNextCompanyPositionHelper(pos);
|
const nextPos = getNextCompanyPositionHelper(pos);
|
||||||
if (nextPos == null) {
|
if (nextPos == null || !company.hasPosition(nextPos)) {
|
||||||
if (!sing) {
|
dialogBoxCreate("You are already at the highest position for your field! No promotion available");
|
||||||
dialogBoxCreate("You are already at the highest position for your field! No promotion available");
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
} else if (company.hasPosition(nextPos)) {
|
|
||||||
if (!sing) {
|
|
||||||
const reqText = getJobRequirementText(company, nextPos);
|
|
||||||
dialogBoxCreate("Unfortunately, you do not qualify for a promotion<br>" + reqText);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
} else {
|
} else {
|
||||||
if (!sing) {
|
const reqText = getJobRequirementText(company, nextPos);
|
||||||
dialogBoxCreate("You are already at the highest position for your field! No promotion available");
|
dialogBoxCreate("Unfortunately, you do not qualify for a promotion<br>" + reqText);
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.jobs[company.name] = pos.name;
|
this.jobs[company.name] = pos.name;
|
||||||
if (!this.focus && this.isWorking && this.companyName !== this.location) this.resetWorkStatus();
|
if (!this.isWorking || !this.workType.includes("Working for Company")) this.companyName = company.name;
|
||||||
this.companyName = this.location;
|
|
||||||
|
|
||||||
if (!sing) {
|
if (!sing) {
|
||||||
dialogBoxCreate("Congratulations! You were offered a new job at " + this.companyName + " as a " + pos.name + "!");
|
dialogBoxCreate("Congratulations! You were offered a new job at " + company.name + " as a " + pos.name + "!");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user