Playtesting - Fixed bugs and some rebalancing with foreign servers

This commit is contained in:
Daniel Xie 2017-04-20 03:29:07 -05:00
parent fd70bf259b
commit c1c37f008e
10 changed files with 41 additions and 33 deletions

@ -24,9 +24,6 @@
padding-left: 10px; padding-left: 10px;
height: 100%; height: 100%;
margin-left: 10%; margin-left: 10%;
}
#script-editor-filename-row-div {
color: #66ff33; color: #66ff33;
} }

@ -120,12 +120,10 @@
<!-- Script editor --> <!-- Script editor -->
<div id="script-editor-container"> <div id="script-editor-container">
<div id="script-editor-filename-row-div" > <p id="script-editor-filename-tag"> Script name: </p>
<p id="script-editor-filename-tag"> Script name (edit below): </p>
<input id="script-editor-filename" type="text" maxlength="30"> </input> <input id="script-editor-filename" type="text" maxlength="30"> </input>
<br> <br>
<p id="script-editor-status"> </p>
</div>
<br><br> <br><br>
<textarea id="script-editor-text" style="border: none" autofocus> </textarea> <textarea id="script-editor-text" style="border: none" autofocus> </textarea>
</div> </div>

@ -34,6 +34,10 @@ CONSTANTS = {
MillisecondsPerHour: 3600000, MillisecondsPerHour: 3600000,
GameCyclesPerHour: 3600000 / 200, 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 //Text that is displayed when the 'help' command is ran in Terminal
HelpText: "analyze Get statistics and information about current machine <br>" + HelpText: "analyze Get statistics and information about current machine <br>" +
"clear Clear all text on the terminal <br>" + "clear Clear all text on the terminal <br>" +

@ -676,13 +676,14 @@ displayFactionAugmentations = function(factionName) {
var aElem = document.createElement("a"); var aElem = document.createElement("a");
var pElem = document.createElement("p"); var pElem = document.createElement("p");
aElem.setAttribute("href", "#"); 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"); aElem.setAttribute("class", "a-link-button");
pElem.innerHTML = "UNLOCKED"; pElem.innerHTML = "UNLOCKED";
//TODO Event listener for button to purchase augmentation //TODO Event listener for button to purchase augmentation
} else { } else {
aElem.setAttribute("class", "a-link-button-inactive"); aElem.setAttribute("class", "a-link-button-inactive");
pElem.innerHTML = "LOCKED"; pElem.innerHTML = "LOCKED (Requires " + req + " faction reputation)";
pElem.style.color = "red"; pElem.style.color = "red";
} }
aElem.style.display = "inline-block"; aElem.style.display = "inline-block";

