2017-02-03 00:33:47 +01:00
|
|
|
/* Functions that handle applying for different jobs/positions in a Company */
|
|
|
|
|
2017-02-03 05:02:27 +01:00
|
|
|
//Determines the job that the Player should get (if any) at the current
|
|
|
|
//company
|
2017-07-28 16:19:28 +02:00
|
|
|
PlayerObject.prototype.applyForJob = function(entryPosType) {
|
2017-02-03 23:05:59 +01:00
|
|
|
var currCompany = "";
|
|
|
|
if (this.companyName != "") {
|
|
|
|
currCompany = Companies[this.companyName];
|
|
|
|
}
|
|
|
|
var currPositionName = "";
|
|
|
|
if (this.companyPosition != "") {
|
|
|
|
currPositionName = this.companyPosition.positionName;
|
|
|
|
}
|
2017-02-03 00:33:47 +01:00
|
|
|
var company = Companies[this.location]; //Company being applied to
|
2017-07-28 16:19:28 +02:00
|
|
|
|
2017-02-03 05:02:27 +01:00
|
|
|
var pos = entryPosType;
|
2017-07-28 16:19:28 +02:00
|
|
|
|
2017-02-03 23:05:59 +01:00
|
|
|
if (!this.isQualified(company, pos)) {
|
2017-05-30 05:52:06 +02:00
|
|
|
var reqText = getJobRequirementText(company, pos);
|
2017-06-01 06:17:50 +02:00
|
|
|
dialogBoxCreate("Unforunately, you do not qualify for this position<br>" + reqText);
|
2017-02-03 23:05:59 +01:00
|
|
|
return;
|
|
|
|
}
|
2017-07-28 16:19:28 +02:00
|
|
|
|
2017-02-03 00:33:47 +01:00
|
|
|
while (true) {
|
2017-02-03 05:02:27 +01:00
|
|
|
if (Engine.Debug) {console.log("Determining qualification for next Company Position");}
|
2017-02-03 00:33:47 +01:00
|
|
|
var newPos = getNextCompanyPosition(pos);
|
2017-07-28 16:19:28 +02:00
|
|
|
|
2017-02-03 23:05:59 +01:00
|
|
|
if (newPos == null) {
|
|
|
|
if (Engine.Debug) {
|
|
|
|
console.log("Player already at highest position, cannot go any higher");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2017-07-28 16:19:28 +02:00
|
|
|
|
2017-02-03 05:02:27 +01:00
|
|
|
//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 {
|
2017-02-03 23:05:59 +01:00
|
|
|
break;
|
2017-02-03 00:33:47 +01:00
|
|
|
}
|
2017-07-28 16:19:28 +02:00
|
|
|
|
2017-02-03 00:33:47 +01:00
|
|
|
}
|
2017-07-28 16:19:28 +02:00
|
|
|
|
2017-02-03 00:33:47 +01:00
|
|
|
//Check if the determined job is the same as the player's current job
|
2017-02-03 23:05:59 +01:00
|
|
|
if (currCompany != "") {
|
|
|
|
if (currCompany.companyName == company.companyName &&
|
|
|
|
pos.positionName == currPositionName) {
|
2017-04-25 09:14:24 +02:00
|
|
|
var nextPos = getNextCompanyPosition(pos);
|
2017-05-30 05:52:06 +02:00
|
|
|
var reqText = getJobRequirementText(company, nextPos);
|
2017-06-01 06:17:50 +02:00
|
|
|
dialogBoxCreate("Unfortunately, you do not qualify for a promotion<br>" + reqText);
|
2017-07-28 16:19:28 +02:00
|
|
|
|
2017-02-03 23:05:59 +01:00
|
|
|
return; //Same job, do nothing
|
|
|
|
}
|
2017-02-03 05:02:27 +01:00
|
|
|
}
|
2017-07-28 16:19:28 +02:00
|
|
|
|
|
|
|
|
2017-02-03 05:02:27 +01:00
|
|
|
//Lose reputation from a Company if you are leaving it for another job
|
2017-04-24 17:35:10 +02:00
|
|
|
var leaveCompany = false;
|
|
|
|
var oldCompanyName = "";
|
2017-02-03 23:05:59 +01:00
|
|
|
if (currCompany != "") {
|
|
|
|
if (currCompany.companyName != company.companyName) {
|
2017-04-24 17:35:10 +02:00
|
|
|
leaveCompany = true;
|
|
|
|
oldCompanyName = currCompany.companyName;
|
2017-02-03 23:05:59 +01:00
|
|
|
company.playerReputation -= 1000;
|
2017-04-18 06:32:17 +02:00
|
|
|
if (company.playerReputation < 0) {company.playerReputation = 0;}
|
|
|
|
if (Engine.debug) {
|
|
|
|
console.log("Lost reputation for " + company.companyName + ". It is now " + company.playerReputation);
|
|
|
|
}
|
2017-02-03 23:05:59 +01:00
|
|
|
}
|
2017-02-03 05:02:27 +01:00
|
|
|
}
|
2017-07-28 16:19:28 +02:00
|
|
|
|
2017-02-03 05:02:27 +01:00
|
|
|
this.companyName = company.companyName;
|
|
|
|
this.companyPosition = pos;
|
2017-07-28 16:19:28 +02:00
|
|
|
|
2017-04-24 17:35:10 +02:00
|
|
|
if (leaveCompany) {
|
2017-07-28 16:19:28 +02:00
|
|
|
dialogBoxCreate("Congratulations! You were offered a new job at " + this.companyName + " as a " +
|
|
|
|
pos.positionName + "!<br>" +
|
|
|
|
"You lost 1000 reputation at your old company " + oldCompanyName + " because you left.");
|
2017-04-24 17:35:10 +02:00
|
|
|
} else {
|
2017-04-24 21:10:35 +02:00
|
|
|
dialogBoxCreate("Congratulations! You were offered a new job at " + this.companyName + " as a " + pos.positionName + "!");
|
2017-04-24 17:35:10 +02:00
|
|
|
}
|
2017-07-28 16:19:28 +02:00
|
|
|
|
2017-02-08 05:48:50 +01:00
|
|
|
Engine.loadLocationContent();
|
2017-02-03 05:02:27 +01:00
|
|
|
}
|
|
|
|
|
2017-07-28 16:19:28 +02:00
|
|
|
function getJobRequirementText(company, pos, tooltiptext=false) {
|
2017-05-30 05:52:06 +02:00
|
|
|
var reqText = "";
|
|
|
|
var offset = company.jobStatReqOffset;
|
|
|
|
var reqHacking = pos.requiredHacking > 0 ? pos.requiredHacking+offset : 0;
|
|
|
|
var reqStrength = pos.requiredStrength > 0 ? pos.requiredStrength+offset : 0;
|
|
|
|
var reqDefense = pos.requiredDefense > 0 ? pos.requiredDefense+offset : 0;
|
|
|
|
var reqDexterity = pos.requiredDexterity > 0 ? pos.requiredDexterity+offset : 0;
|
|
|
|
var reqAgility = pos.requiredDexterity > 0 ? pos.requiredDexterity+offset : 0;
|
|
|
|
var reqCharisma = pos.requiredCharisma > 0 ? pos.requiredCharisma+offset : 0;
|
|
|
|
var reqRep = pos.requiredReputation;
|
2017-07-28 16:19:28 +02:00
|
|
|
if (tooltiptext) {
|
|
|
|
reqText = "Requires:<br>";
|
|
|
|
reqText += (reqHacking.toString() + " hacking<br>");
|
|
|
|
reqText += (reqStrength.toString() + " strength<br>");
|
|
|
|
reqText += (reqDefense.toString() + " defense<br>");
|
|
|
|
reqText += (reqDexterity.toString() + " dexterity<br>");
|
|
|
|
reqText += (reqAgility.toString() + " agility<br>");
|
|
|
|
reqText += (reqCharisma.toString() + " charisma<br>");
|
|
|
|
reqText += (reqRep.toString() + " and reputation");
|
|
|
|
} else {
|
|
|
|
reqText = "(Requires ";
|
|
|
|
if (reqHacking > 0) {reqText += (reqHacking + " hacking, ");}
|
|
|
|
if (reqStrength > 0) {reqText += (reqStrength + " strength, ");}
|
|
|
|
if (reqDefense > 0) {reqText += (reqDefense + " defense, ");}
|
|
|
|
if (reqDexterity > 0) {reqText += (reqDexterity + " dexterity, ");}
|
|
|
|
if (reqAgility > 0) {reqText += (reqAgility + " agility, ");}
|
|
|
|
if (reqCharisma > 0) {reqText += (reqCharisma + " charisma, ");}
|
|
|
|
if (reqRep > 1) {reqText += (reqRep + " reputation, ");}
|
|
|
|
reqText = reqText.substring(0, reqText.length - 2);
|
|
|
|
reqText += ")";
|
|
|
|
}
|
2017-05-30 05:52:06 +02:00
|
|
|
return reqText;
|
|
|
|
}
|
|
|
|
|
2017-07-28 16:19:28 +02:00
|
|
|
//Returns your next position at a company given the field (software, business, etc.)
|
|
|
|
PlayerObject.prototype.getNextCompanyPosition = function(company, entryPosType) {
|
|
|
|
var currCompany = null;
|
|
|
|
if (this.companyName != "") {
|
|
|
|
currCompany = Companies[this.companyName];
|
|
|
|
}
|
|
|
|
|
|
|
|
//Not employed at this company, so return the entry position
|
|
|
|
if (currCompany == null || (currCompany.companyName != company.companyName)) {
|
|
|
|
return entryPosType;
|
|
|
|
}
|
|
|
|
|
|
|
|
//If the entry pos type and the player's current position have the same type,
|
|
|
|
//return the player's "nextCompanyPosition". Otherwise return the entryposType
|
|
|
|
//Employed at this company, so just return the next position if it exists.
|
|
|
|
if ((this.companyPosition.isSoftwareJob() && entryPosType.isSoftwareJob()) ||
|
|
|
|
(this.companyPosition.isITJob() && entryPosType.isITJob()) ||
|
|
|
|
(this.companyPosition.isSecurityEngineerJob() && entryPosType.isSecurityEngineerJob()) ||
|
|
|
|
(this.companyPosition.isNetworkEngineerJob() && entryPosType.isNetworkEngineerJob()) ||
|
|
|
|
(this.companyPosition.isSecurityJob() && entryPosType.isSecurityJob()) ||
|
|
|
|
(this.companyPosition.isAgentJob() && entryPosTypeisAgentJob()) ||
|
|
|
|
(this.companyPosition.isSoftwareConsultantJob() && entryPosType.isSoftwareConsultantJob()) ||
|
|
|
|
(this.companyPosition.isBusinessConsultantJob() && entryPosType.isBusinessConsultantJob()) ||
|
|
|
|
(this.companyPosition.isPartTimeJob() && entryPosType.isPartTimeJob())) {
|
|
|
|
return getNextCompanyPosition(this.companyPosition);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return entryPosType;
|
|
|
|
}
|
|
|
|
|
2017-02-03 05:02:27 +01:00
|
|
|
PlayerObject.prototype.applyForSoftwareJob = function() {
|
2017-02-03 23:05:59 +01:00
|
|
|
this.applyForJob(CompanyPositions.SoftwareIntern);
|
2017-02-03 00:33:47 +01:00
|
|
|
}
|
|
|
|
|
2017-05-10 19:42:46 +02:00
|
|
|
PlayerObject.prototype.applyForSoftwareConsultantJob = function() {
|
|
|
|
this.applyForJob(CompanyPositions.SoftwareConsultant);
|
|
|
|
}
|
|
|
|
|
2017-02-03 00:33:47 +01:00
|
|
|
PlayerObject.prototype.applyForItJob = function() {
|
2017-02-03 23:05:59 +01:00
|
|
|
this.applyForJob(CompanyPositions.ITIntern);
|
2017-02-03 00:33:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
PlayerObject.prototype.applyForSecurityEngineerJob = function() {
|
2017-02-03 05:02:27 +01:00
|
|
|
var company = Companies[this.location]; //Company being applied to
|
|
|
|
if (this.isQualified(company, CompanyPositions.SecurityEngineer)) {
|
|
|
|
this.companyName = company.companyName;
|
|
|
|
this.companyPosition = CompanyPositions.SecurityEngineer;
|
2017-07-03 21:42:11 +02:00
|
|
|
dialogBoxCreate("Congratulations, you were offered a position at " + this.companyName + " as a Security Engineer!");
|
2017-02-08 05:48:50 +01:00
|
|
|
Engine.loadLocationContent();
|
2017-02-03 05:02:27 +01:00
|
|
|
} else {
|
2017-02-03 23:05:59 +01:00
|
|
|
dialogBoxCreate("Unforunately, you do not qualify for this position");
|
2017-02-03 05:02:27 +01:00
|
|
|
}
|
2017-02-03 00:33:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
PlayerObject.prototype.applyForNetworkEngineerJob = function() {
|
2017-02-03 05:02:27 +01:00
|
|
|
var company = Companies[this.location]; //Company being applied to
|
|
|
|
if (this.isQualified(company, CompanyPositions.NetworkEngineer)) {
|
2017-02-03 23:05:59 +01:00
|
|
|
this.applyForJob(CompanyPositions.NetworkEngineer);
|
2017-02-03 05:02:27 +01:00
|
|
|
} else {
|
2017-02-03 23:05:59 +01:00
|
|
|
dialogBoxCreate("Unforunately, you do not qualify for this position");
|
2017-02-03 05:02:27 +01:00
|
|
|
}
|
2017-02-03 00:33:47 +01:00
|
|
|
}
|
|
|
|
|
2017-02-03 05:02:27 +01:00
|
|
|
PlayerObject.prototype.applyForBusinessJob = function() {
|
2017-02-03 23:05:59 +01:00
|
|
|
this.applyForJob(CompanyPositions.BusinessIntern);
|
2017-02-03 00:33:47 +01:00
|
|
|
}
|
|
|
|
|
2017-05-10 19:42:46 +02:00
|
|
|
PlayerObject.prototype.applyForBusinessConsultantJob = function() {
|
|
|
|
this.applyForJob(CompanyPositions.BusinessConsultant);
|
|
|
|
}
|
|
|
|
|
2017-02-03 00:33:47 +01:00
|
|
|
PlayerObject.prototype.applyForSecurityJob = function() {
|
2017-02-03 05:02:27 +01:00
|
|
|
//TODO If case for POlice departments
|
2017-02-03 23:05:59 +01:00
|
|
|
this.applyForJob(CompanyPositions.SecurityGuard);
|
2017-02-03 00:33:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
PlayerObject.prototype.applyForAgentJob = function() {
|
2017-02-03 05:02:27 +01:00
|
|
|
var company = Companies[this.location]; //Company being applied to
|
|
|
|
if (this.isQualified(company, CompanyPositions.FieldAgent)) {
|
2017-02-03 23:05:59 +01:00
|
|
|
this.applyForJob(CompanyPositions.FieldAgent);
|
2017-02-03 05:02:27 +01:00
|
|
|
} else {
|
2017-02-03 23:05:59 +01:00
|
|
|
dialogBoxCreate("Unforunately, you do not qualify for this position");
|
2017-02-03 05:02:27 +01:00
|
|
|
}
|
2017-02-03 00:33:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
PlayerObject.prototype.applyForEmployeeJob = function() {
|
2017-02-03 05:02:27 +01:00
|
|
|
var company = Companies[this.location]; //Company being applied to
|
2017-02-03 23:05:59 +01:00
|
|
|
if (this.isQualified(company, CompanyPositions.Employee)) {
|
2017-02-03 05:02:27 +01:00
|
|
|
this.companyName = company.companyName;
|
|
|
|
this.companyPosition = CompanyPositions.Employee;
|
2017-05-10 19:42:46 +02:00
|
|
|
dialogBoxCreate("Congratulations, you are now employed at " + this.companyName);
|
|
|
|
Engine.loadLocationContent();
|
|
|
|
} else {
|
|
|
|
dialogBoxCreate("Unforunately, you do not qualify for this position");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PlayerObject.prototype.applyForPartTimeEmployeeJob = function() {
|
|
|
|
var company = Companies[this.location]; //Company being applied to
|
|
|
|
if (this.isQualified(company, CompanyPositions.PartTimeEmployee)) {
|
|
|
|
this.companyName = company.companyName;
|
|
|
|
this.companyPosition = CompanyPositions.PartTimeEmployee;
|
|
|
|
dialogBoxCreate("Congratulations, you are now employed part-time at " + this.companyName);
|
2017-02-08 05:48:50 +01:00
|
|
|
Engine.loadLocationContent();
|
2017-02-03 05:02:27 +01:00
|
|
|
} else {
|
2017-02-03 23:05:59 +01:00
|
|
|
dialogBoxCreate("Unforunately, you do not qualify for this position");
|
2017-02-03 05:02:27 +01:00
|
|
|
}
|
2017-02-03 00:33:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
PlayerObject.prototype.applyForWaiterJob = function() {
|
2017-02-03 05:02:27 +01:00
|
|
|
var company = Companies[this.location]; //Company being applied to
|
2017-02-03 23:05:59 +01:00
|
|
|
if (this.isQualified(company, CompanyPositions.Waiter)) {
|
2017-02-03 05:02:27 +01:00
|
|
|
this.companyName = company.companyName;
|
|
|
|
this.companyPosition = CompanyPositions.Waiter;
|
2017-05-10 19:42:46 +02:00
|
|
|
dialogBoxCreate("Congratulations, you are now employed as a waiter at " + this.companyName);
|
|
|
|
Engine.loadLocationContent();
|
|
|
|
} else {
|
|
|
|
dialogBoxCreate("Unforunately, you do not qualify for this position");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PlayerObject.prototype.applyForPartTimeWaiterJob = function() {
|
|
|
|
var company = Companies[this.location]; //Company being applied to
|
|
|
|
if (this.isQualified(company, CompanyPositions.PartTimeWaiter)) {
|
|
|
|
this.companyName = company.companyName;
|
|
|
|
this.companyPosition = CompanyPositions.PartTimeWaiter;
|
|
|
|
dialogBoxCreate("Congratulations, you are now employed as a part-time waiter at " + this.companyName);
|
2017-02-08 05:48:50 +01:00
|
|
|
Engine.loadLocationContent();
|
2017-02-03 05:02:27 +01:00
|
|
|
} else {
|
2017-02-03 23:05:59 +01:00
|
|
|
dialogBoxCreate("Unforunately, you do not qualify for this position");
|
2017-02-03 05:02:27 +01:00
|
|
|
}
|
2017-02-03 00:33:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//Checks if the Player is qualified for a certain position
|
|
|
|
PlayerObject.prototype.isQualified = function(company, position) {
|
|
|
|
var offset = company.jobStatReqOffset;
|
2017-04-24 03:43:41 +02:00
|
|
|
var reqHacking = position.requiredHacking > 0 ? position.requiredHacking+offset : 0;
|
|
|
|
var reqStrength = position.requiredStrength > 0 ? position.requiredStrength+offset : 0;
|
|
|
|
var reqDefense = position.requiredDefense > 0 ? position.requiredDefense+offset : 0;
|
|
|
|
var reqDexterity = position.requiredDexterity > 0 ? position.requiredDexterity+offset : 0;
|
|
|
|
var reqAgility = position.requiredDexterity > 0 ? position.requiredDexterity+offset : 0;
|
|
|
|
var reqCharisma = position.requiredCharisma > 0 ? position.requiredCharisma+offset : 0;
|
2017-07-28 16:19:28 +02:00
|
|
|
|
2017-04-23 04:32:51 +02:00
|
|
|
if (this.hacking_skill >= reqHacking &&
|
|
|
|
this.strength >= reqStrength &&
|
2017-07-28 16:19:28 +02:00
|
|
|
this.defense >= reqDefense &&
|
2017-04-23 04:32:51 +02:00
|
|
|
this.dexterity >= reqDexterity &&
|
|
|
|
this.agility >= reqAgility &&
|
|
|
|
this.charisma >= reqCharisma &&
|
2017-02-03 00:33:47 +01:00
|
|
|
company.playerReputation >= position.requiredReputation) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2017-07-28 16:19:28 +02:00
|
|
|
}
|