Added cases for all the commands that will be implemented for now. Updated Server class to contain information about servers, home computer, etc. Added a few fields to Server that will be used when hacking, as well as constructor.

This commit is contained in:
Daniel Xie
2016-10-17 16:23:23 -05:00
parent 7c03b274d7
commit a1fd46232e
4 changed files with 117 additions and 38 deletions
+48 -13
View File
@@ -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,
};
/* 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() {
}