@ -27,7 +27,6 @@ function evaluate(exp, workerScript) {
break; break;
//Can currently only assign to "var"s //Can currently only assign to "var"s
case "assign": case "assign":
console.log("Evaluating assign operation");
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
if (env.stopFlag) {reject(workerScript);} if (env.stopFlag) {reject(workerScript);}
@ -46,13 +45,11 @@ function evaluate(exp, workerScript) {
}); });
p.then(function(expRight) { p.then(function(expRight) {
console.log("Right side of assign operation resolved with value: " + expRight);
try { try {
env.set(exp.left.value, expRight); env.set(exp.left.value, expRight);
} catch (e) { } catch (e) {
throw new Error("|" + workerScript.serverIp + "|" + workerScript.name + "|" + e.toString()); throw new Error("|" + workerScript.serverIp + "|" + workerScript.name + "|" + e.toString());
} }
console.log("Assign operation finished");
resolve("assignFinished"); resolve("assignFinished");
}, function(e) { }, function(e) {
reject(e); reject(e);
@ -60,7 +57,6 @@ function evaluate(exp, workerScript) {
}); });
case "binary": case "binary":
console.log("Binary operation called");
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
if (env.stopFlag) {reject(workerScript);} if (env.stopFlag) {reject(workerScript);}
@ -88,7 +84,6 @@ function evaluate(exp, workerScript) {
}); });
pRight.then(function(args) { pRight.then(function(args) {
console.log("Resolving binary operation");
try { try {
resolve(apply_op(exp.operator, args[0], args[1])); resolve(apply_op(exp.operator, args[0], args[1]));
} catch (e) { } catch (e) {
@ -149,7 +144,6 @@ function evaluate(exp, workerScript) {
}); });
break; break;
case "while": case "while":
console.log("Evaluating while loop");
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
if (env.stopFlag) {reject(workerScript);} if (env.stopFlag) {reject(workerScript);}
@ -191,7 +185,6 @@ function evaluate(exp, workerScript) {
setTimeout(function() { setTimeout(function() {
if (exp.func.value == "hack") { if (exp.func.value == "hack") {
console.log("Execute hack()");
if (exp.args.length != 1) { if (exp.args.length != 1) {
throw new Error("|" + workerScript.serverIp + "|" + workerScript.name + "|Hack() call has incorrect number of arguments. Takes 1 argument"); 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") { } else if (exp.func.value == "sleep") {
console.log("Execute sleep()");
if (exp.args.length != 1) { if (exp.args.length != 1) {
throw new Error("|" + workerScript.serverIp + "|" + workerScript.name + "|Sleep() call has incorrect number of arguments. Takes 1 argument."); throw new Error("|" + workerScript.serverIp + "|" + workerScript.name + "|Sleep() call has incorrect number of arguments. Takes 1 argument.");
} }
var sleepTimePromise = evaluate(exp.args[0], workerScript); var sleepTimePromise = evaluate(exp.args[0], workerScript);
sleepTimePromise.then(function(sleepTime) { sleepTimePromise.then(function(sleepTime) {
console.log("Sleep time: " + sleepTime);
workerScript.scriptRef.log("Sleeping for " + sleepTime + " milliseconds"); workerScript.scriptRef.log("Sleeping for " + sleepTime + " milliseconds");
var p = new Promise(function(resolve, reject) { var p = new Promise(function(resolve, reject) {
setTimeout(function() { setTimeout(function() {
@ -314,7 +305,6 @@ function evaluate(exp, workerScript) {
p.then(function(res) { p.then(function(res) {
post(res.toString()); post(res.toString());
console.log("Print call executed");
resolve("printExecuted"); resolve("printExecuted");
}, function(e) { }, function(e) {
reject(e); reject(e);

@ -156,7 +156,6 @@ function Parser(input) {
checkKeywordAndSkip("for"); checkKeywordAndSkip("for");
splitExpressions = delimited("(", ")", ";", parse_expression); splitExpressions = delimited("(", ")", ";", parse_expression);
console.log("Parsing code in for loop");
code = parse_expression(); code = parse_expression();
if (splitExpressions.length != 3) { if (splitExpressions.length != 3) {
@ -180,7 +179,6 @@ function Parser(input) {
* code: prog node * code: prog node
*/ */
function parse_while() { function parse_while() {
console.log("Parsing while token");
checkKeywordAndSkip("while"); checkKeywordAndSkip("while");
var cond = parse_expression(); var cond = parse_expression();
@ -238,7 +236,6 @@ function Parser(input) {
} }
function parse_prog() { function parse_prog() {
console.log("Parsing prog token");
var prog = delimited("{", "}", ";", parse_expression); var prog = delimited("{", "}", ";", parse_expression);
if (prog.length == 0) return FALSE; if (prog.length == 0) return FALSE;
if (prog.length == 1) return prog[0]; if (prog.length == 1) return prog[0];

@ -387,6 +387,8 @@ PlayerObject.prototype.startWork = function() {
} }
PlayerObject.prototype.work = function(numCycles) { PlayerObject.prototype.work = function(numCycles) {
this.workRepGainRate = this.getWorkRepGain();
this.workHackExpGained += this.workHackExpGainRate * numCycles; this.workHackExpGained += this.workHackExpGainRate * numCycles;
this.workStrExpGained += this.workStrExpGainRate * numCycles; this.workStrExpGained += this.workStrExpGainRate * numCycles;
this.workDefExpGained += this.workDefExpGainRate * 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.workRepGainRate = this.hacking_skill / CONSTANTS.MaxSkillLevel * this.faction_rep_mult;
this.workMoneyGainRate = 0; this.workMoneyGainRate = 0;
this.factionWorkType = CONSTANTS.FactionWorkHacking;
this.currentWorkFactionDescription = "carrying out hacking contracts"; this.currentWorkFactionDescription = "carrying out hacking contracts";
this.startFactionWork(faction); this.startFactionWork(faction);
@ -527,6 +530,7 @@ PlayerObject.prototype.startFactionFieldWork = function(faction) {
this.workRepGainRate = this.getFactionFieldWorkRepGain(); this.workRepGainRate = this.getFactionFieldWorkRepGain();
this.workMoneyGainRate = 0; this.workMoneyGainRate = 0;
this.factionWorkType = CONSTANTS.factionWorkField;
this.currentWorkFactionDescription = "carrying out field missions" this.currentWorkFactionDescription = "carrying out field missions"
this.startFactionWork(faction); this.startFactionWork(faction);
@ -539,9 +543,10 @@ PlayerObject.prototype.startFactionSecurityWork = function(faction) {
this.workDexExpGainRate = 0; this.workDexExpGainRate = 0;
this.workAgiExpGainRate = 0; this.workAgiExpGainRate = 0;
this.workChaExpGainRate = 0; this.workChaExpGainRate = 0;
this.workRepGainRate = this.getFactionFieldWorkRepGain(); this.workRepGainRate = this.getFactionSecurityWorkRepGain();
this.workMoneyGainRate = 0; this.workMoneyGainRate = 0;
this.factionWorkType = CONSTANTS.FactionWorkSecurity;
this.currentWorkFactionDescription = "performing security detail" this.currentWorkFactionDescription = "performing security detail"
this.startFactionWork(faction); this.startFactionWork(faction);
@ -550,6 +555,21 @@ PlayerObject.prototype.startFactionSecurityWork = function(faction) {
PlayerObject.prototype.workForFaction = function(numCycles) { PlayerObject.prototype.workForFaction = function(numCycles) {
var faction = Factions[this.currentWorkFactionName]; 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.workHackExpGained += this.workHackExpGainRate * numCycles;
this.workStrExpGained += this.workStrExpGainRate * numCycles; this.workStrExpGained += this.workStrExpGainRate * numCycles;
this.workDefExpGained += this.workDefExpGainRate * numCycles; this.workDefExpGained += this.workDefExpGainRate * numCycles;

@ -23,6 +23,7 @@ purchaseServer = function(ram, cost) {
//Connect new server to home computer //Connect new server to home computer
var homeComputer = Player.getHomeComputer(); var homeComputer = Player.getHomeComputer();
homeComputer.serversOnNetwork.push(newServ.ip); homeComputer.serversOnNetwork.push(newServ.ip);
newServ.serversOnNetwork.push(homeComputer.ip);
Player.money -= cost; Player.money -= cost;

@ -469,31 +469,31 @@ initForeignServers = function() {
//Gyms //Gyms
var CrushFitnessGymServer = new Server(); var CrushFitnessGymServer = new Server();
CrushFitnessGymServer.init(createRandomIp(), "crush-fitness", "Crush Fitness", true, false, false, false, 4); 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); CrushFitnessGymServer.setPortProperties(2);
AddToAllServers(CrushFitnessGymServer); AddToAllServers(CrushFitnessGymServer);
var IronGymServer = new Server(); var IronGymServer = new Server();
IronGymServer.init(createRandomIp(), "iron-gym", "Iron Gym Network", true, false, false, false, 4); 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); IronGymServer.setPortProperties(1);
AddToAllServers(IronGymServer); AddToAllServers(IronGymServer);
var MilleniumFitnessGymServer = new Server(); var MilleniumFitnessGymServer = new Server();
MilleniumFitnessGymServer.init(createRandomIp(), "millenium-fitness", "Millenium Fitness Network", true, false, false, false, 8); 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); MilleniumFitnessGymServer.setPortProperties(3);
AddToAllServers(MilleniumFitnessGymServer); AddToAllServers(MilleniumFitnessGymServer);
var PowerhouseGymServer = new Server(); var PowerhouseGymServer = new Server();
PowerhouseGymServer.init(createRandomIp(), "powerhouse-fitness", "Powerhouse Fitness", true, false, false, false, 8); 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); PowerhouseGymServer.setPortProperties(5);
AddToAllServers(PowerhouseGymServer); AddToAllServers(PowerhouseGymServer);
var SnapFitnessGymServer = new Server(); var SnapFitnessGymServer = new Server();
SnapFitnessGymServer.init(createRandomIp(), "snap-fitness", "Snap Fitness", true, false, false, false, 8); 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); SnapFitnessGymServer.setPortProperties(4);
AddToAllServers(SnapFitnessGymServer); AddToAllServers(SnapFitnessGymServer);
@ -643,7 +643,7 @@ processServerGrowth = function(numCycles) {
var numServerGrowthCyclesAdjusted = numServerGrowthCycles * serverGrowthPercentage; var numServerGrowthCyclesAdjusted = numServerGrowthCycles * serverGrowthPercentage;
//Apply serverGrowth for the calculated number of growth cycles //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); //console.log("serverGrowth ratio: " + serverGrowth);
server.moneyAvailable *= serverGrowth; server.moneyAvailable *= serverGrowth;
} }

@ -343,7 +343,7 @@ var Terminal = {
//Cannot edit scripts that are currently running //Cannot edit scripts that are currently running
for (var i = 0; i < Player.getCurrentServer().runningScripts.length; i++) { 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; post("Cannot open/edit scripts that are currently running!"); return;
} }
} }