Merge pull request #15 from danielyxie/dev

Dev v0.10
This commit is contained in:
danielyxie 2017-05-15 22:31:54 -05:00 committed by GitHub
commit 66e667be2b
8 changed files with 73 additions and 55 deletions

@ -40,3 +40,5 @@ Private beta feedback
covers some of the text
Now, only other suggestion before sleep would be to be able to buy multiple Hacknet upgrades in one click
6) - Maybe show total $ somewhere onscreen at all (or most) times. $/sec would also be good to know, depending on if you want the player to know that. Bottom of the menu on the left is an empty enough place to keep these.

@ -1,5 +1,5 @@
CONSTANTS = {
Version: "0.9",
Version: "0.10",
//Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience
//and the skill level formula in Player.js. Note that all this means it that when experience hits MAX_INT, then
@ -18,13 +18,13 @@ CONSTANTS = {
BaseCostForHacknetNodeCore: 1000000,
/* Hacknet Node constants */
HacknetNodeMoneyGainPerLevel: 0.75,
HacknetNodePurchaseNextMult: 1.35, //Multiplier when purchasing an additional hacknet node
HacknetNodeMoneyGainPerLevel: 1,
HacknetNodePurchaseNextMult: 1.30, //Multiplier when purchasing an additional hacknet node
HacknetNodeUpgradeLevelMult: 1.06, //Multiplier for cost when upgrading level
HacknetNodeUpgradeRamMult: 1.25, //Multiplier for cost when upgrading RAM
HacknetNodeUpgradeCoreMult: 1.45, //Multiplier for cost when buying another core
HacknetNodeUpgradeRamMult: 1.20, //Multiplier for cost when upgrading RAM
HacknetNodeUpgradeCoreMult: 1.40, //Multiplier for cost when buying another core
HacknetNodeMaxLevel: 500,
HacknetNodeMaxLevel: 200,
HacknetNodeMaxRam: 64,
HacknetNodeMaxCores: 16,
@ -58,7 +58,7 @@ CONSTANTS = {
ServerGrowthRate: 1.00075,
//Maximum number of log entries for a script
MaxLogCapacity: 20,
MaxLogCapacity: 40,
//How much a TOR router costs
TorRouterCost: 100000,
@ -141,14 +141,12 @@ CONSTANTS = {
"ls Displays all programs and scripts on the machine<br>" +
"mem [script name] Displays the amount of RAM the script requires to run<br>" +
"nano [script name] Text editor - Open up and edit a script<br>" +
"netstat Displays all available network connections<br>" +
"ps Display all scripts that are currently running<br>" +
"rm Delete a script/program from the machine. (WARNING: Permanent)<br>" +
"run [script/program] Execute a program or a script<br>" +
"scan See 'netstat' command<br>" +
"scan Displays all available network connections<br>" +
"sudov Shows whether or not you have root access on this computer<br>" +
"tail [script] Display script logs (logs contain details about active scripts)<br>" +
"telnet [ip/hostname] See 'connect' command<br>" +
"top Display all running scripts and their RAM usage<br>",
/* Tutorial related things */

@ -18,8 +18,8 @@ HacknetNode.prototype.updateMoneyGainRate = function() {
//Each CPU core doubles the speed. Every 1GB of ram adds 15% increase
this.moneyGainRatePerSecond = (this.level * gainPerLevel) *
Math.pow(1.05, this.ram-1) *
this.numCores * Player.hacknet_node_money_mult;
Math.pow(1.07, this.ram-1) *
((this.numCores + 1) / 2) * Player.hacknet_node_money_mult;
if (isNaN(this.moneyGainRatePerSecond)) {
this.moneyGainRatePerSecond = 0;
dialogBoxCreate("Error in calculating Hacknet Node production. Please report to game developer");

@ -151,8 +151,7 @@ function iTutorialEvaluateStep() {
"on the computer. Right now, it shows that you have a program called 'NUKE.exe' on your computer. " +
"We'll get to what this does later. <br><br> Through your home computer's terminal, you can connect " +
"to other machines throughout the world. Let's do that now by first entering " +
"the 'scan' command (Alternatively, you can also enter the 'netstat' command " +
"which does the same thing). ");
"the 'scan' command. ");
//next step triggered by terminal command
break;
case iTutorialSteps.TerminalConnect:
@ -160,8 +159,7 @@ function iTutorialEvaluateStep() {
"it displays a list of all servers that can be connected to from your " +
"current machine. A server is identified by either its IP or its hostname. <br><br> " +
"To connect to a machine, use the 'connect [ip/hostname]' command. You can type in " +
"the ip or the hostname, but dont use both. (Alternatively, " +
"the 'telnet [ip/hostname]' command does the same thing).<br><br>" +
"the ip or the hostname, but dont use both.<br><br>" +
"Let's try this now by connecting to the 'foodnstuff' server (connect foodnstuff)");
//next step triggered by terminal command
break;

@ -433,6 +433,7 @@ PlayerObject.prototype.startWork = function() {
//Remove all old event listeners from Cancel button
var newCancelButton = clearEventListeners("work-in-progress-cancel-button");
newCancelButton.innerHTML = "Cancel Work";
newCancelButton.addEventListener("click", function() {
Player.finishWork(true);
return false;
@ -508,6 +509,7 @@ PlayerObject.prototype.startWorkPartTime = function() {
this.timeNeededToCompleteWork = CONSTANTS.MillisecondsPer8Hours;
var newCancelButton = clearEventListeners("work-in-progress-cancel-button");
newCancelButton.innerHTML = "Stop Working";
newCancelButton.addEventListener("click", function() {
Player.finishWorkPartTime();
return false;
@ -632,13 +634,9 @@ PlayerObject.prototype.startFactionWork = function(faction) {
this.timeNeededToCompleteWork = CONSTANTS.MillisecondsPer20Hours;
var cancelButton = document.getElementById("work-in-progress-cancel-button");
//Remove all old event listeners from Cancel button
var newCancelButton = cancelButton.cloneNode(true);
cancelButton.parentNode.replaceChild(newCancelButton, cancelButton);
newCancelButton.addEventListener("click", function() {
var cancelButton = clearEventListeners("work-in-progress-cancel-button");
cancelButton.innerHTML = "Stop Faction Work";
cancelButton.addEventListener("click", function() {
Player.finishFactionWork(true, faction);
return false;
});
@ -836,13 +834,9 @@ PlayerObject.prototype.startCreateProgramWork = function(programName, time) {
this.createProgramName = programName;
var cancelButton = document.getElementById("work-in-progress-cancel-button");
//Remove all old event listeners from Cancel button
var newCancelButton = cancelButton.cloneNode(true);
cancelButton.parentNode.replaceChild(newCancelButton, cancelButton);
newCancelButton.addEventListener("click", function() {
var cancelButton = clearEventListeners("work-in-progress-cancel-button");
cancelButton.innerHTML = "Cancel work on creating program";
cancelButton.addEventListener("click", function() {
Player.finishCreateProgramWork(true, programName);
return false;
});
@ -957,13 +951,16 @@ PlayerObject.prototype.startClass = function(costMult, expMult, className) {
this.workAgiExpGainRate = agiExp * this.agility_exp_mult;
this.workChaExpGainRate = chaExp * this.charisma_exp_mult;
var cancelButton = document.getElementById("work-in-progress-cancel-button");
//Remove all old event listeners from Cancel button
var newCancelButton = cancelButton.cloneNode(true);
cancelButton.parentNode.replaceChild(newCancelButton, cancelButton);
newCancelButton.addEventListener("click", function() {
var cancelButton = clearEventListeners("work-in-progress-cancel-button");
if (className == CONSTANTS.ClassGymStrength ||
className == CONSTANTS.ClassGymDefense ||
className == CONSTANTS.ClassGymDexterity ||
className == CONSTANTS.ClassGymAgility) {
cancelButton.innerHTML = "Stop training at gym";
} else {
cancelButton.innerHTML = "Stop taking course";
}
cancelButton.addEventListener("click", function() {
Player.finishClass();
return false;
});
@ -1049,6 +1046,7 @@ PlayerObject.prototype.startCrime = function(hackExp, strExp, defExp, dexExp, ag
//Remove all old event listeners from Cancel button
var newCancelButton = clearEventListeners("work-in-progress-cancel-button")
newCancelButton.innerHTML = "Cancel crime"
newCancelButton.addEventListener("click", function() {
Player.finishCrime(true);
return false;

@ -3,16 +3,29 @@
*/
//Initialize the 'save and close' button on script editor page
function scriptEditorSaveCloseInit() {
function scriptEditorInit() {
var closeButton = document.getElementById("script-editor-save-and-close-button");
closeButton.addEventListener("click", function() {
saveAndCloseScriptEditor();
return false;
});
var textareas = document.getElementsByTagName('textarea');
var count = textareas.length;
for(var i=0;i<count;i++){
textareas[i].onkeydown = function(e){
if(e.keyCode==9 || e.which==9){
e.preventDefault();
var s = this.selectionStart;
this.value = this.value.substring(0,this.selectionStart) + "\t" + this.value.substring(this.selectionEnd);
this.selectionEnd = s+1;
}
}
}
};
document.addEventListener("DOMContentLoaded", scriptEditorSaveCloseInit, false);
document.addEventListener("DOMContentLoaded", scriptEditorInit, false);
//Define key commands in script editor (ctrl o to save + close, etc.)
$(document).keydown(function(e) {
@ -32,8 +45,8 @@ function saveAndCloseScriptEditor() {
return;
}
var code = document.getElementById("script-editor-text").value;
code = code.replace(/\s\s+/g, '');
if (code.indexOf("while(true) {hack('foodnstuff');}") == -1) {
code = code.replace(/\s/g, "");
if (code.indexOf("while(true){hack('foodnstuff');}") == -1) {
dialogBoxCreate("Please copy and paste the code from the tutorial!");
return;
}
@ -112,7 +125,7 @@ Script.prototype.saveScript = function() {
if (Engine.currentPage == Engine.Page.ScriptEditor) {
//Update code and filename
var code = document.getElementById("script-editor-text").value;
this.code = code;
this.code = code.replace(/^\s+|\s+$/g, '');
var filename = document.getElementById("script-editor-filename").value + ".script";
this.filename = filename;

@ -27,6 +27,15 @@ var postNetburnerText = function() {
post("Bitburner v" + CONSTANTS.Version);
}
/*
$(document).keyup(function(event) {
//Enter
if (event.keyCode == 13) {
}
});
*/
//Defines key commands in terminal
$(document).keydown(function(event) {
//Terminal
@ -36,6 +45,7 @@ $(document).keydown(function(event) {
//Enter
if (event.keyCode == 13) {
event.preventDefault();
var command = $('input[class=terminal-input]').val();
if (command.length > 0) {
post("> " + command);
@ -364,19 +374,19 @@ var Terminal = {
if (commandArray[0] == "help") {
post(CONSTANTS.HelpText);
iTutorialNextStep();
} else {post("Wrong command! Try again!");}
} else {post("Bad command. Please follow the tutorial");}
break;
case iTutorialSteps.TerminalLs:
if (commandArray[0] == "ls") {
Terminal.executeListCommand(commandArray);
iTutorialNextStep();
} else {post("Wrong command! Try again!");}
} else {post("Bad command. Please follow the tutorial");}
break;
case iTutorialSteps.TerminalScan:
if (commandArray[0] == "scan") {
Terminal.executeScanCommand(commandArray);
iTutorialNextStep();
} else {post("Wrong command! Try again!");}
} else {post("Bad command. Please follow the tutorial");}
break;
case iTutorialSteps.TerminalConnect:
@ -389,7 +399,7 @@ var Terminal = {
post("Connected to foodnstuff");
iTutorialNextStep();
} else {post("Wrong command! Try again!"); return;}
} else {post("Wrong command! Try again!");}
} else {post("Bad command. Please follow the tutorial");}
break;
case iTutorialSteps.TerminalAnalyze:
if (commandArray[0] == "analyze") {
@ -408,7 +418,7 @@ var Terminal = {
$('input[class=terminal-input]').prop('disabled', true);
iTutorialNextStep();
} else {
post("Wrong command! Try again!");
post("Bad command. Please follow the tutorial");
}
break;
case iTutorialSteps.TerminalNuke:
@ -417,7 +427,7 @@ var Terminal = {
foodnstuffServ.hasAdminRights = true;
post("NUKE successful! Gained root access to foodnstuff");
iTutorialNextStep();
} else {post("Wrong command! Try again!");}
} else {post("Bad command. Please follow the tutorial");}
break;
case iTutorialSteps.TerminalManualHack:
if (commandArray.length == 1 && commandArray[0] == "hack") {
@ -430,14 +440,14 @@ var Terminal = {
document.getElementById("terminal-input-td").innerHTML = '<input type="text" class="terminal-input"/>';
$('input[class=terminal-input]').prop('disabled', true);
iTutorialNextStep();
} else {post("Wrong command! Try again!");}
} else {post("Bad command. Please follow the tutorial");}
break;
case iTutorialSteps.TerminalCreateScript:
if (commandArray.length == 2 &&
commandArray[0] == "nano" && commandArray[1] == "foodnstuff.script") {
Engine.loadScriptEditorContent("foodnstuff", "");
iTutorialNextStep();
} else {post("Wrong command! Try again!");}
} else {post("Bad command. Please follow the tutorial");}
case iTutorialSteps.TerminalFree:
if (commandArray.length == 1 && commandArray[0] == "free") {
Terminal.executeFreeCommand(commandArray);
@ -449,7 +459,7 @@ var Terminal = {
commandArray[0] == "run" && commandArray[1] == "foodnstuff.script") {
Terminal.runScript("foodnstuff.script");
iTutorialNextStep();
} else {post("Wrong command! Try again!");}
} else {post("Bad command. Please follow the tutorial");}
break;
case iTutorialSteps.ActiveScriptsToTerminal:
if (commandArray.length == 2 &&
@ -461,7 +471,7 @@ var Terminal = {
}
}
iTutorialNextStep();
} else {post("Wrong command! Try again!");}
} else {post("Bad command. Please follow the tutorial");}
break;
default:
post("Please follow the tutorial, or click 'Exit Tutorial' if you'd like to skip it");
@ -501,7 +511,6 @@ var Terminal = {
postNetburnerText();
break;
case "connect":
case "telnet":
//Disconnect from current server in terminal and connect to new one
if (commandArray.length != 2) {
post("Incorrect usage of connect/telnet command. Usage: connect/telnet [ip/hostname]");
@ -644,7 +653,6 @@ var Terminal = {
}
Engine.loadScriptEditorContent(scriptname, "");
break;
case "netstat":
case "scan":
Terminal.executeScanCommand(commandArray);
break;

@ -110,6 +110,7 @@ var Engine = {
document.getElementById("script-editor-filename").value = filename;
}
document.getElementById("script-editor-text").value = code;
document.getElementById("script-editor-text").focus();
Engine.currentPage = Engine.Page.ScriptEditor;
},