From ca10704ce09bb7bf279bd16c9e079985b56fa48e Mon Sep 17 00:00:00 2001 From: Daniel Xie Date: Tue, 7 Feb 2017 22:48:50 -0600 Subject: [PATCH] Got work functionality implemented --- src/CompanyJobApplication.js | 4 +++ src/Player.js | 48 +++++++++++++++++++++--------------- src/engine.js | 4 +-- 3 files changed, 34 insertions(+), 22 deletions(-) diff --git a/src/CompanyJobApplication.js b/src/CompanyJobApplication.js index 37fdf2941..215b91546 100644 --- a/src/CompanyJobApplication.js +++ b/src/CompanyJobApplication.js @@ -70,6 +70,7 @@ PlayerObject.prototype.applyForJob = function(entryPosType) { this.companyPosition = pos; dialogBoxCreate("Congratulations! You were offered a new job at ", this.companyName, " as a " + pos.positionName); + Engine.loadLocationContent(); } PlayerObject.prototype.applyForSoftwareJob = function() { @@ -86,6 +87,7 @@ PlayerObject.prototype.applyForSecurityEngineerJob = function() { this.companyName = company.companyName; this.companyPosition = CompanyPositions.SecurityEngineer; dialogBoxCreate("Congratulations, you were offered a position at ", this.companyName, " as a Security Engineer!" , ""); + Engine.loadLocationContent(); } else { dialogBoxCreate("Unforunately, you do not qualify for this position"); } @@ -124,6 +126,7 @@ PlayerObject.prototype.applyForEmployeeJob = function() { this.companyName = company.companyName; this.companyPosition = CompanyPositions.Employee; dialogBoxCreate("Congratulations, you are now employed at ", this.companyName, "", ""); + Engine.loadLocationContent(); } else { dialogBoxCreate("Unforunately, you do not qualify for this position"); } @@ -135,6 +138,7 @@ PlayerObject.prototype.applyForWaiterJob = function() { this.companyName = company.companyName; this.companyPosition = CompanyPositions.Waiter; dialogBoxCreate("Congratulations, you are now employed as a waiter at ", this.companyName, "", ""); + Engine.loadLocationContent(); } else { dialogBoxCreate("Unforunately, you do not qualify for this position"); } diff --git a/src/Player.js b/src/Player.js index 2246c4af1..7a29821ca 100644 --- a/src/Player.js +++ b/src/Player.js @@ -234,13 +234,13 @@ PlayerObject.prototype.finishWork = function(cancelled) { txt = "You worked a short shift of " + convertTimeMsToTimeElapsedString(this.timeWorked) + "

" + "Since you cancelled your work early, you only gained half of the experience, money, and reputation you earned.

" + "You earned a total of:
" + - "$" + (this.workMoneyGained / cancMult) + "
" + - (this.workRepGained / cancMult) + " reputation for the company
" + - (this.workHackExpGained / cancMult) + " hacking exp
" + - (this.workStrExpGained / cancMult) + " strength exp
" + - (this.workDefExpGained / cancMult) + " defense exp
" + - (this.workDexExpGained / cancMult) + " dexterity exp
" + - (this.workAgiExpGained / cancMult) + " agility exp
"; + "$" + (this.workMoneyGained / cancMult).toFixed(2) + "
" + + (this.workRepGained / cancMult).toFixed(3) + " reputation for the company
" + + (this.workHackExpGained / cancMult).toFixed(3) + " hacking exp
" + + (this.workStrExpGained / cancMult).toFixed(3) + " strength exp
" + + (this.workDefExpGained / cancMult).toFixed(3) + " defense exp
" + + (this.workDexExpGained / cancMult).toFixed(3) + " dexterity exp
" + + (this.workAgiExpGained / cancMult).toFixed(3) + " agility exp
"; } else { txt = "You worked a full shirt of 8 hours!

" + @@ -254,6 +254,11 @@ PlayerObject.prototype.finishWork = function(cancelled) { (this.workAgiExpGained / cancMult) + " agility exp
"; } dialogBoxCreate(txt); + + var mainMenu = document.getElementById("mainmenu-container"); + mainMenu.style.visibility = "visible"; + + Engine.loadTerminalContent(); } PlayerObject.prototype.startWork = function() { @@ -279,7 +284,7 @@ PlayerObject.prototype.startWork = function() { var cancelButton = document.getElementById("work-in-progress-cancel-button"); cancelButton.addEventListener("click", function() { - this.finishWork(true); + Player.finishWork(true); }); //Display Work In Progress Screen @@ -309,15 +314,15 @@ PlayerObject.prototype.work = function(numCycles) { " at " + Player.companyName + "

" + "You have been working for " + convertTimeMsToTimeElapsedString(this.timeWorked) + "

" + "You have earned:

" + - "$" + this.workMoneyGained + " (" + this.workMoneyGainRate * cyclesPerSec + " / sec)

" + - this.workRepGained + " (" + this.workRepGainRate * cyclesPerSec + " / sec) reputation for this company
" + - this.workHackExpGained + " (" + this.workHackExpGainRate * cyclesPerSec + " / sec) hacking exp
" + - this.workStrExpGained + " (" + this.workStrExpGainRate * cyclesPerSec + " / sec) strength exp
" + - this.workDefExpGained + " (" + this.workDefExpGainRate * cyclesPerSec + " / sec) defense exp
" + - this.workDexExpGained + " (" + this.workDexExpGainRate * cyclesPerSec + " / sec) dexterity exp
" + - this.workAgiExpGained + " (" + this.workAgiExpGainrate * cyclesPerSec + " / sec) agility exp
" + + "$" + this.workMoneyGained + " (" + (this.workMoneyGainRate * cyclesPerSec).toFixed(2) + " / sec)

" + + this.workRepGained.toFixed(3) + " (" + (this.workRepGainRate * cyclesPerSec).toFixed(3) + " / sec) reputation for this company
" + + this.workHackExpGained.toFixed(3) + " (" + (this.workHackExpGainRate * cyclesPerSec).toFixed(3) + " / sec) hacking exp
" + + this.workStrExpGained.toFixed(3) + " (" + (this.workStrExpGainRate * cyclesPerSec).toFixed(3) + " / sec) strength exp
" + + this.workDefExpGained.toFixed(3) + " (" + (this.workDefExpGainRate * cyclesPerSec).toFixed(3) + " / sec) defense exp
" + + this.workDexExpGained.toFixed(3) + " (" + (this.workDexExpGainRate * cyclesPerSec).toFixed(3) + " / sec) dexterity exp
" + + this.workAgiExpGained.toFixed(3) + " (" + (this.workAgiExpGainRate * cyclesPerSec).toFixed(3) + " / sec) agility exp

" + - "You will automatically finish after working for 8 hours. You can cancel earlier if you wish,

" + + "You will automatically finish after working for 8 hours. You can cancel earlier if you wish,
" + "but you will only gain half of the experience, money, and reputation you've earned so far." } @@ -331,31 +336,34 @@ PlayerObject.prototype.getWorkMoneyGain = function() { //Hack exp gained per game cycle PlayerObject.prototype.getWorkHackExpGain = function() { var company = Companies[this.companyName]; + if (Engine.Debug) { + console.log(company.companyName); + } return this.companyPosition.hackingExpGain * company.expMultiplier * this.hacking_exp_mult; } //Str exp gained per game cycle PlayerObject.prototype.getWorkStrExpGain = function() { var company = Companies[this.companyName]; - return this.companyPosition.strengthExpGain * company.expMultiplier * this.str_exp_mult; + return this.companyPosition.strengthExpGain * company.expMultiplier * this.strength_exp_mult; } //Def exp gained per game cycle PlayerObject.prototype.getWorkDefExpGain = function() { var company = Companies[this.companyName]; - return this.companyPosition.defenseExpGain * company.expMultiplier * this.def_exp_mult; + return this.companyPosition.defenseExpGain * company.expMultiplier * this.defense_exp_mult; } //Dex exp gained per game cycle PlayerObject.prototype.getWorkDexExpGain = function() { var company = Companies[this.companyName]; - return this.companyPosition.dexterityExpGain * company.expMultiplier * this.dex_exp_mult; + return this.companyPosition.dexterityExpGain * company.expMultiplier * this.dexterity_exp_mult; } //Agi exp gained per game cycle PlayerObject.prototype.getWorkAgiExpGain = function() { var company = Companies[this.companyName]; - return this.companyPosition.agilityExpGain * company.expMultiplier * this.agi_exp_mult; + return this.companyPosition.agilityExpGain * company.expMultiplier * this.agility_exp_mult; } //Reputation gained per game cycle diff --git a/src/engine.js b/src/engine.js index 70062d2f0..dcf44a09c 100644 --- a/src/engine.js +++ b/src/engine.js @@ -425,7 +425,7 @@ var Engine = { }, updateGame: function(numCycles = 1) { - //Manual hack + //Start Manual hack if (Player.startAction == true) { Engine._totalActionTime = Player.actionTime; Engine._actionTimeLeft = Player.actionTime; @@ -437,7 +437,7 @@ var Engine = { } if (Player.isWorking) { - //TODO + Player.work(numCycles); } //Counters