From 9e2344919f7388488d3587b5c6959b2af0942b4d Mon Sep 17 00:00:00 2001 From: Daniel Xie Date: Sat, 20 May 2017 22:45:36 -0500 Subject: [PATCH] Small UI changes, adding RAM cost for new script commands. --- README.md | 6 ------ css/interactivetutorial.css | 11 +++++++---- css/menupages.css | 14 +++++++------- css/styles.css | 23 +++++++++++++++++------ index.html | 4 ++++ src/Constants.js | 17 ++++++++++++++++- src/NetscriptEvaluator.js | 4 ++-- src/Script.js | 6 +++++- 8 files changed, 58 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index a79bc823e..f7ad97b72 100644 --- a/README.md +++ b/README.md @@ -35,11 +35,5 @@ Tasks TODO: Private beta feedback I'd suggest putting a "Back" button in the tutorial window, - -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. - -Donate to faction for reputatino - -Quick overview screen test for open beta \ No newline at end of file diff --git a/css/interactivetutorial.css b/css/interactivetutorial.css index 42cc96643..d46ebf875 100644 --- a/css/interactivetutorial.css +++ b/css/interactivetutorial.css @@ -1,14 +1,17 @@ /* interactivetutorial.css */ +#interactive-tutorial-wrapper { + position:relative; +} + #interactive-tutorial-container { display: none; - position: fixed; /* Stay in place */ + position: absolute; /* Stay in place */ right: 0; top: 0; - height: 100%; /* Full height */ - margin: 30% auto; + height: 400px; /* Full height */ padding: 10px; border: 5px solid #FFFFFF; - width: 35%; + width: 25%; overflow: auto; /* Enable scroll if needed */ background-color: #444; /* Fallback color */ color: white; diff --git a/css/menupages.css b/css/menupages.css index 2c9c1fb03..89b375388 100644 --- a/css/menupages.css +++ b/css/menupages.css @@ -39,7 +39,7 @@ #script-editor-save-and-close-button, #script-editor-netscript-doc-button { float: right; - display: inline-block; + display: block; width: 50%; margin-right: 25%; } @@ -56,7 +56,7 @@ float: left; resize: none; color: #66ff33; - width: 75%; + width: 70%; margin: 10px; padding: 5px; @@ -79,7 +79,7 @@ #script-editor-text { color: #66ff33; - width: 75%; + width: 70%; height: 100%; margin: 10px; padding: 5px; @@ -112,7 +112,7 @@ } #active-scripts-text { - width: 80%; + width: 70%; margin: 6px; padding: 4px; } @@ -155,7 +155,7 @@ #hacknet-nodes-text, #hacknet-nodes-money { - width: 80%; + width: 70%; margin: 10px; padding: 10px; } @@ -224,7 +224,7 @@ } #create-program-page-text { - width: 80%; + width: 70%; } .create-program-a-link-button { @@ -392,7 +392,7 @@ div.faction-clear { } #tutorial-text { - width: 80%; + width: 70%; margin: 10px; } diff --git a/css/styles.css b/css/styles.css index 6a0d0fb16..f0dedbd09 100644 --- a/css/styles.css +++ b/css/styles.css @@ -214,26 +214,37 @@ tr:focus { position:fixed; top:0px; -webkit-animation:status-text 3s 1; + background-color: transparent; +} + +#status-text-container { + background-color: transparent; } #status-text { font-size: 20px; color: #FFFFFF; right: 0; - bottom: 0; + bottom: 0; + padding: 4px; + background-color: transparent; + z-index: 2; } /* Character Overview */ +#character-overview-wrapper { + position: relative; +} #character-overview-container { display: none; - position: fixed; /* Stay in place */ + position: absolute; /* Stay in place */ right: 0; top: 0; - height: 100%; /* Full height */ - margin: 45% auto; + height: 250px; /* Full height */ + /*margin: 50% auto;*/ padding: 5px; border: 2px solid #66ff33; - width: 20%; + width: 18%; overflow: auto; /* Enable scroll if needed */ background-color: #444; /* Fallback color */ z-index: 1; @@ -241,7 +252,7 @@ tr:focus { #character-overview-text { padding: 4px; - margin: 4px; + margin: 12px; color: white; background-color: #444; } diff --git a/index.html b/index.html index b8d7e0a11..48a040d0c 100644 --- a/index.html +++ b/index.html @@ -716,17 +716,21 @@ +

Exit Tutorial Next Back
+
+

