Playtesting - Fixed bugs

This commit is contained in:
Daniel Xie 2017-04-19 16:39:25 -05:00
parent 9b408cb995
commit e2e0bba3c2
9 changed files with 104 additions and 35 deletions

@ -191,6 +191,14 @@
color: #66ff33; color: #66ff33;
} }
#faction-augmentations-container p,
#faction-augmentations-container a,
#faction-augmentations-container ul,
#faction-augmentations-container h1{
margin: 8px;
padding: 4px;
}
/* World */ /* World */
#world-container li { #world-container li {
margin: 0 0 15px 0; margin: 0 0 15px 0;

@ -73,8 +73,8 @@ li {
text-decoration: none; text-decoration: none;
background-color: #555; background-color: #555;
color: #FFFFFF; color: #FFFFFF;
padding: 4px; padding: 6px;
margin: 4px; margin: 6px;
border-top: 1px solid #333333; border-top: 1px solid #333333;
border-right: 1px solid #333333; border-right: 1px solid #333333;
border-bottom: 1px solid #333333; border-bottom: 1px solid #333333;
@ -86,8 +86,8 @@ li {
text-decoration: none; text-decoration: none;
background-color: #555; background-color: #555;
color: #FFFFFF; color: #FFFFFF;
padding: 4px; padding: 6px;
margin: 4px; margin: 6px;
border-top: 1px solid #333333; border-top: 1px solid #333333;
border-right: 1px solid #333333; border-right: 1px solid #333333;
border-bottom: 1px solid #333333; border-bottom: 1px solid #333333;

@ -397,9 +397,10 @@
</div> </div>
<div id="faction-augmentations-container"> <div id="faction-augmentations-container">
<a href="#" id="faction-augmentations-back-button" class="a-link-button"> Back </a>
<h1> Faction Augmentations </h1> <h1> Faction Augmentations </h1>
<p id="faction-augmentations-page-desc"> Lists all augmentations that are available to purchase from </p> <p id="faction-augmentations-page-desc"> Lists all augmentations that are available to purchase from </p>
<a href="#" id="faction-augmentations-back-button" class="a-link-button"> Back </a>
<ul class="faction-augmentations-list" id="faction-augmentations-list"> <ul class="faction-augmentations-list" id="faction-augmentations-list">
</ul> </ul>
</div> </div>

@ -28,6 +28,9 @@ CONSTANTS = {
MillisecondsPer8Hours: 28800000, MillisecondsPer8Hours: 28800000,
GameCyclesPer8Hours: 28800000 / 200, GameCyclesPer8Hours: 28800000 / 200,
MillisecondsPer4Hours: 14400000,
GameCyclesPer4Hours: 14400000 / 200,
MillisecondsPerHour: 3600000, MillisecondsPerHour: 3600000,
GameCyclesPerHour: 3600000 / 200, GameCyclesPerHour: 3600000 / 200,

@ -8,6 +8,8 @@ Programs = {
SQLInjectProgram: "SQLInject.exe", SQLInjectProgram: "SQLInject.exe",
} }
//TODO Right now the times needed to complete work are hard-coded...
//maybe later make this dependent on hacking level or something
function displayCreateProgramContent() { function displayCreateProgramContent() {
var portHackALink = document.getElementById("create-program-porthack"); var portHackALink = document.getElementById("create-program-porthack");
var bruteSshALink = document.getElementById("create-program-brutessh"); var bruteSshALink = document.getElementById("create-program-brutessh");
@ -38,7 +40,7 @@ function displayCreateProgramContent() {
Player.hacking_skill >= 50) { Player.hacking_skill >= 50) {
bruteSshALink.style.display = "block"; bruteSshALink.style.display = "block";
bruteSshALink.addEventListener("click", function() { bruteSshALink.addEventListener("click", function() {
createProgram(Programs.BruteSSHProgram); Player.startCreateProgramWork(Programs.BruteSSHProgram, CONSTANTS.MillisecondsPerHour);
}); });
} }
@ -47,7 +49,7 @@ function displayCreateProgramContent() {
Player.hacking_skill >= 125) { Player.hacking_skill >= 125) {
ftpCrackALink.style.display = "block"; ftpCrackALink.style.display = "block";
ftpCrackALink.addEventListener("click", function() { ftpCrackALink.addEventListener("click", function() {
createProgram(Programs.FTPCrackProgram); Player.startCreateProgramWork(Programs.FTPCrackProgram, CONSTANTS.MillisecondsPer4Hours);
}); });
} }
@ -56,7 +58,7 @@ function displayCreateProgramContent() {
Player.hacking_skill >= 300) { Player.hacking_skill >= 300) {
relaySmtpALink.style.display = "block"; relaySmtpALink.style.display = "block";
relaySmtpAlink.addEventListener("click", function() { relaySmtpAlink.addEventListener("click", function() {
createProgram(Programs.RelaySMTPProgram); Player.startCreateProgramWork(Programs.RelaySMTPProgram. CONSTANTS.MillisecondsPer8Hours);
}); });
} }
@ -65,7 +67,7 @@ function displayCreateProgramContent() {
Player.hacking_skill >= 500) { Player.hacking_skill >= 500) {
httpWormALink.style.display = "block"; httpWormALink.style.display = "block";
httpWormALink.addEventListener("click", function() { httpWormALink.addEventListener("click", function() {
createProgram(Programs.HTTPWormProgram); Player.startCreateProgramWork(Programs.HTTPWormProgram, CONSTANTS.MillisecondsPer10Hours);
}); });
} }
@ -74,11 +76,7 @@ function displayCreateProgramContent() {
Player.hacking_skill >= 750) { Player.hacking_skill >= 750) {
sqlInjectALink.style.display = "block"; sqlInjectALink.style.display = "block";
sqlInjectALink.addEventListener("click", function() { sqlInjectALink.addEventListener("click", function() {
createProgram(Programs.SQLInjectProgram); Player.startCreateProgramWork(Programs.SQLInjectProgram, CONSTANTS.MillisecondsPer10Hours);
}); });
} }
} }
function createProgram(programName) {
Player.startCreateProgramWork(programName);
}

