diff --git a/src/Player.js b/src/Player.js
index 3950ea3b9..6accbc652 100644
--- a/src/Player.js
+++ b/src/Player.js
@@ -39,9 +39,14 @@ var Player = {
total_money: 0,
lifetime_money: 0,
+ //Starting (home) computer
+ homeComputer = new Server();
+ startingServer.init("19.42.93.219", "home.pc", true, true, true, true, 2);
+
//Servers
- //discoveredServers = [],
- //purchasedServers = [],
+ currentServer = homeComputer, //Server currently being accessed through terminal
+ discoveredServers = [],
+ purchasedServers = [],
//Achievements and achievement progress
diff --git a/src/Server.js b/src/Server.js
index 38fdbf3e0..c4c2fd7c6 100644
--- a/src/Server.js
+++ b/src/Server.js
@@ -1,19 +1,54 @@
//Netburner Server class
-// Parent class for a Server object. PlayerServer and NPCServer inherit from this
-var Server = {
+function Server() = {
+ /* Properties */
//Connection information
- ip: "0.0.0.0",
- isOnline: false,
+ this.ip: "0.0.0.0",
+ this.hostname: "",
+ this.isOnline: true,
+ this.isConnectedTo: false, //Whether the player is connected to this server
- ownedByPlayer: false,
+ //Access information
+ this.hasAdminRights: false, //Whether player has admin rights
+ this.purchasedByPlayer: false,
- //Properties
- max_ram: 1, //GB
- ram_used: 0,
+ //RAM and Scripts
+ maxRam: 1, //GB
+ ramUsed: 0,
- //scripts = [],
+ scripts = [],
+ runningScripts = [], //Scripts currently being run
+ programs = [],
- //Manual hack state information
- is_hacking: false,
- hacking_progress: 0,
-};
\ No newline at end of file
+ /* Hacking information (only valid for "foreign" aka non-purchased servers) */
+
+ //Skill required to attempt a hack. Whether a hack is successful will be determined
+ //by a separate formula
+ requiredHackingSkill = 1,
+
+ //Total money available on this server. How much of this you hack will be determined
+ //by a formula related to hacking skill. The money available on a server will steadily increase
+ //over time, and it will decrease when you hack it
+ moneyAvailable = 500,
+
+
+ //Manual hack state information (hacking done without script)
+ isHacking: false,
+ hackingProgress: 0,
+};
+
+//Initialize the properties of a server
+Server.prototype.init = function(ip, hostname, onlineStatus, isConnectedTo, adminRights, purchasedByPlayer, maxRam) {
+ this.ip = ip;
+ this.hostname = hostname;
+ this.isOnline = onlineStatus;
+ this.isConnectedTo = isConnectedTo;
+ this.hasAdminRights = adminRights;
+ this.purchasedByPlayer = purchasedByPlayer;
+ this.maxRam = maxRam;
+}
+
+//Create all "foreign" servers that exist in the game. This does not include
+//servers that the player can purchase or the player's starting computer
+function initAllServers() {
+
+}
\ No newline at end of file
diff --git a/src/Terminal.js b/src/Terminal.js
index a7744526a..154c123f3 100644
--- a/src/Terminal.js
+++ b/src/Terminal.js
@@ -10,9 +10,10 @@ $(document).keyup(function(event) {
var command = $('input[class=terminal-input]').val();
if (command.length > 0) {
post("> " + command);
- $('input[class=terminal-input]').val("");
- //Execute command function here
+ //TODO Do i have to switch the order of these two?
+ executeCommand(command);
+ $('input[class=terminal-input]').val("");
}
}
});
@@ -25,6 +26,60 @@ var executeCommand = function(command) {
}
switch (commandArray[0]) {
- case
+ case "analyze":
+ //TODO Analyze the system for ports
+ break;
+ case "clear":
+ case "cls":
+ //TODO
+ break;
+ case "connect":
+ //TODO Disconnect from current server in terminal and connect to new one
+ break;
+ case "df":
+ //TODO
+ break;
+ case "hack":
+ //TODO Hack the current PC (usually for money)
+ //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 {
+
+ }
+ break;
+ case "help":
+ //TODO
+ break;
+ case "hostname":
+ //Print the hostname of current system
+ post(Player.currentServer.hostname);
+ break;
+ case "ifconfig":
+ //Print the IP address of the current system
+ post(Player.currentServer.ip);
+ break;
+ case "kill":
+ //TODO
+ break;
+ case "ls":
+ //TODO
+ break;
+ case "ps":
+ //TODO
+ break;
+ case "rm":
+ //TODO
+ break;
+ case "run":
+ //TODO
+ break;
+ case "scan":
+ //TODO
+ break;
}
-}
\ No newline at end of file
+}
+
+var runProgram = function(programName) {
+
+}
diff --git a/src/engine.js b/src/engine.js
index 946b18fd7..bbeb8e9ff 100644
--- a/src/engine.js
+++ b/src/engine.js
@@ -87,6 +87,7 @@ var Engine = {
loadTerminalContent: function() {
Engine.hideAllContent();
Engine.Display.terminalContent.style.visibility = "visible";
+ post("Netburner v1.0");
},
loadCharacterContent: function() {
@@ -108,7 +109,8 @@ var Engine = {
'Strength: ' + Player.strength + '
' +
'Defense: ' + Player.defense + '
' +
'Dexterity: ' + Player.dexterity + '
' +
- 'Agility: ' + Player.agility + '
';
+ 'Agility: ' + Player.agility + '
' +
+ 'Servers owned: ' + Player.purchasedServers.length +
';
},
/* Main Event Loop */
@@ -139,24 +141,6 @@ var Engine = {
/* Initialization */
init: function() {
- //Hacking button
- //Engine.Clickables.hackButton = document.getElementById("hackbutton");
-
- //Event Listener for hacking button
- //Engine.Clickables.hackButton.addEventListener("click", function() {
- // ++Player.hacking_skill;
-
- //Returns false so that once the code runs, the button won't try to do
- //anything else
- // return false;
- //});
-
- //Hacking Skill Display
- //Engine.Display.hacking_skill = document.getElementById("hackingskill");
-
- //Status display
- //Engine.Display.statusText = document.getElementById("status");
-
//Load, save, and delete buttons
//Engine.Clickables.saveButton = document.getElementById("save");
//Engine.Clickables.saveButton.addEventListener("click", function() {