From fc2dc82f1af4797f860ddabe17bdef4f23f681ae Mon Sep 17 00:00:00 2001 From: Daniel Xie Date: Fri, 3 Feb 2017 16:05:59 -0600 Subject: [PATCH] Implemented Applying to jobs. Working on Purchasing Servers --- css/menupages.css | 16 --- css/styles.css | 84 +++++++++++++ index.html | 128 +++++++++++-------- src/CompanyJobApplication.js | 89 ++++++++------ src/Location.js | 231 +++++++++++++++++++++++++++++++---- src/Player.js | 4 +- src/PurchaseServers.js | 14 +++ src/Terminal.js | 1 + src/engine.js | 9 +- utils/DialogBox.js | 45 +++++++ utils/PurchaseServerBox.js | 42 +++++++ 11 files changed, 537 insertions(+), 126 deletions(-) create mode 100644 src/PurchaseServers.js create mode 100644 utils/DialogBox.js create mode 100644 utils/PurchaseServerBox.js diff --git a/css/menupages.css b/css/menupages.css index dc1236e30..bc82f0dba 100644 --- a/css/menupages.css +++ b/css/menupages.css @@ -47,7 +47,6 @@ box-shadow: none; } - #script-editor-status { float: left; color: #ffffff; @@ -100,21 +99,6 @@ width: 99%; } -/* Purchase servers */ -#purchase-servers-container { - position: fixed; - padding-top: 10px; - padding-left: 10px; - height: 100%; - margin-left: 10%; - width: 99%; -} - -#purchase-servers-input, #purchase-servers-gb-text { - display:inline-block; - color: #66ff33; -} - /* Create program */ #create-program-container { position: fixed; diff --git a/css/styles.css b/css/styles.css index 963807a48..3fc576546 100644 --- a/css/styles.css +++ b/css/styles.css @@ -67,3 +67,87 @@ h1 { border-bottom: 1px solid #333333; border-left: 1px solid #333333; } + +/* Pop-up Dialog Box */ +#dialog-box-container { + display: none; /* Hidden by default */ + position: fixed; /* Stay in place */ + z-index: 1; /* Sit on top */ + left: 0; + top: 0; + width: 100%; /* Full width */ + height: 100%; /* Full height */ + overflow: auto; /* Enable scroll if needed */ + background-color: #333; /* Fallback color */ + background-color: rgba(0,0,0,0.4); /* Black w/ opacity */ +} + +#dialog-box-content { + background-color: #555; + margin: 15% auto; /* 15% from the top and centered */ + padding: 1px; + border: 1px solid #555; + width: 80%; /* Could be more or less, depending on screen size */ +} + +.dialog-box-text { + color: #66ff33; +} + +#dialog-box-close-button { + color: #aaa; + float: right; + font-size: 28px; + font-weight: bold; +} + +#dialog-box-close-button:hover, +#dialog-box-close-button:focus { + color: black; + text-decoration: none; + cursor: pointer; +} + +/* Pop-up Yes/no box */ +#yes-no-box-container { + display: none; /* Hidden by default */ + position: fixed; /* Stay in place */ + z-index: 1; /* Sit on top */ + left: 0; + top: 0; + width: 100%; /* Full width */ + height: 100%; /* Full height */ + overflow: auto; /* Enable scroll if needed */ + background-color: #333; /* Fallback color */ + background-color: rgba(0,0,0,0.4); /* Black w/ opacity */ +} + +#yes-no-box-content { + background-color: #555; + margin: 15% auto; /* 15% from the top and centered */ + padding: 1px; + border: 1px solid #555; + width: 80%; /* Could be more or less, depending on screen size */ +} + +#yes-no-box-yes, #yes-no-box-no { + color: #aaa; + float: right; + font-size: 28px; + font-weight: bold; +} + +#yes-no-box-yes:hover, +#yes-no-box-yes:focus { + color: black; + text-decoration: none; + cursor: pointer; +} + + +#yes-no-box-no:hover, +#yes-no-box-no:focus { + color: black; + text-decoration: none; + cursor: pointer; +} \ No newline at end of file diff --git a/index.html b/index.html index 5cc0110b1..106b0ed8c 100644 --- a/index.html +++ b/index.html @@ -16,6 +16,8 @@ + + @@ -33,7 +35,9 @@ + + @@ -168,124 +172,124 @@ @@ -365,23 +369,23 @@ Work - Train Strength - Train Defense - Train Dexterity - Train Agility + Train Strength + Train Defense + Train Dexterity + Train Agility - Purchase 1GB Server - Purchase 2GB Server - Purchase 4GB Server - Purchase 8GB Server - Purchase 16GB Server - Purchase 32GB Server - Purchase 64GB Server - Purchase 128GB Server - Purchase 256GB Server - Purchase 512GB Server - Purchase 1TB Server + Purchase 1GB Server - $100,000 + Purchase 2GB Server - $250,000 + Purchase 4GB Server - $600,000 + Purchase 8GB Server - $1,500,000 + Purchase 16GB Server - $4,000,000 + Purchase 32GB Server - $9,000,000 + Purchase 64GB Server - $20,000,000 + Purchase 128GB Server - $45,000,000 + Purchase 256GB Server - $100,000,000 + Purchase 512GB Server - $250,000,000 + Purchase 1TB Server - $600,000,000 Travel to Aevum @@ -392,5 +396,27 @@ Travel to Volhaven + +
+
+ × +