@ -445,7 +445,7 @@ displayFactionContent = function(factionName) {
var faction = Factions[factionName]; var faction = Factions[factionName];
document.getElementById("faction-name").innerHTML = factionName; document.getElementById("faction-name").innerHTML = factionName;
document.getElementById("faction-info").innerHTML = faction.info; document.getElementById("faction-info").innerHTML = faction.info;
document.getElementById("faction-reputation").innerHTML = "Reputation: " + faction.playerReputation; document.getElementById("faction-reputation").innerHTML = "Reputation: " + faction.playerReputation.toFixed(3);
var hackDiv = document.getElementById("faction-hack-div"); var hackDiv = document.getElementById("faction-hack-div");
var fieldWorkDiv = document.getElementById("faction-fieldwork-div"); var fieldWorkDiv = document.getElementById("faction-fieldwork-div");
@ -649,6 +649,9 @@ displayFactionAugmentations = function(factionName) {
var faction = Factions[factionName]; var faction = Factions[factionName];
var augmentationsList = document.getElementById("faction-augmentations-list"); var augmentationsList = document.getElementById("faction-augmentations-list");
while (augmentationsList.firstChild) {
augmentationsList.removeChild(augmentationsList.firstChild);
}
for (var i = 0; i < faction.augmentations.length; ++i) { for (var i = 0; i < faction.augmentations.length; ++i) {
var aug = Augmentations[faction.augmentations[i]]; var aug = Augmentations[faction.augmentations[i]];
@ -660,13 +663,14 @@ displayFactionAugmentations = function(factionName) {
if (faction.playerReputation >= (aug.baseRepRequirement * faction.augmentationRepRequirementMult)) { if (faction.playerReputation >= (aug.baseRepRequirement * faction.augmentationRepRequirementMult)) {
aElem.setAttribute("class", "a-link-button"); aElem.setAttribute("class", "a-link-button");
pElem.innerHTML = "UNLOCKED"; pElem.innerHTML = "UNLOCKED";
//Might need to set color? Should be the green by default though...
//TODO Event listener for button to purchase augmentation //TODO Event listener for button to purchase augmentation
} else { } else {
aElem.setAttribute("class", "a-link-button-inactive"); aElem.setAttribute("class", "a-link-button-inactive");
pElem.innerHTML = "LOCKED"; pElem.innerHTML = "LOCKED";
pElem.style.color = red; pElem.style.color = "red";
} }
aElem.style.display = "inline-block";
pElem.style.display = "inline-block";
aElem.innerHTML = aug.name; aElem.innerHTML = aug.name;
span.appendChild(aElem); span.appendChild(aElem);

@ -125,6 +125,7 @@ function PlayerObject() {
this.createProgramName = ""; this.createProgramName = "";
this.timeWorked = 0; //in ms this.timeWorked = 0; //in ms
this.timeNeededToCompleteWork = 0;
this.work_money_mult = 1; this.work_money_mult = 1;
@ -368,6 +369,7 @@ PlayerObject.prototype.startWork = function() {
this.workMoneyGained = 0; this.workMoneyGained = 0;
this.timeWorked = 0; this.timeWorked = 0;
this.timeNeededToCompleteWork = CONSTANTS.MillisecondsPer8Hours;
var cancelButton = document.getElementById("work-in-progress-cancel-button"); var cancelButton = document.getElementById("work-in-progress-cancel-button");
@ -400,7 +402,7 @@ PlayerObject.prototype.work = function(numCycles) {
//If timeWorked == 8 hours, then finish. You can only gain 8 hours worth of exp and money //If timeWorked == 8 hours, then finish. You can only gain 8 hours worth of exp and money
if (this.timeWorked >= CONSTANTS.MillisecondsPer8Hours) { if (this.timeWorked >= CONSTANTS.MillisecondsPer8Hours) {
var maxCycles = CONSTANTS.GameCyclesPer8Hours; //Number of cycles in 8 hours var maxCycles = CONSTANTS.GameCyclesPer8Hours;
this.workHackExpGained = this.workHackExpGainRate * maxCycles; this.workHackExpGained = this.workHackExpGainRate * maxCycles;
this.workStrExpGained = this.workStrExpGainRate * maxCycles; this.workStrExpGained = this.workStrExpGainRate * maxCycles;
this.workDefExpGained = this.workDefExpGainRate * maxCycles; this.workDefExpGained = this.workDefExpGainRate * maxCycles;
@ -483,6 +485,7 @@ PlayerObject.prototype.startFactionWork = function(faction) {
this.workMoneyGained = 0; this.workMoneyGained = 0;
this.timeWorked = 0; this.timeWorked = 0;
this.timeNeededToCompleteWork = CONSTANTS.MillisecondsPer20Hours;
var cancelButton = document.getElementById("work-in-progress-cancel-button"); var cancelButton = document.getElementById("work-in-progress-cancel-button");
@ -562,7 +565,7 @@ PlayerObject.prototype.workForFaction = function(numCycles) {
//If timeWorked == 20 hours, then finish. You can only work for the faction for 20 hours //If timeWorked == 20 hours, then finish. You can only work for the faction for 20 hours
if (this.timeWorked >= CONSTANTS.MillisecondsPer20Hours) { if (this.timeWorked >= CONSTANTS.MillisecondsPer20Hours) {
var maxCycles = CONSTANTS.GameCyclesPer20Hours; //Number of cycles in 20 hours var maxCycles = CONSTANTS.GameCyclesPer20Hours;
this.workHackExpGained = this.workHackExpGainRate * maxCycles; this.workHackExpGained = this.workHackExpGainRate * maxCycles;
this.workStrExpGained = this.workStrExpGainRate * maxCycles; this.workStrExpGained = this.workStrExpGainRate * maxCycles;
this.workDefExpGained = this.workDefExpGainRate * maxCycles; this.workDefExpGained = this.workDefExpGainRate * maxCycles;
@ -579,7 +582,7 @@ PlayerObject.prototype.workForFaction = function(numCycles) {
"You have been doing this for " + convertTimeMsToTimeElapsedString(this.timeWorked) + "<br><br>" + "You have been doing this for " + convertTimeMsToTimeElapsedString(this.timeWorked) + "<br><br>" +
"You have earned: <br><br>" + "You have earned: <br><br>" +
"$" + this.workMoneyGained + " (" + (this.workMoneyGainRate * cyclesPerSec).toFixed(2) + " / sec) <br><br>" + "$" + this.workMoneyGained + " (" + (this.workMoneyGainRate * cyclesPerSec).toFixed(2) + " / sec) <br><br>" +
this.workRepGained.toFixed(3) + " (" + (this.workRepGainRate * cyclesPerSec).toFixed(3) + " / sec) reputation for this company <br><br>" + this.workRepGained.toFixed(3) + " (" + (this.workRepGainRate * cyclesPerSec).toFixed(3) + " / sec) reputation for this faction <br><br>" +
this.workHackExpGained.toFixed(3) + " (" + (this.workHackExpGainRate * cyclesPerSec).toFixed(3) + " / sec) hacking exp <br><br>" + this.workHackExpGained.toFixed(3) + " (" + (this.workHackExpGainRate * cyclesPerSec).toFixed(3) + " / sec) hacking exp <br><br>" +
this.workStrExpGained.toFixed(3) + " (" + (this.workStrExpGainRate * cyclesPerSec).toFixed(3) + " / sec) strength exp <br>" + this.workStrExpGained.toFixed(3) + " (" + (this.workStrExpGainRate * cyclesPerSec).toFixed(3) + " / sec) strength exp <br>" +
this.workDefExpGained.toFixed(3) + " (" + (this.workDefExpGainRate * cyclesPerSec).toFixed(3) + " / sec) defense exp <br>" + this.workDefExpGained.toFixed(3) + " (" + (this.workDefExpGainRate * cyclesPerSec).toFixed(3) + " / sec) defense exp <br>" +
@ -587,8 +590,8 @@ PlayerObject.prototype.workForFaction = function(numCycles) {
this.workAgiExpGained.toFixed(3) + " (" + (this.workAgiExpGainRate * cyclesPerSec).toFixed(3) + " / sec) agility exp <br><br> " + this.workAgiExpGained.toFixed(3) + " (" + (this.workAgiExpGainRate * cyclesPerSec).toFixed(3) + " / sec) agility exp <br><br> " +
this.workChaExpGained.toFixed(3) + " (" + (this.workChaExpGainRate * cyclesPerSec).toFixed(3) + " / sec) charisma exp <br><br>" + this.workChaExpGained.toFixed(3) + " (" + (this.workChaExpGainRate * cyclesPerSec).toFixed(3) + " / sec) charisma exp <br><br>" +
"You will automatically finish after working for 8 hours. You can cancel earlier if you wish.<br>" + "You will automatically finish after working for 20 hours. You can cancel earlier if you wish.<br>" +
"There is no penalty for cancelling earlier"; "There is no penalty for cancelling earlier.";
} }
@ -663,10 +666,11 @@ PlayerObject.prototype.getFactionFieldWorkRepGain = function() {
} }
/* Creating a Program */ /* Creating a Program */
PlayerObject.prototype.startCreateProgramWork = function(programName) { PlayerObject.prototype.startCreateProgramWork = function(programName, time) {
this.isWorking = true; this.isWorking = true;
this.timeWorked = 0; this.timeWorked = 0;
this.timeNeededToCompleteWork = time;
this.currentWorkFactionName = ""; this.currentWorkFactionName = "";
this.currentWorkFactionDescription = ""; this.currentWorkFactionDescription = "";
@ -691,18 +695,14 @@ PlayerObject.prototype.createProgramWork = function(numCycles) {
this.timeWorked += Engine._idleSpeed * numCycles; this.timeWorked += Engine._idleSpeed * numCycles;
var programName = this.createProgramName; var programName = this.createProgramName;
//If timeWorked == 10 hours, then finish if (this.timeWorked >= this.timeNeededToCompleteWork) {
//Creating a program will take a flat 10 hours for now. We can make this variable based
//on skill level later
var timeToComplete = 36000000;
if (this.timeWorked >= timeToComplete) {
this.finishCreateProgramWork(false, programName); this.finishCreateProgramWork(false, programName);
} }
var txt = document.getElementById("work-in-progress-text"); var txt = document.getElementById("work-in-progress-text");
txt.innerHTML = "You are currently working on coding " + programName + ".<br><br> " + txt.innerHTML = "You are currently working on coding " + programName + ".<br><br> " +
"You have been working for " + convertTimeMsToTimeElapsedString(this.timeWorked) + "<br><br>" + "You have been working for " + convertTimeMsToTimeElapsedString(this.timeWorked) + "<br><br>" +
"The program is " + (this.timeWorked / timeToComplete).toFixed(2) + "% complete. <br>" + "The program is " + (this.timeWorked / this.timeNeededToCompleteWork * 100).toFixed(2) + "% complete. <br>" +
"If you cancel, you will lose all of your progress."; "If you cancel, you will lose all of your progress.";
} }

@ -13,17 +13,16 @@ purchaseServer = function(ram, cost) {
return; return;
} }
//Create server //Create server
newServ.init(createRandomIp(), hostname, "", true, false, true, true, ram); newServ.init(createRandomIp(), hostname, "", true, false, true, true, ram);
AddToAllServers(newServ); AddToAllServers(newServ);
//Add to Player's purchasedServers array //Add to Player's purchasedServers array
Player.purchasedServers.push(newServ); Player.purchasedServers.push(newServ.ip);
//Connect new server to home computer //Connect new server to home computer
var homeComputer = Player.getHomeComputer(); var homeComputer = Player.getHomeComputer();
homeComputer.serversOnNetwork.push(newServ); homeComputer.serversOnNetwork.push(newServ.ip);
Player.money -= cost; Player.money -= cost;

@ -493,12 +493,13 @@ var Terminal = {
//Contains the implementations of all possible programs //Contains the implementations of all possible programs
executeProgram: function(programName) { executeProgram: function(programName) {
switch (programName) { switch (programName) {
var s = Player.getCurrentServer();
case Programs.NukeProgram: case Programs.NukeProgram:
if (Player.getCurrentServer().hasAdminRights) { if (s.hasAdminRights) {
post("You already have root access to this computer. There is no reason to run NUKE.exe"); post("You already have root access to this computer. There is no reason to run NUKE.exe");
} else { } else {
if (Player.getCurrentServer().openPortCount >= Player.getCurrentServer().numOpenPortsRequired) { if (s.openPortCount >= Player.getCurrentServer().numOpenPortsRequired) {
Player.getCurrentServer().hasAdminRights = true; s.hasAdminRights = true;
post("NUKE successful! Gained root access to " + Player.getCurrentServer().hostname); post("NUKE successful! Gained root access to " + Player.getCurrentServer().hostname);
//TODO Make this take time rather than be instant //TODO Make this take time rather than be instant
} else { } else {
@ -506,6 +507,61 @@ var Terminal = {
} }
} }
break; break;
case Programs.BruteSSHProgram:
if (s.hasAdminRights == false) {
post("Permission denied. You do not have root access to this computer.");
} else if (s.sshPortOpen) {
post("SSH Port (22) is already open!");
} else {
s.sshPortOpen = true;
post("Opened SSH Port(22)!")
++s.openPortCount;
}
break;
case Programs.FTPCrackProgram:
if (s.hasAdminRights == false) {
post("Permission denied. You do not have root access to this computer.");
} else if (s.ftpPortOpen) {
post("FTP Port (21) is already open!");
} else {
s.ftpPortOpen = true;
post("Opened FTP Port (21)!");
++s.openPortCount;
}
break;
case Programs.RelaySMTPProgram:
if (s.hasAdminRights == false) {
post("Permission denied. You do not have root access to this computer.");
} else if (s.smtpPortOpen) {
post("SMTP Port (25) is already open!");
} else {
s.smtpPortOpen = true;
post("Opened SMTP Port (25)!");
++s.openPortCount;
}
break;
case Programs.HTTPWormProgram:
if (s.hasAdminRights == false) {
post("permission denied. You do not have root access to this computer.");
} else if (s.httpPortOpen) {
post("HTTP Port (80) is already open!");
} else {
s.httpPortOpen = true;
post("Opened HTTP Port (80)!");
++s.openPortCount;
}
break;
case Programs.SQLInjectProgram:
if (s.hasAdminRights == false) {
post("permission denied. You do not have root access to this computer.");
} else if (s.sqlPortOpen) {
post("SQL Port (1433) is already open!");
} else {
s.sqlPortOpen = true;
post("Opened SQL Port (1433)!");
++s.openPortCount;
}
break;
default: default:
post("Executable not found"); post("Executable not found");
return; return;