From c1c37f008edd942cc61f450cdfbff29336f625e8 Mon Sep 17 00:00:00 2001 From: Daniel Xie Date: Thu, 20 Apr 2017 03:29:07 -0500 Subject: [PATCH] Playtesting - Fixed bugs and some rebalancing with foreign servers --- css/menupages.css | 5 +---- index.html | 10 ++++------ src/Constants.js | 4 ++++ src/Faction.js | 5 +++-- src/Netscript/Evaluator.js | 10 ---------- src/Netscript/Parser.js | 3 --- src/Player.js | 22 +++++++++++++++++++++- src/PurchaseServers.js | 1 + src/Server.js | 12 ++++++------ src/Terminal.js | 2 +- 10 files changed, 41 insertions(+), 33 deletions(-) diff --git a/css/menupages.css b/css/menupages.css index dc8217e8f..c603a3cca 100644 --- a/css/menupages.css +++ b/css/menupages.css @@ -24,10 +24,7 @@ padding-left: 10px; height: 100%; margin-left: 10%; -} - -#script-editor-filename-row-div { - color: #66ff33; + color: #66ff33; } #script-editor-filename-tag { diff --git a/index.html b/index.html index 21248b30b..f93591e8c 100644 --- a/index.html +++ b/index.html @@ -120,12 +120,10 @@
-
-

Script name (edit below):

- -
-

-
+

Script name:

+ + +


