Implemented Applying to jobs. Working on Purchasing Servers

This commit is contained in:
Daniel Xie 2017-02-03 16:05:59 -06:00
parent afda3338bd
commit fc2dc82f1a
11 changed files with 537 additions and 126 deletions

@ -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;

@ -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;
}

@ -16,6 +16,8 @@
<script src="utils/JSONReviver.js"></script>
<script src="utils/StringHelperFunctions.js"></script>
<script src="utils/ObjectHelperFunctions.js"></script>
<script src="utils/DialogBox.js"></script>
<script src="utils/PurchaseServerBox.js"></script>
<!-- Netscript -->
<script src="src/netscript/NetScriptWorker.js"></script>
@ -33,7 +35,9 @@
<script src="src/Player.js"></script>
<script src="src/Faction.js"></script>
<script src="src/Company.js"></script>
<script src="src/CompanyJobApplication.js"></script>
<script src="src/Terminal.js"></script>
<script src="src/PurchaseServers.js"></script>
<script src="src/engine.js"></script>
@ -168,124 +172,124 @@
<ul id="chongqing-locations-list">
<li id="chongqing-travelagency-li">
<a href="#" id="chongqing-travelagency"> Travel Agency </a>
<a href="#" id="chongqing-travelagency" class="a-link-button"> Travel Agency </a>
<li>
<li id="chonqging-kuaigonginternational-li">
<a href="#" id="chongqing-kuaigonginternational">KuaiGong International </a>
<a href="#" id="chongqing-kuaigonginternational" class="a-link-button">KuaiGong International </a>
<li>
<li id="chongqing-solarisspacesystems-li">
<a href="#" id="chongqing-solarisspacesystems">Solaris Space Systems</a>
<a href="#" id="chongqing-solarisspacesystems" class="a-link-button">Solaris Space Systems</a>
<li>
</ul>
<ul id="sector12-locations-list">
<li id="sector12-travelagency-li">
<a href="#" id="sector12-travelagency">Travel Agency </a>
<a href="#" id="sector12-travelagency" class="a-link-button">Travel Agency </a>
<li>
<li id="sector12-megacorp-li">
<a href="#" id="sector12-megacorp">MegaCorp</a>
<a href="#" id="sector12-megacorp" class="a-link-button">MegaCorp</a>
<li>
<li id="sector12-bladeindustries-li">
<a href="#" id="sector12-bladeindustries"> Blade Industries</a>
<a href="#" id="sector12-bladeindustries" class="a-link-button"> Blade Industries</a>
<li>
<li id="sector12-foursigma-li">
<a href="#" id="sector12-foursigma">Four Sigma</a>
<a href="#" id="sector12-foursigma" class="a-link-button">Four Sigma</a>
<li>
<li id="sector12-icarusmicrosystems-li">
<a href="#" id="sector12-icarusmicrosystems"> Icarus Microsystems</a>
<a href="#" id="sector12-icarusmicrosystems" class="a-link-button"> Icarus Microsystems</a>
<li>
<li id="sector12-universalenergy-li">
<a href="#" id="sector12-universalenergy">Universal Energy </a>
<a href="#" id="sector12-universalenergy" class="a-link-button">Universal Energy </a>
<li>
<li id="sector12-deltaone-li">
<a href="#" id="sector12-deltaone">DeltaOne </a>
<a href="#" id="sector12-deltaone" class="a-link-button">DeltaOne </a>
<li>
<li id="sector12-cia-li">
<a href="#" id="sector12-cia">Central Intelligence Agency </a>
<a href="#" id="sector12-cia" class="a-link-button">Central Intelligence Agency </a>
<li>
<li id="sector12-nsa-li">
<a href="#" id="sector12-nsa">National Security Agency </a>
<a href="#" id="sector12-nsa" class="a-link-button">National Security Agency </a>
<li>
<li id="sector12-alphaenterprises-li">
<a href="#" id="sector12-alphaenterprises">Alpha Enterprises</a>
<a href="#" id="sector12-alphaenterprises" class="a-link-button">Alpha Enterprises</a>
<li>
<li id="sector12-carmichaelsecurity-li">
<a href="#" id="sector12-carmichaelsecurity"> Carmichael Security</a>
<a href="#" id="sector12-carmichaelsecurity" class="a-link-button"> Carmichael Security</a>
<li>
<li id="sector12-foodnstuff-li">
<a href="#" id="sector12-foodnstuff">FoodNStuff</a>
<a href="#" id="sector12-foodnstuff" class="a-link-button">FoodNStuff</a>
<li>
<li id="sector12-joesguns-li">
<a href="#" id="sector12-joesguns"> Joe's Guns</a>
<a href="#" id="sector12-joesguns" class="a-link-button"> Joe's Guns</a>
<li>
<li id="sector12-irongym-li">
<a href="#" id="sector12-irongym">Iron Gym </a>
<a href="#" id="sector12-irongym" class="a-link-button">Iron Gym </a>
<li>
<li id="sector12-powerhousegym-li">
<a href="#" id="sector12-powerhousegym">Powerhouse Gym</a>
<a href="#" id="sector12-powerhousegym" class="a-link-button">Powerhouse Gym</a>
<li>
</ul>
<ul id="newtokyo-locations-list">
<li id="newtokyo-travelagency-li">
<a href="#" id="newtokyo-travelagency"> Travel Agency</a>
<a href="#" id="newtokyo-travelagency" class="a-link-button"> Travel Agency</a>
<li>
<li id="newtokyo-defcomm-li">
<a href="#" id="newtokyo-defcomm"> DefComm</a>
<a href="#" id="newtokyo-defcomm" class="a-link-button"> DefComm</a>
<li>
<li id="newtokyo-vitalife-li">
<a href="#" id="newtokyo-vitalife">VitaLife </a>
<a href="#" id="newtokyo-vitalife" class="a-link-button">VitaLife </a>
<li>
<li id="newtokyo-globalpharmaceuticals-li">
<a href="#" id="newtokyo-globalpharmaceuticals">Global Pharmaceuticals</a>
<a href="#" id="newtokyo-globalpharmaceuticals" class="a-link-button">Global Pharmaceuticals</a>
<li>
<li id="newtokyo-noodlebar-li">
<a href="#" id="newtokyo-noodlebar">Noodle Bar </a>
<a href="#" id="newtokyo-noodlebar" class="a-link-button">Noodle Bar </a>
<li>
</ul>
<ul id="ishima-locations-list">
<li id="ishima-travelagency-li">
<a href="#" id="ishima-travelagency">Travel Agency </a>
<a href="#" id="ishima-travelagency" class="a-link-button">Travel Agency </a>
<li>
<li id="ishima-stormtechnologies-li">
<a href="#" id="ishima-stormtechnologies">Storm Technologies</a>
<a href="#" id="ishima-stormtechnologies" class="a-link-button">Storm Technologies</a>
<li>
<li id="ishima-novamedical-li">
<a href="#" id="ishima-novamedical">Nova Medical</a>
<a href="#" id="ishima-novamedical" class="a-link-button">Nova Medical</a>
<li>
<li id="ishima-omegasoftware-li">
<a href="#" id="ishima-omegasoftware">Omega Software </a>
<a href="#" id="ishima-omegasoftware" class="a-link-button">Omega Software </a>
<li>
</ul>
<ul id="volhaven-locations-list">
<li id="volhaven-travelagency-li">
<a href="#" id="volhaven-travelagency">Travel Agency </a>
<a href="#" id="volhaven-travelagency" class="a-link-button">Travel Agency </a>
<li>
<li id="volhaven-omnitekincorporated-li">
<a href="#" id="volhaven-omnitekincorporated">OmniTek Incorporated </a>
<a href="#" id="volhaven-omnitekincorporated" class="a-link-button">OmniTek Incorporated </a>
<li>
<li id="volhaven-nwo-li">
<a href="#" id="volhaven-nwo">NWO</a>
<a href="#" id="volhaven-nwo" class="a-link-button">NWO</a>
<li>
<li id="volhaven-helislabs-li">
<a href="#" id="volhaven-helioslabs">Helios Labs</a>
<a href="#" id="volhaven-helioslabs" class="a-link-button">Helios Labs</a>
<li>
<li id="volhaven-omniacybersystems-li">
<a href="#" id="volhaven-omniacybersystems">Omnia Cybersystems</a>
<a href="#" id="volhaven-omniacybersystems" class="a-link-button">Omnia Cybersystems</a>
<li>
<li id="volhaven-lexocorp-li">
<a href="#" id="volhaven-lexocorp">LexoCorp</a>
<a href="#" id="volhaven-lexocorp" class="a-link-button">LexoCorp</a>
<li>
<li id="volhaven-syscoresecurities-li">
<a href="#" id="volhaven-syscoresecurities">SysCore Securities</a>
<a href="#" id="volhaven-syscoresecurities" class="a-link-button">SysCore Securities</a>
<li>
<li id="volhaven-computek-li">
<a href="#" id="volhaven-computek">CompuTek</a>
<a href="#" id="volhaven-computek" class="a-link-button">CompuTek</a>
<li>
<li id="volhaven-milleniumfitnessgym-li">
<a href="#" id="volhaven-milleniumfitnessgym">Millenium Fitness Gym</a>
<a href="#" id="volhaven-milleniumfitnessgym" class="a-link-button">Millenium Fitness Gym</a>
<li>
</ul>
</div>
@ -365,23 +369,23 @@
<a href="#" id="location-work" class="a-link-button"> Work </a>
<!-- Gym -->
<a href="#" id="location-gym-train-str" class="a-link-button"> Train Strength</a>
<a href="#" id="location-gym-train-def" class="a-link-button"> Train Defense </a>
<a href="#" id="location-gym-train-dex" class="a-link-button"> Train Dexterity</a>
<a href="#" id="location-gym-train-agi" class="a-link-button"> Train Agility</a>
<a href="#" id="location-gym-train-str" class="a-link-button">Train Strength</a>
<a href="#" id="location-gym-train-def" class="a-link-button">Train Defense </a>
<a href="#" id="location-gym-train-dex" class="a-link-button">Train Dexterity</a>
<a href="#" id="location-gym-train-agi" class="a-link-button">Train Agility</a>
<!-- Purchase servers -->
<a href="#" id="location-purchase-1gb" class="a-link-button"> Purchase 1GB Server</a>
<a href="#" id="location-purchase-2gb" class="a-link-button"> Purchase 2GB Server</a>
<a href="#" id="location-purchase-4gb" class="a-link-button"> Purchase 4GB Server</a>
<a href="#" id="location-purchase-8gb" class="a-link-button"> Purchase 8GB Server</a>
<a href="#" id="location-purchase-16gb" class="a-link-button"> Purchase 16GB Server</a>
<a href="#" id="location-purchase-32gb" class="a-link-button"> Purchase 32GB Server</a>
<a href="#" id="location-purchase-64gb" class="a-link-button"> Purchase 64GB Server</a>
<a href="#" id="location-purchase-128gb" class="a-link-button"> Purchase 128GB Server</a>
<a href="#" id="location-purchase-256gb" class="a-link-button"> Purchase 256GB Server</a>
<a href="#" id="location-purchase-512gb" class="a-link-button"> Purchase 512GB Server</a>
<a href="#" id="location-purchase-1tb" class="a-link-button"> Purchase 1TB Server</a>
<a href="#" id="location-purchase-1gb" class="a-link-button"> Purchase 1GB Server - $100,000</a>
<a href="#" id="location-purchase-2gb" class="a-link-button"> Purchase 2GB Server - $250,000</a>
<a href="#" id="location-purchase-4gb" class="a-link-button"> Purchase 4GB Server - $600,000</a>
<a href="#" id="location-purchase-8gb" class="a-link-button"> Purchase 8GB Server - $1,500,000</a>
<a href="#" id="location-purchase-16gb" class="a-link-button"> Purchase 16GB Server - $4,000,000</a>
<a href="#" id="location-purchase-32gb" class="a-link-button"> Purchase 32GB Server - $9,000,000</a>
<a href="#" id="location-purchase-64gb" class="a-link-button"> Purchase 64GB Server - $20,000,000</a>
<a href="#" id="location-purchase-128gb" class="a-link-button"> Purchase 128GB Server - $45,000,000</a>
<a href="#" id="location-purchase-256gb" class="a-link-button"> Purchase 256GB Server - $100,000,000</a>
<a href="#" id="location-purchase-512gb" class="a-link-button"> Purchase 512GB Server - $250,000,000</a>
<a href="#" id="location-purchase-1tb" class="a-link-button"> Purchase 1TB Server - $600,000,000</a>
<!-- Travel agency -->
<a href="#" id="location-travel-to-aevum" class="a-link-button"> Travel to Aevum </a>
@ -392,5 +396,27 @@
<a href="#" id="location-travel-to-volhaven" class="a-link-button"> Travel to Volhaven</a>
</div>
<!-- Dialog Box, displays status text only -->
<div id="dialog-box-container">
<div id="dialog-box-content">
<span id="dialog-box-close-button">&times;</span>
<p id="dialog-box-text-1" class="dialog-box-text"> </p>
<p id="dialog-box-text-2" class="dialog-box-text"> </p>
<p id="dialog-box-text-3" class="dialog-box-text"> </p>
<p id="dialog-box-text-4" class="dialog-box-text"> </p>
</div>
</div>
<!-- Purchase Server Box -->
<div id="purchase-server-box-container">
<div id="purchase-server-box-content">
<p id="purchase-server-box-text"> </p>
<p id="purchase-server-box-enter-name"> Enter new server hostname: </p>
<input type="text" id="purchase-server-box-input" pattern="[a-zA-Z0-9-_]+ maxlength="30"> </input>
<span id="purchase-server-box-confirm"> Purchase </span>
<span id="purchase-server-box-cancel"> Cancel </span>
</div>
</div>
</body>
</html>

@ -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");
}
}

@ -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;
});
}
//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

@ -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

14
src/PurchaseServers.js Normal file

@ -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
}

@ -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;
}

@ -247,7 +247,14 @@ var Engine = {
/* Display character info */
displayCharacterInfo: function() {
Engine.Display.characterInfo.innerHTML = 'Money: $' + Player.money.toFixed(2) + '<br><br>' +
var companyPosition = "";
if (Player.companyPosition != "") {
companyPosition = Player.companyPosition.positionName;
}
Engine.Display.characterInfo.innerHTML = 'Current City: ' + Player.city + '<br><br>' +
'Employer: ' + Player.companyName + '<br><br>' +
'Job Title: ' + companyPosition + '<br><br><br><br>' +
'Money: $' + Player.money.toFixed(2) + '<br><br>' +
'Hacking Level: ' + Player.hacking_skill + '<br><br>' +
'Strength: ' + Player.strength + '<br><br>' +
'Defense: ' + Player.defense + '<br><br>' +

45
utils/DialogBox.js Normal file

@ -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();
}

@ -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();
}