+

+

+

+
+
+ + +
+
+

+

Enter new server hostname:

+ + Purchase + Cancel +
+
+ \ No newline at end of file diff --git a/src/CompanyJobApplication.js b/src/CompanyJobApplication.js index a523a68ab..37fdf2941 100644 --- a/src/CompanyJobApplication.js +++ b/src/CompanyJobApplication.js @@ -3,62 +3,81 @@ //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 = this.companyPosition.positionName; + if (Engine.Debug) { + console.log("Player.applyForJob() called"); + } + + var currCompany = ""; + if (this.companyName != "") { + currCompany = Companies[this.companyName]; + } + var currPositionName = ""; + if (this.companyPosition != "") { + currPositionName = this.companyPosition.positionName; + } var company = Companies[this.location]; //Company being applied to var pos = entryPosType; - //var pos = CompanyPositions.SoftwareIntern; + + if (!this.isQualified(company, pos)) { + dialogBoxCreate("You are not qualified for this position"); + return; + } while (true) { 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 go any higher"); + } + break; + } + //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; - } - 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; + break; } } //Check if the determined job is the same as the player's current job - if (currCompany.companyName == company.companyName && - pos.positionName == currPositionName) { - //TODO Post something about not being able to get a promotion - return; //Same job, do nothing + if (currCompany != "") { + if (currCompany.companyName == company.companyName && + pos.positionName == currPositionName) { + dialogBoxCreate("Unfortunately, you do not qualify for 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; + if (currCompany != "") { + if (currCompany.companyName != company.companyName) { + company.playerReputation -= 1000; + } } + this.companyName = company.companyName; this.companyPosition = pos; - //TODO Post something about being promoted/getting new job + dialogBoxCreate("Congratulations! You were offered a new job at ", this.companyName, " as a " + pos.positionName); } PlayerObject.prototype.applyForSoftwareJob = function() { - applyForJob(CompanyPositions.SoftwareIntern); + this.applyForJob(CompanyPositions.SoftwareIntern); } PlayerObject.prototype.applyForItJob = function() { - applyForJob(CompanyPositions.ITIntern); + this.applyForJob(CompanyPositions.ITIntern); } PlayerObject.prototype.applyForSecurityEngineerJob = function() { @@ -66,58 +85,58 @@ PlayerObject.prototype.applyForSecurityEngineerJob = function() { if (this.isQualified(company, CompanyPositions.SecurityEngineer)) { this.companyName = company.companyName; this.companyPosition = CompanyPositions.SecurityEngineer; - //TODO Post that u got job + dialogBoxCreate("Congratulations, you were offered a position at ", this.companyName, " as a Security Engineer!" , ""); } else { - //TODO Post not qualified + dialogBoxCreate("Unforunately, you do not qualify for this position"); } } PlayerObject.prototype.applyForNetworkEngineerJob = function() { var company = Companies[this.location]; //Company being applied to if (this.isQualified(company, CompanyPositions.NetworkEngineer)) { - applyForJob(CompanyPositions.NetworkEngineer); + this.applyForJob(CompanyPositions.NetworkEngineer); } else { - //TODO Say you aren't qualified + dialogBoxCreate("Unforunately, you do not qualify for this position"); } } PlayerObject.prototype.applyForBusinessJob = function() { - applyForJob(CompanyPositions.BusinessIntern); + this.applyForJob(CompanyPositions.BusinessIntern); } PlayerObject.prototype.applyForSecurityJob = function() { //TODO If case for POlice departments - applyForJob(CompanyPositions.SecurityGuard); + this.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); + this.applyForJob(CompanyPositions.FieldAgent); } else { - //TODO Post not qualified + dialogBoxCreate("Unforunately, you do not qualify for this position"); } } PlayerObject.prototype.applyForEmployeeJob = function() { var company = Companies[this.location]; //Company being applied to - if (this.isQualified(company, CompanyPositions.Employee) { + if (this.isQualified(company, CompanyPositions.Employee)) { this.companyName = company.companyName; this.companyPosition = CompanyPositions.Employee; - //TODO Post that u got the job + dialogBoxCreate("Congratulations, you are now employed at ", this.companyName, "", ""); } else { - //TODO Post not qualified + dialogBoxCreate("Unforunately, you do not qualify for this position"); } } PlayerObject.prototype.applyForWaiterJob = function() { var company = Companies[this.location]; //Company being applied to - if (this.isQualified(company, CompanyPositions.Waiter) { + if (this.isQualified(company, CompanyPositions.Waiter)) { this.companyName = company.companyName; this.companyPosition = CompanyPositions.Waiter; - //TODO Post that u got job + dialogBoxCreate("Congratulations, you are now employed as a waiter at ", this.companyName, "", ""); } else { - //TODO Post not qualified + dialogBoxCreate("Unforunately, you do not qualify for this position"); } } diff --git a/src/Location.js b/src/Location.js index b3a9e22aa..81832f0ae 100644 --- a/src/Location.js +++ b/src/Location.js @@ -1,5 +1,6 @@ /* Display Location Content when visiting somewhere in the World*/ + Locations = { //Cities Aevum: "Aevum", @@ -76,21 +77,13 @@ displayLocationContent = function() { if (Engine.debug) { console.log("displayLocationContent() called with location " + Player.location) } - - var loc = Player.location; - - var returnToWorld = document.getElementById("location-return-to-world-button"); - returnToWorld.addEventListener("click", function() { - Engine.loadWorldContent(); - }); - - var locationName = document.getElementById("location-name"); - locationName.innerHTML = loc; - locationName.style.display = "block"; - - var locationInfo = document.getElementById("location-info"); - locationInfo.style.display = "block"; + var returnToWorld = document.getElementById("location-return-to-world-button"); + + var locationName = document.getElementById("location-name"); + + var locationInfo = document.getElementById("location-info"); + var softwareJob = document.getElementById("location-software-job"); var itJob = document.getElementById("location-it-job"); var securityEngineerJob = document.getElementById("location-security-engineer-job"); @@ -100,9 +93,9 @@ displayLocationContent = function() { var agentJob = document.getElementById("location-agent-job"); var employeeJob = document.getElementById("location-employee-job"); var waiterJob = document.getElementById("location-waiter-job"); - + var work = document.getElementById("location-work"); - + var gymTrainStr = document.getElementById("location-gym-train-str"); var gymTrainDef = document.getElementById("location-gym-train-def"); var gymTrainDex = document.getElementById("location-gym-train-dex"); @@ -126,6 +119,17 @@ displayLocationContent = function() { var travelToNewTokyo = document.getElementById("location-travel-to-newtokyo"); var travelToIshima = document.getElementById("location-travel-to-ishima"); var travelToVolhaven = document.getElementById("location-travel-to-volhaven"); + + var loc = Player.location; + + returnToWorld.addEventListener("click", function() { + Engine.loadWorldContent(); + }); + + locationName.innerHTML = loc; + locationName.style.display = "block"; + + locationInfo.style.display = "block"; softwareJob.style.display = "none"; itJob.style.display = "none"; @@ -137,7 +141,7 @@ displayLocationContent = function() { employeeJob.style.display = "none"; waiterJob.style.display = "none"; - work.style.display = "none"; + work.style.display = "none"; //TODO DIsplay this gymTrainStr.style.display = "none"; gymTrainDef.style.display = "none"; @@ -181,7 +185,13 @@ displayLocationContent = function() { networkEngineerJob.style.display = "block"; businessJob.style.display = "block"; securityJob.style.display = "block"; + + purchase128gb.style.display = "block"; + purchase256gb.style.display = "block"; + purchase512gb.style.display = "block"; + purchase1tb.style.display = "block"; break; + case Locations.AevumBachmanAndAssociates: locationInfo.innerHTML = Companies[loc].info; @@ -212,6 +222,11 @@ displayLocationContent = function() { securityEngineerJob.style.display = "block"; networkEngineerJob.style.display = "block"; businessJob.style.display = "block"; + + purchase128gb.style.display = "block"; + purchase256gb.style.display = "block"; + purchase512gb.style.display = "block"; + purchase1tb.style.display = "block"; break; case Locations.AevumAeroCorp: @@ -267,6 +282,11 @@ displayLocationContent = function() { itJob.style.display = "block"; securityEngineerJob.style.display = "block"; networkEngineerJob.style.display = "block"; + + purchase1gb.style.display = "block"; + purchase2gb.style.display = "block"; + purchase4gb.style.display = "block"; + purchase8gb.style.display = "block"; break; case Locations.AevumCrushFitnessGym: @@ -445,14 +465,13 @@ displayLocationContent = function() { gymTrainAgi.style.display = "block"; break; - case Location.Sector12PowerhouseGym: + case Locations.Sector12PowerhouseGym: gymTrainStr.style.display = "block"; gymTrainDef.style.display = "block"; gymTrainDex.style.display = "block"; gymTrainAgi.style.display = "block"; break; - case Locations.NewTokyoTravelAgency: travelToAevum.style.display = "block"; travelToChongqing.style.display = "block"; @@ -518,7 +537,12 @@ displayLocationContent = function() { securityJob.style.display = "none"; agentJob.style.display = "none"; employeeJob.style.display = "none"; - waiterJob.style.display = "none"; + waiterJob.style.display = "none"; + + purchase32gb.style.display = "block"; + purchase64gb.style.display = "block"; + purchase128gb.style.display = "block"; + purchase256gb.style.display = "block"; break; case Locations.IshimaNovaMedical: @@ -537,6 +561,11 @@ displayLocationContent = function() { softwareJob.style.display = "block"; itJob.style.display = "block"; businessJob.style.display = "block"; + + purchase4gb.style.display = "block"; + purchase8gb.style.display = "block"; + purchase16gb.style.display = "block"; + purchase32gb.style.display = "block"; break; case Locations.VolhavenTravelAgency: @@ -558,6 +587,11 @@ displayLocationContent = function() { networkEngineerJob.style.display = "block"; businessJob.style.display = "block"; securityJob.style.display = "block"; + + purchase128gb.style.display = "block"; + purchase256gb.style.display = "block"; + purchase512gb.style.display = "block"; + purchase1tb.style.display = "block"; break; case Locations.VolhavenNWO: @@ -619,6 +653,14 @@ displayLocationContent = function() { itJob.style.display = "block"; securityEngineerJob.style.display = "block"; networkEngineerJob.style.display = "block"; + + purchase8gb.style.display = "block"; + purchase16gb.style.display = "block"; + purchase32gb.style.display = "block"; + purchase64gb.style.display = "block"; + purchase128gb.style.display = "block"; + purchase256gb.style.display = "block"; + break; case Locations.VolhavenMilleniumFitnessGym: @@ -632,297 +674,444 @@ displayLocationContent = function() { } initLocationButtons = function() { + //Buttons to travel to different locations in World aevumTravelAgency = document.getElementById("aevum-travelagency"); aevumTravelAgency.addEventListener("click", function() { Player.location = Locations.AevumTravelAgency; Engine.loadLocationContent(); + return false; }); aevumECorp = document.getElementById("aevum-ecorp"); aevumECorp.addEventListener("click", function() { Player.location = Locations.AevumECorp; Engine.loadLocationContent(); + return false; }); aevumBachmanAndAssociates = document.getElementById("aevum-bachmanandassociates"); aevumBachmanAndAssociates.addEventListener("click", function() { Player.location = Locations.AevumBachmanAndAssociates; Engine.loadLocationContent(); + return false; }); aevumClarkeIncorporated = document.getElementById("aevum-clarkeincorporated"); aevumClarkeIncorporated.addEventListener("click", function() { Player.location = Locations.AevumClarkeIncorporated; Engine.loadLocationContent(); + return false; }); aevumFulcrumTechnologies = document.getElementById("aevum-fulcrumtechnologies"); aevumFulcrumTechnologies.addEventListener("click", function() { Player.location = Locations.AevumFulcrumTechnologies; Engine.loadLocationContent(); + return false; }); aevumAeroCorp = document.getElementById("aevum-aerocorp"); aevumAeroCorp.addEventListener("click", function() { Player.location = Locations.AevumAeroCorp; Engine.loadLocationContent(); + return false; }); aevumGalacticCybersystems = document.getElementById("aevum-galacticcybersystems"); aevumGalacticCybersystems.addEventListener("click", function() { Player.location = Locations.AevumGalacticCybersystems; Engine.loadLocationContent(); + return false; }); aevumWatchdogSecurity = document.getElementById("aevum-watchdogsecurity"); aevumWatchdogSecurity.addEventListener("click", function() { Player.location = Locations.AevumWatchdogSecurity; Engine.loadLocationContent(); + return false; }); aevumRhoConstruction = document.getElementById("aevum-rhoconstruction"); aevumRhoConstruction.addEventListener("click", function() { Player.location = Locations.AevumRhoConstruction; Engine.loadLocationContent(); + return false; }); aevumPolice = document.getElementById("aevum-aevumpolice"); aevumPolice.addEventListener("click", function() { Player.location = Locations.AevumPolice; Engine.loadLocationContent(); + return false; }); aevumNetLinkTechnologies = document.getElementById("aevum-netlinktechnologies"); aevumNetLinkTechnologies.addEventListener("click", function() { Player.location = Locations.AevumNetLinkTechnologies; Engine.loadLocationContent(); + return false; }); aevumCrushFitnessGym = document.getElementById("aevum-crushfitnessgym"); aevumCrushFitnessGym.addEventListener("click", function() { Player.location = Locations.AevumCrushFitnessGym; Engine.loadLocationContent(); + return false; }); aevumSnapFitnessGym = document.getElementById("aevum-snapfitnessgym"); aevumSnapFitnessGym.addEventListener("click", function() { Player.location = Locations.AevumSnapFitnessGym; Engine.loadLocationContent(); + return false; }); chongqingTravelAgency = document.getElementById("chongqing-travelagency"); chongqingTravelAgency.addEventListener("click", function() { Player.location = Locations.ChongqingTravelAgency; Engine.loadLocationContent(); + return false; }); chongqingKuaiGongInternational = document.getElementById("chongqing-kuaigonginternational"); chongqingKuaiGongInternational.addEventListener("click", function() { Player.location = Locations.ChongqingKuaiGongInternational; Engine.loadLocationContent(); + return false; }); chongqingSolarisSpaceSystems = document.getElementById("chongqing-solarisspacesystems"); chongqingSolarisSpaceSystems.addEventListener("click", function() { Player.location = Locations.ChongqingSolarisSpaceSystems; Engine.loadLocationContent(); + return false; }); sector12TravelAgency = document.getElementById("sector12-travelagency"); sector12TravelAgency.addEventListener("click", function() { Player.location = Locations.Sector12TravelAgency; Engine.loadLocationContent(); + return false; }); sector12MegaCorp = document.getElementById("sector12-megacorp"); sector12MegaCorp.addEventListener("click", function() { Player.location = Locations.Sector12MegaCorp; Engine.loadLocationContent(); + return false; }); sector12BladeIndustries = document.getElementById("sector12-bladeindustries"); sector12BladeIndustries.addEventListener("click", function() { Player.location = Locations.Sector12BladeIndustries; Engine.loadLocationContent(); + return false; }); sector12FourSigma = document.getElementById("sector12-foursigma"); sector12FourSigma.addEventListener("click", function() { Player.location = Locations.Sector12FourSigma; Engine.loadLocationContent(); + return false; }); sector12IcarusMicrosystems = document.getElementById("sector12-icarusmicrosystems"); sector12IcarusMicrosystems.addEventListener("click", function() { Player.location = Locations.Sector12IcarusMicrosystems; Engine.loadLocationContent(); + return false; }); sector12UniversalEnergy = document.getElementById("sector12-universalenergy"); sector12UniversalEnergy.addEventListener("click", function() { Player.location = Locations.Sector12UniversalEnergy; Engine.loadLocationContent(); + return false; }); sector12DeltaOne = document.getElementById("sector12-deltaone"); sector12DeltaOne.addEventListener("click", function() { Player.location = Locations.Sector12DeltaOne; Engine.loadLocationContent(); + return false; }); sector12CIA = document.getElementById("sector12-cia"); sector12CIA.addEventListener("click", function() { Player.location = Locations.Sector12CIA; Engine.loadLocationContent(); + return false; }); sector12NSA = document.getElementById("sector12-nsa"); sector12NSA.addEventListener("click", function() { Player.location = Locations.Sector12NSA; Engine.loadLocationContent(); + return false; }); sector12AlphaEnterprises = document.getElementById("sector12-alphaenterprises"); sector12AlphaEnterprises.addEventListener("click", function() { Player.location = Locations.Sector12AlphaEnterprises; Engine.loadLocationContent(); + return false; }); sector12CarmichaelSecurity = document.getElementById("sector12-carmichaelsecurity"); sector12CarmichaelSecurity.addEventListener("click", function() { Player.location = Locations.Sector12CarmichaelSecurity; Engine.loadLocationContent(); + return false; }); sector12FoodNStuff = document.getElementById("sector12-foodnstuff"); sector12FoodNStuff.addEventListener("click", function() { Player.location = Locations.Sector12FoodNStuff; Engine.loadLocationContent(); + return false; }); sector12JoesGuns = document.getElementById("sector12-joesguns"); sector12JoesGuns.addEventListener("click", function() { Player.location = Locations.Sector12JoesGuns; Engine.loadLocationContent(); + return false; }); sector12IronGym = document.getElementById("sector12-irongym"); sector12IronGym.addEventListener("click", function() { Player.location = Locations.Sector12IronGym; Engine.loadLocationContent(); + return false; }); sector12PowerhouseGym = document.getElementById("sector12-powerhousegym"); sector12PowerhouseGym.addEventListener("click", function() { Player.location = Locations.Sector12PowerhouseGym; Engine.loadLocationContent(); + return false; }); newTokyoTravelAgency = document.getElementById("newtokyo-travelagency"); newTokyoTravelAgency.addEventListener("click", function() { Player.location = Locations.NewTokyoTravelAgency; Engine.loadLocationContent(); + return false; }); newTokyoDefComm = document.getElementById("newtokyo-defcomm"); newTokyoDefComm.addEventListener("click", function() { Player.location = Locations.NewTokyoDefComm; Engine.loadLocationContent(); + return false; }); newTokyoVitaLife = document.getElementById("newtokyo-vitalife"); newTokyoVitaLife.addEventListener("click", function() { Player.location = Locations.NewTokyoVitaLife; Engine.loadLocationContent(); + return false; }); newTokyoGlobalPharmaceuticals = document.getElementById("newtokyo-globalpharmaceuticals"); newTokyoGlobalPharmaceuticals.addEventListener("click", function() { Player.location = Locations.NewTokyoGlobalPharmaceuticals; Engine.loadLocationContent(); + return false; }); newTokyoNoodleBar = document.getElementById("newtokyo-noodlebar"); newTokyoNoodleBar.addEventListener("click", function() { Player.location = Locations.NewTokyoNoodleBar; Engine.loadLocationContent(); + return false; }); ishimaTravelAgency = document.getElementById("ishima-travelagency"); ishimaTravelAgency.addEventListener("click", function() { Player.location = Locations.IshimaTravelAgency; Engine.loadLocationContent(); + return false; }); ishimaStormTechnologies = document.getElementById("ishima-stormtechnologies"); ishimaStormTechnologies.addEventListener("click", function() { Player.location = Locations.IshimaStormTechnologies; Engine.loadLocationContent(); + return false; }); ishimaNovaMedical = document.getElementById("ishima-novamedical"); ishimaNovaMedical.addEventListener("click", function() { Player.location = Locations.IshimaNovaMedical; Engine.loadLocationContent(); + return false; }); ishimaOmegaSoftware = document.getElementById("ishima-omegasoftware"); ishimaOmegaSoftware.addEventListener("click", function() { Player.location = Locations.IshimaOmegaSoftware; Engine.loadLocationContent(); + return false; }); volhavenTravelAgency = document.getElementById("volhaven-travelagency"); volhavenTravelAgency.addEventListener("click", function() { Player.location = Locations.VolhavenTravelAgency; Engine.loadLocationContent(); + return false; }); volhavenOmniTekIncorporated = document.getElementById("volhaven-omnitekincorporated"); volhavenOmniTekIncorporated.addEventListener("click", function() { Player.location = Locations.VolhavenOmniTekIncorporated; Engine.loadLocationContent(); + return false; }); volhavenNWO = document.getElementById("volhaven-nwo"); volhavenNWO.addEventListener("click", function() { Player.location = Locations.VolhavenNWO; Engine.loadLocationContent(); + return false; }); volhavenHeliosLabs = document.getElementById("volhaven-helioslabs"); volhavenHeliosLabs.addEventListener("click", function() { Player.location = Locations.VolhavenHeliosLabs; Engine.loadLocationContent(); + return false; }); volhavenOmniaCybersystems = document.getElementById("volhaven-omniacybersystems"); volhavenOmniaCybersystems.addEventListener("click", function() { Player.location = Locations.VolhavenOmniaCybersystems; Engine.loadLocationContent(); + return false; }); volhavenLexoCorp = document.getElementById("volhaven-lexocorp"); volhavenLexoCorp.addEventListener("click", function() { Player.location = Locations.VolhavenLexoCorp; Engine.loadLocationContent(); + return false; }); volhavenSysCoreSecurities = document.getElementById("volhaven-syscoresecurities"); volhavenSysCoreSecurities.addEventListener("click", function() { Player.location = Locations.VolhavenSysCoreSecurities; Engine.loadLocationContent(); + return false; }); volhavenCompuTek = document.getElementById("volhaven-computek"); volhavenCompuTek.addEventListener("click", function() { Player.location = Locations.VolhavenCompuTek; Engine.loadLocationContent(); + return false; }); volhavenMilleniumFitnessGym = document.getElementById("volhaven-milleniumfitnessgym"); volhavenMilleniumFitnessGym.addEventListener("click", function() { Player.location = Locations.VolhavenMilleniumFitnessGym; Engine.loadLocationContent(); + return false; }); -} \ No newline at end of file + + + //Buttons to interact at a location (apply for job/promotion, train, purchase, etc.) + var softwareJob = document.getElementById("location-software-job"); + var itJob = document.getElementById("location-it-job"); + var securityEngineerJob = document.getElementById("location-security-engineer-job"); + var networkEngineerJob = document.getElementById("location-network-engineer-job"); + var businessJob = document.getElementById("location-business-job"); + var securityJob = document.getElementById("location-security-job"); + var agentJob = document.getElementById("location-agent-job"); + var employeeJob = document.getElementById("location-employee-job"); + var waiterJob = document.getElementById("location-waiter-job"); + + var work = document.getElementById("location-work"); + + var gymTrainStr = document.getElementById("location-gym-train-str"); + var gymTrainDef = document.getElementById("location-gym-train-def"); + var gymTrainDex = document.getElementById("location-gym-train-dex"); + var gymTrainAgi = document.getElementById("location-gym-train-agi"); + + var purchase1gb = document.getElementById("location-purchase-1gb"); + var purchase2gb = document.getElementById("location-purchase-2gb"); + var purchase4gb = document.getElementById("location-purchase-4gb"); + var purchase8gb = document.getElementById("location-purchase-8gb"); + var purchase16gb = document.getElementById("location-purchase-16gb"); + var purchase32gb = document.getElementById("location-purchase-32gb"); + var purchase64gb = document.getElementById("location-purchase-64gb"); + var purchase128gb = document.getElementById("location-purchase-128gb"); + var purchase256gb = document.getElementById("location-purchase-256gb"); + var purchase512gb = document.getElementById("location-purchase-512gb"); + var purchase1tb = document.getElementById("location-purchase-1tb"); + + var travelToAevum = document.getElementById("location-travel-to-aevum"); + var travelToChongqing = document.getElementById("location-travel-to-chongqing"); + var travelToSector12 = document.getElementById("location-travel-to-sector12"); + var travelToNewTokyo = document.getElementById("location-travel-to-newtokyo"); + var travelToIshima = document.getElementById("location-travel-to-ishima"); + var travelToVolhaven = document.getElementById("location-travel-to-volhaven"); + + softwareJob.addEventListener("click", function() { + Player.applyForSoftwareJob(); + return false; + }); + + itJob.addEventListener("click", function() { + Player.applyForSoftwareJob() + return false; + }); + + securityEngineerJob.addEventListener("click", function() { + Player.applyForSecurityEngineerJob(); + return false; + }); + + networkEngineerJob.addEventListener("click", function() { + Player.applyForNetworkEngineerJob(); + return false; + }); + + businessJob.addEventListener("click", function() { + Player.applyForBusinessJob(); + return false; + }); + + securityJob.addEventListener("click", function() { + Player.applyForSecurityJob(); + return false; + }); + + agentJob.addEventListener("click", function() { + Player.applyForAgentJob(); + return false; + }); + + employeeJob.addEventListener("click", function() { + Player.applyForEmployeeJob(); + return false; + }); + + waiterJob.addEventListener("click", function() { + Player.applyForWaiterJob(); + return false; + }); + + purchase1gb.addEventListener("click", function() { + askToPurchaseServer(1); + }); + +} purchase2gb + purchase4gb + purchase8gb + purchase16gb + purchase32gb + purchase64gb + purchase128gb + purchase256gb + purchase512gb + purchase1tb \ No newline at end of file diff --git a/src/Player.js b/src/Player.js index 203f78a1c..3abdf20a8 100644 --- a/src/Player.js +++ b/src/Player.js @@ -60,7 +60,7 @@ function PlayerObject() { this.homeComputer = ""; //Location information - this.city = Locations.Aevum; + this.city = Locations.Sector12; this.location = ""; //Company Information @@ -69,7 +69,7 @@ function PlayerObject() { //Servers this.currentServer = ""; //IP address of Server currently being accessed through terminal - this.discoveredServers = []; //IP addresses of secret servers not in the network that you have discovered + this.discoveredServers = []; //IP addresses of secret servers not in the network that you have discovered this.purchasedServers = []; //Achievements and achievement progress diff --git a/src/PurchaseServers.js b/src/PurchaseServers.js new file mode 100644 index 000000000..8c244760c --- /dev/null +++ b/src/PurchaseServers.js @@ -0,0 +1,14 @@ +/* Functions to handle Purchase of Servers */ +purchaseServer = function(ram, cost) { + //TODO Check if player has enough money + + + var newServ = new Server(); + var hostname = document.getElementById("purchase-server-box-input").value; + newServ.init(createRandomIp(), hostname, "", true, false, true, true, ram); + + AddToAllServers(newServ); + Player.purchasedServers.push(newServ); + + //TODO Dialog box saying successfully purchased +} \ No newline at end of file diff --git a/src/Terminal.js b/src/Terminal.js index 49c1ddd13..1d4fa0599 100644 --- a/src/Terminal.js +++ b/src/Terminal.js @@ -228,6 +228,7 @@ var Terminal = { if (Player.getCurrentServer().getServerOnNetwork(i).ip == ip || Player.getCurrentServer().getServerOnNetwork(i).hostname == ip) { Player.getCurrentServer().isConnectedTo = false; Player.currentServer = Player.getCurrentServer().getServerOnNetwork(i).ip; + Player.getCurrentServer().isConnectedTo = true; post("Connected to " + ip); return; } diff --git a/src/engine.js b/src/engine.js index 653a69e01..eb69068c8 100644 --- a/src/engine.js +++ b/src/engine.js @@ -247,7 +247,14 @@ var Engine = { /* Display character info */ displayCharacterInfo: function() { - Engine.Display.characterInfo.innerHTML = 'Money: $' + Player.money.toFixed(2) + '

