Added some init functions to the engine's init(). Began writing out the hack function for servers

This commit is contained in:
Daniel Xie 2016-10-20 16:34:21 -05:00
parent 4057f946d8
commit 4517020719
3 changed files with 16 additions and 1 deletions

@ -57,6 +57,14 @@ Server.prototype.init = function(ip, hostname, organizationName, onlineStatus, i
this.maxRam = maxRam;
}
//Hack a server. Return the amount of money hacked.
//This assumes that the server being hacked is not purchased by the palyer, that the player's hacking skill is greater than the
//required hacking skill and that the player has admin rights.
Server.prototype.hack = function(hackingSkill) {
}
//Set the hacking properties of a server
Server.prototype.setHackingParameters = function(requiredHackingSkill, moneyAvailable, hackDifficulty, serverGrowth) {
this.requiredHackingSkill = requiredHackingSkill;

@ -53,8 +53,12 @@ var Terminal = {
//You can't hack your home pc or servers you purchased
if (Player.currentServer.purchasedByPlayer) {
post("Cannot hack your own machines! You are currently connected to your home PC or one of your purchased servers");
} else if (Player.currentServer.hasAdminRights == false ) {
post("You do not have admin rights for this machine! Cannot hack");
} else if (Player.currentServer.requiredHackingSkill > Player.hacking_skill) {
post("Your hacking skill is not high enough to attempt hacking this machine");
} else {
var hackResult = Player.currentServer.hack();
}
break;
case "help":

@ -144,6 +144,9 @@ var Engine = {
//Initialize Player objects
Player.init();
//Initialize foreign servers
ForeignServers.init();
//Load, save, and delete buttons
//Engine.Clickables.saveButton = document.getElementById("save");
//Engine.Clickables.saveButton.addEventListener("click", function() {