Implemented df and cls/clear commands

This commit is contained in:
Daniel Xie
2016-10-20 16:11:01 -05:00
parent ce0ca6c24d
commit 4057f946d8
4 changed files with 18 additions and 7 deletions

View File

@ -53,9 +53,9 @@
})
</script>
<script src="src/Terminal.js"></script>
<script src="src/Server.js"></script>
<script src="src/Player.js"></script>
<script src="src/Terminal.js"></script>
<script src="src/engine.js"></script>
</body>
</html>

View File

@ -51,7 +51,7 @@ var Player = {
init: function() {
homeComputer.init("19.42.93.219", "home", "Home PC", true, true, true, true, 1);
currentServer = Player.homeComputer;
Player.homeComputer.init("19.42.93.219", "home", "Home PC", true, true, true, true, 1);
Player.currentServer = Player.homeComputer;
}
};

View File

@ -4,6 +4,10 @@ var post = function(input) {
window.scrollTo(0, document.body.scrollHeight);
}
var postNetburnerText = function() {
post("Netburner v1.0");
}
//command is checked on enter key press
$(document).keyup(function(event) {
if (event.keyCode == 13) {
@ -32,13 +36,17 @@ var Terminal = {
break;
case "clear":
case "cls":
//TODO
console.log("cls/clear command called");
$("#terminal tr:not(:last)").remove();
postNetburnerText();
break;
case "connect":
//TODO Disconnect from current server in terminal and connect to new one..maybe rename this to telnet?
break;
case "df":
//TODO
console.log("df command called");
var dfStr = Player.currentServer.ramUsed.toString() + " / " Player.currentServer.maxRam.toString() + "GB";
post(dfStr);
break;
case "hack":
//TODO Hack the current PC (usually for money)

View File

@ -87,7 +87,7 @@ var Engine = {
loadTerminalContent: function() {
Engine.hideAllContent();
Engine.Display.terminalContent.style.visibility = "visible";
post("Netburner v1.0");
postNetburnerText();
},
loadCharacterContent: function() {
@ -141,6 +141,9 @@ var Engine = {
/* Initialization */
init: function() {
//Initialize Player objects
Player.init();
//Load, save, and delete buttons
//Engine.Clickables.saveButton = document.getElementById("save");
//Engine.Clickables.saveButton.addEventListener("click", function() {
@ -182,7 +185,7 @@ var Engine = {
Engine.displayCharacterInfo();
//Message at the top of terminal
post("Netburner v1.0");
postNetburnerText();
//Run main loop
Engine.idleTimer();