diff --git a/src/Company.js b/src/Company.js index 73d222680..2cba7f0dc 100644 --- a/src/Company.js +++ b/src/Company.js @@ -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) diff --git a/src/CompanyJobApplication.js b/src/CompanyJobApplication.js index e6413a84e..a523a68ab 100644 --- a/src/CompanyJobApplication.js +++ b/src/CompanyJobApplication.js @@ -1,68 +1,124 @@ /* 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); - if (newPos == null) { - if (Engine.Debug) { - console.log("Player already at highest position, cannot promote"); + + //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; } - break; + + 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; } - if (!this.isQualified(company, newPos)) { - //If player not qualified for next job, break loop so player will be given current job - break; - } - pos = newPos; } //Check if the determined job is the same as the player's current job if (currCompany.companyName == company.companyName && - pos.positionName == ) - - //Lose reputation from old company b/c Player is leaving - If Player is not currently in this position, give it to him + pos.positionName == currPositionName) { + //TODO Post something about not being able to get a promotion + return; //Same job, do nothing + } + //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 diff --git a/src/Player.js b/src/Player.js index 09cf96474..203f78a1c 100644 --- a/src/Player.js +++ b/src/Player.js @@ -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