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
|
|
|
|
PlayerObject.prototype.applyForJob = function(entryPosType) {
|
2017-02-03 00:33:47 +01:00
|
|
|
var currCompany = Companies[this.companyName];
|
2017-02-03 05:02:27 +01:00
|
|
|
var currPositionName = this.companyPosition.positionName;
|
2017-02-03 00:33:47 +01:00
|
|
|
var company = Companies[this.location]; //Company being applied to
|
|
|
|
|
2017-02-03 05:02:27 +01:00
|
|
|
var pos = entryPosType;
|
|
|
|
//var pos = CompanyPositions.SoftwareIntern;
|
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-02-03 05:02:27 +01:00
|
|
|
|
|
|
|
//Check if this company has this position
|
|
|
|
if (company.hasPosition(newPos)) {
|
|
|
|
if (newPos == null) {
|
|
|
|
if (Engine.Debug) {
|
|
|
|
console.log("Player already at highest position, cannot go any higher");
|
|
|
|
}
|
|
|
|
break;
|
2017-02-03 00:33:47 +01:00
|
|
|
}
|
2017-02-03 05:02:27 +01:00
|
|
|
|
|
|
|
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 {
|
|
|
|
//TODO Post something about having no position to be promoted to
|
|
|
|
return;
|
2017-02-03 00:33:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//Check if the determined job is the same as the player's current job
|
|
|
|
if (currCompany.companyName == company.companyName &&
|
2017-02-03 05:02:27 +01:00
|
|
|
pos.positionName == currPositionName) {
|
|
|
|
//TODO Post something about not being able to get a promotion
|
|
|
|
return; //Same job, do nothing
|
|
|
|
}
|
2017-02-03 00:33:47 +01:00
|
|
|
|
2017-02-03 05:02:27 +01:00
|
|
|
//Lose reputation from a Company if you are leaving it for another job
|
|
|
|
if (currCompany.companyName != company.companyName) {
|
|
|
|
company.playerReputation -= 1000;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.companyName = company.companyName;
|
|
|
|
this.companyPosition = pos;
|
|
|
|
|
|
|
|
//TODO Post something about being promoted/getting new job
|
|
|
|
}
|
|
|
|
|
|
|
|
PlayerObject.prototype.applyForSoftwareJob = function() {
|
|
|
|
applyForJob(CompanyPositions.SoftwareIntern);
|
2017-02-03 00:33:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
PlayerObject.prototype.applyForItJob = function() {
|
2017-02-03 05:02:27 +01:00
|
|
|
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;
|
|
|
|
//TODO Post that u got job
|
|
|
|
} else {
|
|
|
|
//TODO Post not qualified
|
|
|
|
}
|
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)) {
|
|
|
|
applyForJob(CompanyPositions.NetworkEngineer);
|
|
|
|
} else {
|
|
|
|
//TODO Say you aren't qualified
|
|
|
|
}
|
2017-02-03 00:33:47 +01:00
|
|
|
}
|
|
|
|
|
2017-02-03 05:02:27 +01:00
|
|
|
PlayerObject.prototype.applyForBusinessJob = function() {
|
|
|
|
applyForJob(CompanyPositions.BusinessIntern);
|
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
|
|
|
|
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)) {
|
|
|
|
applyForJob(CompanyPositions.FieldAgent);
|
|
|
|
} else {
|
|
|
|
//TODO Post not qualified
|
|
|
|
}
|
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
|
|
|
|
if (this.isQualified(company, CompanyPositions.Employee) {
|
|
|
|
this.companyName = company.companyName;
|
|
|
|
this.companyPosition = CompanyPositions.Employee;
|
|
|
|
//TODO Post that u got the job
|
|
|
|
} else {
|
|
|
|
//TODO Post not qualified
|
|
|
|
}
|
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
|
|
|
|
if (this.isQualified(company, CompanyPositions.Waiter) {
|
|
|
|
this.companyName = company.companyName;
|
|
|
|
this.companyPosition = CompanyPositions.Waiter;
|
|
|
|
//TODO Post that u got job
|
|
|
|
} else {
|
|
|
|
//TODO Post not qualified
|
|
|
|
}
|
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;
|
|
|
|
if (this.hacking_skill >= position.requiredHacking+offset &&
|
|
|
|
this.strength >= position.requiredStrength+offset &&
|
|
|
|
this.defense >= position.requiredDefense+offset &&
|
|
|
|
this.dexterity >= position.requiredDexterity+offset &&
|
|
|
|
this.agility >= position.requiredAgility+offset &&
|
|
|
|
this.charisma >= position.requiredCharisma+offset &&
|
|
|
|
company.playerReputation >= position.requiredReputation) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|