' + + var companyPosition = ""; + if (Player.companyPosition != "") { + companyPosition = Player.companyPosition.positionName; + } + Engine.Display.characterInfo.innerHTML = 'Current City: ' + Player.city + '

' + + 'Employer: ' + Player.companyName + '

' + + 'Job Title: ' + companyPosition + '



' + + 'Money: $' + Player.money.toFixed(2) + '

' + 'Hacking Level: ' + Player.hacking_skill + '

' + 'Strength: ' + Player.strength + '

' + 'Defense: ' + Player.defense + '

' + diff --git a/utils/DialogBox.js b/utils/DialogBox.js new file mode 100644 index 000000000..6e79dac8b --- /dev/null +++ b/utils/DialogBox.js @@ -0,0 +1,45 @@ +/* Pop up Dialog Box */ +function dialogBoxInit() { + if (Engine.Debug) { + console.log("Dialog Box Initialized"); + } + var closeButton = document.getElementById("dialog-box-close-button"); + var dialogBox = document.getElementById("dialog-box-container"); + + //Close Dialog box + closeButton.addEventListener("click", function() { + dialogBoxClose(); + return false; + }); +}; + +document.addEventListener("DOMContentLoaded", dialogBoxInit, false); + +dialogBoxClose = function() { + if (Engine.Debug) { + console.log("Dialog Box Close called"); + } + var dialogBox = document.getElementById("dialog-box-container"); + dialogBox.style.display = "none"; +} + +dialogBoxOpen = function() { + var dialogBox = document.getElementById("dialog-box-container"); + dialogBox.style.display = "block"; +} + +dialogBoxSetText = function(txt1, txt2="", txt3="", txt4="") { + var dialogBoxText1 = document.getElementById("dialog-box-text-1"); + var dialogBoxText2 = document.getElementById("dialog-box-text-2"); + var dialogBoxText3 = document.getElementById("dialog-box-text-3"); + var dialogBoxText4 = document.getElementById("dialog-box-text-4"); + dialogBoxText1.innerHTML = txt1; + dialogBoxText2.innerHTML = txt2; + dialogBoxText3.innerHTML = txt3; + dialogBoxText4.innerHTML = txt4; +} + +dialogBoxCreate = function(txt1, txt2="", txt3="", txt4="") { + dialogBoxSetText(txt1, txt2, txt3, txt4); + dialogBoxOpen(); +} \ No newline at end of file diff --git a/utils/PurchaseServerBox.js b/utils/PurchaseServerBox.js new file mode 100644 index 000000000..83b003360 --- /dev/null +++ b/utils/PurchaseServerBox.js @@ -0,0 +1,42 @@ +/* Pop up Yes/No Box */ +function purchaseServerBoxInit() { + if (Engine.Debug) { + console.log("Purchase Server box Initialized"); + } + var cancelButton = document.getElementById("purchase-server-box-cancel"); + + //Close Dialog box + cancelButton.addEventListener("click", function() { + purchaseServerBoxClose(); + return false; + }); +}; + +document.addEventListener("DOMContentLoaded", purchaseServerBoxInit, false); + +purchaseServerBoxClose = function() { + var purchaseServerBox = document.getElementById("purchase-server-box-container"); + purchaseServerBox.style.display = "none"; +} + +purchaseServerBoxOpen = function() { + var purchaseServerBox = document.getElementById("purchase-server-box-container"); + purchaseServerBox.style.display = "block"; +} + +purchaseServerBoxSetText = function(txt) { + var purchaseServerBox = document.getElementById("purchase-server-box-text"); + purchaseServerBox.innerHTML = txt; +} + +//ram argument is in GB +purchaseServerBoxCreate = function(ram, cost) { + purchaseServerBoxSetText("Would you like to purchase a new server with " + ram + "GB of RAM for $" + cost + "?" ); + + var confirmButton = document.getElementById("purchase-server-box-confirm"); + confirmButton.addEventListener("click", function() { + purchaseServer(ram, cost); + }); + + purchaseServerBoxOpen(); +} \ No newline at end of file