+
diff --git a/src/Constants.js b/src/Constants.js index a22bffda6..142e71b4c 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -48,10 +48,12 @@ CONSTANTS = { ScriptRelaysmtpRamCost: 0.05, ScriptHttpwormRamCost: 0.05, ScriptSqlinjectRamCost: 0.05, - ScriptRunRamCost: 0.75, + ScriptRunRamCost: 0.8, ScriptGetHackingLevelRamCost: 0.1, ScriptGetServerMoneyRamCost: 0.1, ScriptOperatorRamCost: 0.01, + ScriptPurchaseHacknetRamCost: 1.0, + ScriptUpgradeHacknetRamCost: 1.0, //Server growth rate ServerGrowthRate: 1.00075, @@ -266,6 +268,19 @@ CONSTANTS = { "getHackingLevel()
Returns the Player's current hacking level

" + "getServerMoneyAvailable(hostname/ip)
Returns the amount of money available on a server. The argument passed in must be a string with either the " + "hostname or IP of the target server.
Example: getServerMoneyAvailable('foodnstuff');

" + + "purchaseHacknetNode()
Purchases a new Hacknet Node. Returns a string with the name of the new Hacknet Node. If the player cannot afford to purchase " + + "a new hacknet node then the function will return an empty string

" + + "upgradeHacknetNode(name)
Upgrades the level of a Hacknet Node. The argument passed in must be a string with the name of the Hacknet Node to upgrade. " + + "If the Hacknet Node is successfully upgraded the function will return true. It will return false otherwise. Example:
" + + "var node = purchaseHacknetNode();
" + + "if (node != '') {
" + + "    var i = 0;
" + + "    while(i < 10) {
" + + "         if (upgradeHacknetNode(node)) {i = i + 1;}
" + + "    };
" + + "};

" + + "The example code above will attempt to purchase a new Hacknet Node. If the Hacknet Node is purchased, then it will " + + "continuously try to level it up until it is leveled up 10 times.

" + "

While loops


" + "A while loop is a control flow statement that repeatedly executes code as long as a condition is met.

" + "while ([cond]) {
    [code]
}


" + diff --git a/src/NetscriptEvaluator.js b/src/NetscriptEvaluator.js index 7e7a617ee..e7c7ee55e 100644 --- a/src/NetscriptEvaluator.js +++ b/src/NetscriptEvaluator.js @@ -720,7 +720,7 @@ function evaluate(exp, workerScript) { } if (cost > Player.money) { workerScript.scriptRef.log("Could not afford to purchase new Hacknet Node"); - resolve(-1); + resolve(""); } //Auto generate a name for the node for now...TODO @@ -732,7 +732,7 @@ function evaluate(exp, workerScript) { Player.loseMoney(cost); Player.hacknetNodes.push(node); workerScript.scriptRef.log("Purchased new Hacknet Node with name: " + name); - resolve(numOwned); + resolve(name); }, CONSTANTS.CodeInstructionRunTime); } else if (exp.func.value == "upgradeHacknetNode") { if (exp.args.length != 1) { diff --git a/src/Script.js b/src/Script.js index d34463a9c..4619ea862 100644 --- a/src/Script.js +++ b/src/Script.js @@ -184,6 +184,8 @@ Script.prototype.updateRamUsage = function() { var getHackingLevelCount = numOccurrences(codeCopy, "getHackingLevel("); var getServerMoneyAvailableCount = numOccurrences(codeCopy, "getServerMoneyAvailable("); var numOperators = numNetscriptOperators(codeCopy); + var purchaseHacknetCount = numOccurrences(codeCopy, "purchaseHacknetNode("); + var upgradeHacknetCount = numOccurrences(codeCopy, "upgradeHacknetNode("); this.ramUsage = baseRam + ((whileCount * CONSTANTS.ScriptWhileRamCost) + @@ -200,7 +202,9 @@ Script.prototype.updateRamUsage = function() { (runCount * CONSTANTS.ScriptRunRamCost) + (getHackingLevelCount * CONSTANTS.ScriptGetHackingLevelRamCost) + (getServerMoneyAvailableCount * CONSTANTS.ScriptGetServerMoneyRamCost) + - (numOperators * CONSTANTS.ScriptOperatorRamCost)); + (numOperators * CONSTANTS.ScriptOperatorRamCost) + + (purchaseHacknetCount * CONSTANTS.ScriptPurchaseHacknetRamCost) + + (upgradeHacknetCount * CONSTANTS.ScriptUpgradeHacknetRamCost)); console.log("ram usage: " + this.ramUsage); if (isNaN(this.ramUsage)) { dialogBoxCreate("ERROR in calculating ram usage. This is a bug, please report to game develoepr");