mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-22 22:22:26 +01:00
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:
parent
7c03b274d7
commit
a1fd46232e
@ -39,9 +39,14 @@ var Player = {
|
|||||||
total_money: 0,
|
total_money: 0,
|
||||||
lifetime_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
|
//Servers
|
||||||
//discoveredServers = [],
|
currentServer = homeComputer, //Server currently being accessed through terminal
|
||||||
//purchasedServers = [],
|
discoveredServers = [],
|
||||||
|
purchasedServers = [],
|
||||||
|
|
||||||
//Achievements and achievement progress
|
//Achievements and achievement progress
|
||||||
|
|
||||||
|
@ -1,19 +1,54 @@
|
|||||||
//Netburner Server class
|
//Netburner Server class
|
||||||
// Parent class for a Server object. PlayerServer and NPCServer inherit from this
|
function Server() = {
|
||||||
var Server = {
|
/* Properties */
|
||||||
//Connection information
|
//Connection information
|
||||||
ip: "0.0.0.0",
|
this.ip: "0.0.0.0",
|
||||||
isOnline: false,
|
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
|
//RAM and Scripts
|
||||||
max_ram: 1, //GB
|
maxRam: 1, //GB
|
||||||
ram_used: 0,
|
ramUsed: 0,
|
||||||
|
|
||||||
//scripts = [],
|
scripts = [],
|
||||||
|
runningScripts = [], //Scripts currently being run
|
||||||
|
programs = [],
|
||||||
|
|
||||||
//Manual hack state information
|
/* Hacking information (only valid for "foreign" aka non-purchased servers) */
|
||||||
is_hacking: false,
|
|
||||||
hacking_progress: 0,
|
//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() {
|
||||||
|
|
||||||
|
}
|
@ -10,9 +10,10 @@ $(document).keyup(function(event) {
|
|||||||
var command = $('input[class=terminal-input]').val();
|
var command = $('input[class=terminal-input]').val();
|
||||||
if (command.length > 0) {
|
if (command.length > 0) {
|
||||||
post("> " + command);
|
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]) {
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var runProgram = function(programName) {
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -87,6 +87,7 @@ var Engine = {
|
|||||||
loadTerminalContent: function() {
|
loadTerminalContent: function() {
|
||||||
Engine.hideAllContent();
|
Engine.hideAllContent();
|
||||||
Engine.Display.terminalContent.style.visibility = "visible";
|
Engine.Display.terminalContent.style.visibility = "visible";
|
||||||
|
post("Netburner v1.0");
|
||||||
},
|
},
|
||||||
|
|
||||||
loadCharacterContent: function() {
|
loadCharacterContent: function() {
|
||||||
@ -108,7 +109,8 @@ var Engine = {
|
|||||||
'Strength: ' + Player.strength + '<br><br>' +
|
'Strength: ' + Player.strength + '<br><br>' +
|
||||||
'Defense: ' + Player.defense + '<br><br>' +
|
'Defense: ' + Player.defense + '<br><br>' +
|
||||||
'Dexterity: ' + Player.dexterity + '<br><br>' +
|
'Dexterity: ' + Player.dexterity + '<br><br>' +
|
||||||
'Agility: ' + Player.agility + '<br><br>';
|
'Agility: ' + Player.agility + '<br><br>' +
|
||||||
|
'Servers owned: ' + Player.purchasedServers.length + <br><br>';
|
||||||
},
|
},
|
||||||
|
|
||||||
/* Main Event Loop */
|
/* Main Event Loop */
|
||||||
@ -139,24 +141,6 @@ var Engine = {
|
|||||||
|
|
||||||
/* Initialization */
|
/* Initialization */
|
||||||
init: function() {
|
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
|
//Load, save, and delete buttons
|
||||||
//Engine.Clickables.saveButton = document.getElementById("save");
|
//Engine.Clickables.saveButton = document.getElementById("save");
|
||||||
//Engine.Clickables.saveButton.addEventListener("click", function() {
|
//Engine.Clickables.saveButton.addEventListener("click", function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user