diff --git a/src/Constants.js b/src/Constants.js index a6213e4f9..2693ef3c8 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -34,6 +34,10 @@ CONSTANTS = { MillisecondsPerHour: 3600000, GameCyclesPerHour: 3600000 / 200, + FactionWorkHacking: "Faction Hacking Work", + FactionWorkField: "Faction Field Work", + FactionWorkSecurity: "Faction Security Work", + //Text that is displayed when the 'help' command is ran in Terminal HelpText: "analyze Get statistics and information about current machine
" + "clear Clear all text on the terminal
" + diff --git a/src/Faction.js b/src/Faction.js index 43c6697df..562a4dd52 100644 --- a/src/Faction.js +++ b/src/Faction.js @@ -676,13 +676,14 @@ displayFactionAugmentations = function(factionName) { var aElem = document.createElement("a"); var pElem = document.createElement("p"); aElem.setAttribute("href", "#"); - if (faction.playerReputation >= (aug.baseRepRequirement * faction.augmentationRepRequirementMult)) { + var req = aug.baseRepRequirement * faction.augmentationRepRequirementMult; + if (faction.playerReputation >= req) { aElem.setAttribute("class", "a-link-button"); pElem.innerHTML = "UNLOCKED"; //TODO Event listener for button to purchase augmentation } else { aElem.setAttribute("class", "a-link-button-inactive"); - pElem.innerHTML = "LOCKED"; + pElem.innerHTML = "LOCKED (Requires " + req + " faction reputation)"; pElem.style.color = "red"; } aElem.style.display = "inline-block"; diff --git a/src/Netscript/Evaluator.js b/src/Netscript/Evaluator.js index a75f4e218..00bfd187b 100644 --- a/src/Netscript/Evaluator.js +++ b/src/Netscript/Evaluator.js @@ -27,7 +27,6 @@ function evaluate(exp, workerScript) { break; //Can currently only assign to "var"s case "assign": - console.log("Evaluating assign operation"); return new Promise(function(resolve, reject) { if (env.stopFlag) {reject(workerScript);} @@ -46,13 +45,11 @@ function evaluate(exp, workerScript) { }); p.then(function(expRight) { - console.log("Right side of assign operation resolved with value: " + expRight); try { env.set(exp.left.value, expRight); } catch (e) { throw new Error("|" + workerScript.serverIp + "|" + workerScript.name + "|" + e.toString()); } - console.log("Assign operation finished"); resolve("assignFinished"); }, function(e) { reject(e); @@ -60,7 +57,6 @@ function evaluate(exp, workerScript) { }); case "binary": - console.log("Binary operation called"); return new Promise(function(resolve, reject) { if (env.stopFlag) {reject(workerScript);} @@ -88,7 +84,6 @@ function evaluate(exp, workerScript) { }); pRight.then(function(args) { - console.log("Resolving binary operation"); try { resolve(apply_op(exp.operator, args[0], args[1])); } catch (e) { @@ -149,7 +144,6 @@ function evaluate(exp, workerScript) { }); break; case "while": - console.log("Evaluating while loop"); return new Promise(function(resolve, reject) { if (env.stopFlag) {reject(workerScript);} @@ -191,7 +185,6 @@ function evaluate(exp, workerScript) { setTimeout(function() { if (exp.func.value == "hack") { - console.log("Execute hack()"); if (exp.args.length != 1) { throw new Error("|" + workerScript.serverIp + "|" + workerScript.name + "|Hack() call has incorrect number of arguments. Takes 1 argument"); } @@ -271,14 +264,12 @@ function evaluate(exp, workerScript) { }); } else if (exp.func.value == "sleep") { - console.log("Execute sleep()"); if (exp.args.length != 1) { throw new Error("|" + workerScript.serverIp + "|" + workerScript.name + "|Sleep() call has incorrect number of arguments. Takes 1 argument."); } var sleepTimePromise = evaluate(exp.args[0], workerScript); sleepTimePromise.then(function(sleepTime) { - console.log("Sleep time: " + sleepTime); workerScript.scriptRef.log("Sleeping for " + sleepTime + " milliseconds"); var p = new Promise(function(resolve, reject) { setTimeout(function() { @@ -314,7 +305,6 @@ function evaluate(exp, workerScript) { p.then(function(res) { post(res.toString()); - console.log("Print call executed"); resolve("printExecuted"); }, function(e) { reject(e); diff --git a/src/Netscript/Parser.js b/src/Netscript/Parser.js index 8ac71df0b..0082be167 100644 --- a/src/Netscript/Parser.js +++ b/src/Netscript/Parser.js @@ -156,7 +156,6 @@ function Parser(input) { checkKeywordAndSkip("for"); splitExpressions = delimited("(", ")", ";", parse_expression); - console.log("Parsing code in for loop"); code = parse_expression(); if (splitExpressions.length != 3) { @@ -180,7 +179,6 @@ function Parser(input) { * code: prog node */ function parse_while() { - console.log("Parsing while token"); checkKeywordAndSkip("while"); var cond = parse_expression(); @@ -238,7 +236,6 @@ function Parser(input) { } function parse_prog() { - console.log("Parsing prog token"); var prog = delimited("{", "}", ";", parse_expression); if (prog.length == 0) return FALSE; if (prog.length == 1) return prog[0]; diff --git a/src/Player.js b/src/Player.js index d46339b18..e97046bb3 100644 --- a/src/Player.js +++ b/src/Player.js @@ -387,6 +387,8 @@ PlayerObject.prototype.startWork = function() { } PlayerObject.prototype.work = function(numCycles) { + this.workRepGainRate = this.getWorkRepGain(); + this.workHackExpGained += this.workHackExpGainRate * numCycles; this.workStrExpGained += this.workStrExpGainRate * numCycles; this.workDefExpGained += this.workDefExpGainRate * numCycles; @@ -512,6 +514,7 @@ PlayerObject.prototype.startFactionHackWork = function(faction) { this.workRepGainRate = this.hacking_skill / CONSTANTS.MaxSkillLevel * this.faction_rep_mult; this.workMoneyGainRate = 0; + this.factionWorkType = CONSTANTS.FactionWorkHacking; this.currentWorkFactionDescription = "carrying out hacking contracts"; this.startFactionWork(faction); @@ -527,6 +530,7 @@ PlayerObject.prototype.startFactionFieldWork = function(faction) { this.workRepGainRate = this.getFactionFieldWorkRepGain(); this.workMoneyGainRate = 0; + this.factionWorkType = CONSTANTS.factionWorkField; this.currentWorkFactionDescription = "carrying out field missions" this.startFactionWork(faction); @@ -539,9 +543,10 @@ PlayerObject.prototype.startFactionSecurityWork = function(faction) { this.workDexExpGainRate = 0; this.workAgiExpGainRate = 0; this.workChaExpGainRate = 0; - this.workRepGainRate = this.getFactionFieldWorkRepGain(); + this.workRepGainRate = this.getFactionSecurityWorkRepGain(); this.workMoneyGainRate = 0; + this.factionWorkType = CONSTANTS.FactionWorkSecurity; this.currentWorkFactionDescription = "performing security detail" this.startFactionWork(faction); @@ -550,6 +555,21 @@ PlayerObject.prototype.startFactionSecurityWork = function(faction) { PlayerObject.prototype.workForFaction = function(numCycles) { var faction = Factions[this.currentWorkFactionName]; + //Constantly update the rep gain rate + switch (this.factionWorkType) { + case CONSTANTS.FactionWorkHacking: + this.workRepGainRate = this.hacking_skill / CONSTANTS.MaxSkillLevel * this.faction_rep_mult; + break; + case CONSTANTS.FactionWorkField: + this.workRepGainRate = this.getFactionFieldWorkRepGain(); + break; + case CONSTANTS.FactionWorkSecurity: + this.workRepGainRate = this.getFactionSecurityWorkRepGain(); + break; + default: + break; + } + this.workHackExpGained += this.workHackExpGainRate * numCycles; this.workStrExpGained += this.workStrExpGainRate * numCycles; this.workDefExpGained += this.workDefExpGainRate * numCycles; diff --git a/src/PurchaseServers.js b/src/PurchaseServers.js index 7487be172..9894ae49f 100644 --- a/src/PurchaseServers.js +++ b/src/PurchaseServers.js @@ -23,6 +23,7 @@ purchaseServer = function(ram, cost) { //Connect new server to home computer var homeComputer = Player.getHomeComputer(); homeComputer.serversOnNetwork.push(newServ.ip); + newServ.serversOnNetwork.push(homeComputer.ip); Player.money -= cost; diff --git a/src/Server.js b/src/Server.js index 69b11e025..9fd9ead95 100644 --- a/src/Server.js +++ b/src/Server.js @@ -469,31 +469,31 @@ initForeignServers = function() { //Gyms var CrushFitnessGymServer = new Server(); CrushFitnessGymServer.init(createRandomIp(), "crush-fitness", "Crush Fitness", true, false, false, false, 4); - CrushFitnessGymServer.setHackingParameters(250, 500000, 40, 25); + CrushFitnessGymServer.setHackingParameters(250, 300000, 40, 25); CrushFitnessGymServer.setPortProperties(2); AddToAllServers(CrushFitnessGymServer); var IronGymServer = new Server(); IronGymServer.init(createRandomIp(), "iron-gym", "Iron Gym Network", true, false, false, false, 4); - IronGymServer.setHackingParameters(100, 250000, 30, 15); + IronGymServer.setHackingParameters(100, 150000, 30, 15); IronGymServer.setPortProperties(1); AddToAllServers(IronGymServer); var MilleniumFitnessGymServer = new Server(); MilleniumFitnessGymServer.init(createRandomIp(), "millenium-fitness", "Millenium Fitness Network", true, false, false, false, 8); - MilleniumFitnessGymServer.setHackingParameters(500, 600000, 50, 30); + MilleniumFitnessGymServer.setHackingParameters(500, 400000, 50, 30); MilleniumFitnessGymServer.setPortProperties(3); AddToAllServers(MilleniumFitnessGymServer); var PowerhouseGymServer = new Server(); PowerhouseGymServer.init(createRandomIp(), "powerhouse-fitness", "Powerhouse Fitness", true, false, false, false, 8); - PowerhouseGymServer.setHackingParameters(1000, 2000000, 60, 50); + PowerhouseGymServer.setHackingParameters(1000, 1000000, 60, 50); PowerhouseGymServer.setPortProperties(5); AddToAllServers(PowerhouseGymServer); var SnapFitnessGymServer = new Server(); SnapFitnessGymServer.init(createRandomIp(), "snap-fitness", "Snap Fitness", true, false, false, false, 8); - SnapFitnessGymServer.setHackingParameters(750, 1000000, 50, 45); + SnapFitnessGymServer.setHackingParameters(750, 750000, 50, 45); SnapFitnessGymServer.setPortProperties(4); AddToAllServers(SnapFitnessGymServer); @@ -643,7 +643,7 @@ processServerGrowth = function(numCycles) { var numServerGrowthCyclesAdjusted = numServerGrowthCycles * serverGrowthPercentage; //Apply serverGrowth for the calculated number of growth cycles - var serverGrowth = Math.pow(1.0001, numServerGrowthCyclesAdjusted); + var serverGrowth = Math.pow(1.0004, numServerGrowthCyclesAdjusted); //console.log("serverGrowth ratio: " + serverGrowth); server.moneyAvailable *= serverGrowth; } diff --git a/src/Terminal.js b/src/Terminal.js index de06d8722..35218c893 100644 --- a/src/Terminal.js +++ b/src/Terminal.js @@ -343,7 +343,7 @@ var Terminal = { //Cannot edit scripts that are currently running for (var i = 0; i < Player.getCurrentServer().runningScripts.length; i++) { - if (filename == Player.getCurrentServer().runningScripts[i].filename) { + if (filename == Player.getCurrentServer().runningScripts[i]) { post("Cannot open/edit scripts that are currently running!"); return; } }