More work on CompanyJobApplication.js, unfinished and untested. need to add popups saying if u got the job or not

This commit is contained in:
Daniel Xie 2017-02-02 22:02:27 -06:00
parent 7382454e83
commit afda3338bd
3 changed files with 93 additions and 27 deletions

@ -189,6 +189,16 @@ CompanyPosition.prototype.isAgentJob = function() {
return false;
}
CompanyPosition.prototype.toJSON = function() {
return Generic_toJSON("CompanyPosition", this);
}
CompanyPosition.fromJSON = function(value) {
return Generic_fromJSON(CompanyPosition, value.data);
}
Reviver.constructors.CompanyPosition = CompanyPosition;
CompanyPositions = {
//Constructor: CompanyPosition(name, reqHack, reqStr, reqDef, reqDex, reqAgi, reqCha, reqRep, salary)

@ -1,18 +1,24 @@
/* Functions that handle applying for different jobs/positions in a Company */
PlayerObject.prototype.applyForSoftwareJob = function() {
//Determines the job that the Player should get (if any) at the current
//company
PlayerObject.prototype.applyForJob = function(entryPosType) {
var currCompany = Companies[this.companyName];
var currPositionName = //TODO
var currPositionName = this.companyPosition.positionName;
var company = Companies[this.location]; //Company being applied to
var pos = CompanyPositions.SoftwareIntern;
var pos = entryPosType;
//var pos = CompanyPositions.SoftwareIntern;
while (true) {
if (Engine.Debug) {console.log("Determining qualification for next COmpany Position");}
if (Engine.Debug) {console.log("Determining qualification for next Company Position");}
var newPos = getNextCompanyPosition(pos);
//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 promote");
console.log("Player already at highest position, cannot go any higher");
}
break;
}
@ -22,47 +28,97 @@ PlayerObject.prototype.applyForSoftwareJob = function() {
break;
}
pos = newPos;
} else {
//TODO Post something about having no position to be promoted to
return;
}
}
//Check if the determined job is the same as the player's current job
if (currCompany.companyName == company.companyName &&
pos.positionName == )
pos.positionName == currPositionName) {
//TODO Post something about not being able to get a promotion
return; //Same job, do nothing
}
//Lose reputation from old company b/c Player is leaving
If Player is not currently in this position, give it to him
//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);
}
PlayerObject.prototype.applyForItJob = function() {
applyForJob(CompanyPositions.ITIntern);
}
PlayerObject.prototype.applyForSecurityEngineerJob = function() {
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
}
}
PlayerObject.prototype.applyForNetworkEngineerJob = function() {
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
}
}
PlayerObject.prototype.applyForSusinessJob = function() {
PlayerObject.prototype.applyForBusinessJob = function() {
applyForJob(CompanyPositions.BusinessIntern);
}
PlayerObject.prototype.applyForSecurityJob = function() {
//TODO If case for POlice departments
applyForJob(CompanyPositions.SecurityGuard);
}
PlayerObject.prototype.applyForAgentJob = function() {
var company = Companies[this.location]; //Company being applied to
if (this.isQualified(company, CompanyPositions.FieldAgent)) {
applyForJob(CompanyPositions.FieldAgent);
} else {
//TODO Post not qualified
}
}
PlayerObject.prototype.applyForEmployeeJob = function() {
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
}
}
PlayerObject.prototype.applyForWaiterJob = function() {
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
}
}
//Checks if the Player is qualified for a certain position

@ -65,7 +65,7 @@ function PlayerObject() {
//Company Information
this.companyName = "";
this.companyJob = ""; //Name of current Company Position
this.companyPosition = "";
//Servers
this.currentServer = ""; //IP address of Server currently being accessed through terminal