Added a few more commands to Terminal (not the implementation). Began defining some of the foreign servers that will exist

This commit is contained in:
Daniel Xie 2016-10-18 16:37:53 -05:00
parent a1fd46232e
commit 47e19f5862
3 changed files with 58 additions and 18 deletions

@ -41,7 +41,7 @@ var Player = {
//Starting (home) computer
homeComputer = new Server();
startingServer.init("19.42.93.219", "home.pc", true, true, true, true, 2);
startingServer.init("19.42.93.219", "home", "Home PC", true, true, true, true, 2);
//Servers
currentServer = homeComputer, //Server currently being accessed through terminal

@ -4,6 +4,7 @@ function Server() = {
//Connection information
this.ip: "0.0.0.0",
this.hostname: "",
this.organizationName: "",
this.isOnline: true,
this.isConnectedTo: false, //Whether the player is connected to this server
@ -11,35 +12,41 @@ function Server() = {
this.hasAdminRights: false, //Whether player has admin rights
this.purchasedByPlayer: false,
//RAM and Scripts
maxRam: 1, //GB
ramUsed: 0,
//RAM, CPU speed and Scripts
this.maxRam: 1, //GB
this.ramUsed: 0,
this.cpuSpeed: 1, //MHz
scripts = [],
runningScripts = [], //Scripts currently being run
programs = [],
this.scripts = [],
this.runningScripts = [], //Scripts currently being run
this.programs = [],
/* 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,
this.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,
this.moneyAvailable = 500,
//Parameters used in formulas that dictate how moneyAvailable and requiredHackingSkill change.
this.hackDifficulty = 1, //Affects hack success rate and how the requiredHackingSkill increases over time
this.serverGrowth = 1, //Affects how the moneyAvailable increases
this.timesHacked = 0,
//Manual hack state information (hacking done without script)
isHacking: false,
hackingProgress: 0,
this.isHacking: false,
this.hackingProgress: 0,
};
//Initialize the properties of a server
Server.prototype.init = function(ip, hostname, onlineStatus, isConnectedTo, adminRights, purchasedByPlayer, maxRam) {
Server.prototype.init = function(ip, hostname, organizationName, onlineStatus, isConnectedTo, adminRights, purchasedByPlayer, maxRam) {
this.ip = ip;
this.hostname = hostname;
this.organizationName = organizationName;
this.isOnline = onlineStatus;
this.isConnectedTo = isConnectedTo;
this.hasAdminRights = adminRights;
@ -47,8 +54,34 @@ Server.prototype.init = function(ip, hostname, onlineStatus, isConnectedTo, admi
this.maxRam = maxRam;
}
//Set the hacking properties of a server
Server.prototype.setHackingParameters(requiredHackingSkill, moneyAvailable, hackDifficulty, serverGrowth) {
this.requiredHackingSkill = requiredHackingSkill;
this.moneyAvailable = moneyAvailable;
this.hackDifficulty = hackDifficulty;
this.serverGrowth = serverGrowth;
}
createRandomIp : function() = {
//TODO
}
//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() {
ForeignServers = {
//Megacorporations
ECorp: new Server();
//Technology and communication companies
FulcrumTechnologies: new Server();
StormTechnologies: new Server();
DedComm: new Server();
//Gyms
CrushFitnessGym: new Server();
IronGym: new Server();
MilleniumFitnessGym: new Server();
PowerhouseGym: new Server();
SnapFitnessGym: new Server();
}
}

@ -12,13 +12,13 @@ $(document).keyup(function(event) {
post("> " + command);
//TODO Do i have to switch the order of these two?
executeCommand(command);
Terminal.executeCommand(command);
$('input[class=terminal-input]').val("");
}
}
});
var executeCommand = function(command) {
var Terminal.executeCommand = function(command) {
var commandArray = command.split();
if (commandArray.length == 0) {
@ -34,7 +34,7 @@ var executeCommand = function(command) {
//TODO
break;
case "connect":
//TODO Disconnect from current server in terminal and connect to new one
//TODO Disconnect from current server in terminal and connect to new one..maybe rename this to telnet?
break;
case "df":
//TODO
@ -65,6 +65,8 @@ var executeCommand = function(command) {
case "ls":
//TODO
break;
case "netstat":
//TODO Displays available network connections using TCP
case "ps":
//TODO
break;
@ -77,9 +79,14 @@ var executeCommand = function(command) {
case "scan":
//TODO
break;
case "scp":
//TODO
break;
default:
}
}
var runProgram = function(programName) {
var Terminal.runProgram = function(programName) {
}