From 4517020719bf0aefb93e3d3c0715378f89cdc692 Mon Sep 17 00:00:00 2001 From: Daniel Xie Date: Thu, 20 Oct 2016 16:34:21 -0500 Subject: [PATCH] Added some init functions to the engine's init(). Began writing out the hack function for servers --- src/Server.js | 8 ++++++++ src/Terminal.js | 6 +++++- src/engine.js | 3 +++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Server.js b/src/Server.js index 386c8f4db..dbe956249 100644 --- a/src/Server.js +++ b/src/Server.js @@ -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; diff --git a/src/Terminal.js b/src/Terminal.js index 3a11cbfd8..170a4869e 100644 --- a/src/Terminal.js +++ b/src/Terminal.js @@ -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": diff --git a/src/engine.js b/src/engine.js index b4ce39aca..e52beee23 100644 --- a/src/engine.js +++ b/src/engine.js @@ -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() {