mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-21 05:35:45 +01:00
Added Options button to top right overview. Script object optimization by deleting server maps when not active. Fixed issue with servers getting negative money
This commit is contained in:
parent
6b2d6b5ded
commit
69d4af01ff
@ -237,6 +237,7 @@ tr:focus {
|
|||||||
right: 0;
|
right: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
|
margin-right: 14px;
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
}
|
}
|
||||||
@ -250,7 +251,7 @@ tr:focus {
|
|||||||
position: absolute; /* Stay in place */
|
position: absolute; /* Stay in place */
|
||||||
right: 0;
|
right: 0;
|
||||||
top: 0;
|
top: 0;
|
||||||
height: 175px; /* Full height */
|
height: 185px; /* Full height */
|
||||||
/*margin: 50% auto;*/
|
/*margin: 50% auto;*/
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
border: 2px solid var(--my-highlight-color);
|
border: 2px solid var(--my-highlight-color);
|
||||||
@ -262,12 +263,13 @@ tr:focus {
|
|||||||
|
|
||||||
#character-overview-text {
|
#character-overview-text {
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
margin: 12px;
|
margin: 10px;
|
||||||
color: white;
|
color: white;
|
||||||
background-color: #444;
|
background-color: #444;
|
||||||
}
|
}
|
||||||
|
|
||||||
#character-overview-save-button {
|
#character-overview-save-button,
|
||||||
|
#character-overview-options-button {
|
||||||
color: #aaa;
|
color: #aaa;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
@ -280,8 +282,14 @@ tr:focus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#character-overview-save-button:hover,
|
#character-overview-save-button:hover,
|
||||||
#character-overview-save-button:focus {
|
#character-overview-save-button:focus,
|
||||||
|
#character-overview-options-button:hover,
|
||||||
|
#character-overview-options-button:focus {
|
||||||
color: white;
|
color: white;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#character-overview-options-button {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
@ -732,6 +732,7 @@
|
|||||||
<div id="character-overview-container">
|
<div id="character-overview-container">
|
||||||
<p id="character-overview-text"> </p>
|
<p id="character-overview-text"> </p>
|
||||||
<span id="character-overview-save-button"> Save Game </span>
|
<span id="character-overview-save-button"> Save Game </span>
|
||||||
|
<span id="character-overview-options-button"> Options </span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -974,6 +974,10 @@ function runScriptFromScript(server, scriptname, workerScript, threads=1) {
|
|||||||
var script = server.scripts[i];
|
var script = server.scripts[i];
|
||||||
script.threads = threads;
|
script.threads = threads;
|
||||||
server.runningScripts.push(script.filename); //Push onto runningScripts
|
server.runningScripts.push(script.filename); //Push onto runningScripts
|
||||||
|
script.moneyStolenMap = new AllServersMap();
|
||||||
|
script.numTimesHackMap = new AllServersMap();
|
||||||
|
script.numTimesGrowMap = new AllServersMap();
|
||||||
|
script.numTimesWeakenMap = new AllServersMap();
|
||||||
addWorkerScript(script, server);
|
addWorkerScript(script, server);
|
||||||
resolve(true);
|
resolve(true);
|
||||||
return;
|
return;
|
||||||
|
@ -181,10 +181,12 @@ function netscriptHack(exp, workerScript) {
|
|||||||
var moneyGained = scriptCalculatePercentMoneyHacked(server);
|
var moneyGained = scriptCalculatePercentMoneyHacked(server);
|
||||||
moneyGained = Math.floor(server.moneyAvailable * moneyGained) * threads;
|
moneyGained = Math.floor(server.moneyAvailable * moneyGained) * threads;
|
||||||
|
|
||||||
//Safety check
|
//Over-the-top safety checks
|
||||||
if (moneyGained <= 0) {moneyGained = 0;}
|
if (moneyGained <= 0) {moneyGained = 0;}
|
||||||
|
if (moneyGained > server.moneyAvailable) {moneyGained = server.moneyAvailable;}
|
||||||
server.moneyAvailable -= moneyGained;
|
server.moneyAvailable -= moneyGained;
|
||||||
|
if (server.moneyAvailable < 0) {server.moneyAvailable = 0;}
|
||||||
|
|
||||||
Player.gainMoney(moneyGained);
|
Player.gainMoney(moneyGained);
|
||||||
workerScript.scriptRef.onlineMoneyMade += moneyGained;
|
workerScript.scriptRef.onlineMoneyMade += moneyGained;
|
||||||
workerScript.scriptRef.recordHack(server.ip, moneyGained, threads);
|
workerScript.scriptRef.recordHack(server.ip, moneyGained, threads);
|
||||||
|
@ -133,10 +133,10 @@ function runScriptsLoop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Reset the correspondings script's maps to save space
|
//Reset the correspondings script's maps to save space
|
||||||
//workerScripts[i].scriptRef.moneyStolenMap = {};
|
workerScripts[i].scriptRef.moneyStolenMap = {};
|
||||||
//workerScripts[i].scriptRef.numTimesHackMap = {};
|
workerScripts[i].scriptRef.numTimesHackMap = {};
|
||||||
//workerScripts[i].scriptRef.numTimesGrowMap = {};
|
workerScripts[i].scriptRef.numTimesGrowMap = {};
|
||||||
//workerScripts[i].scriptRef.numTimesWeakenMap = {};
|
workerScripts[i].scriptRef.numTimesWeakenMap = {};
|
||||||
|
|
||||||
//Free RAM
|
//Free RAM
|
||||||
AllServers[ip].ramUsed -= workerScripts[i].ramUsage;
|
AllServers[ip].ramUsed -= workerScripts[i].ramUsage;
|
||||||
|
@ -372,8 +372,20 @@ scriptCalculateOfflineProduction = function(script) {
|
|||||||
//4 hours (14400 sec) then we are completely confident in its ability
|
//4 hours (14400 sec) then we are completely confident in its ability
|
||||||
var confidence = (script.onlineRunningTime) / 14400;
|
var confidence = (script.onlineRunningTime) / 14400;
|
||||||
if (confidence >= 1) {confidence = 1;}
|
if (confidence >= 1) {confidence = 1;}
|
||||||
console.log("onlineRunningTime: " + script.onlineRunningTime);
|
|
||||||
console.log("Confidence: " + confidence);
|
//Grow
|
||||||
|
for (var ip in script.numTimesGrowMap) {
|
||||||
|
if (script.numTimesGrowMap.hasOwnProperty(ip)) {
|
||||||
|
if (script.numTimesGrowMap[ip] == 0 || script.numTimesGrowMap[ip] == null) {continue;}
|
||||||
|
var serv = AllServers[ip];
|
||||||
|
if (serv == null) {continue;}
|
||||||
|
var timesGrown = Math.round(0.5 * script.numTimesGrowMap[ip] / script.onlineRunningTime * timePassed);
|
||||||
|
console.log(script.filename + " called grow() on " + serv.hostname + " " + timesGrown + " times while offline");
|
||||||
|
script.log("Called grow() on " + serv.hostname + " " + timesGrown + " times while offline");
|
||||||
|
var growth = processSingleServerGrowth(serv, timesGrown * 450);
|
||||||
|
script.log(serv.hostname + " grown by " + formatNumber(growth * 100 - 100, 6) + "% from grow() calls made while offline");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var totalOfflineProduction = 0;
|
var totalOfflineProduction = 0;
|
||||||
for (var ip in script.moneyStolenMap) {
|
for (var ip in script.moneyStolenMap) {
|
||||||
@ -433,20 +445,6 @@ scriptCalculateOfflineProduction = function(script) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Grow
|
|
||||||
for (var ip in script.numTimesGrowMap) {
|
|
||||||
if (script.numTimesGrowMap.hasOwnProperty(ip)) {
|
|
||||||
if (script.numTimesGrowMap[ip] == 0 || script.numTimesGrowMap[ip] == null) {continue;}
|
|
||||||
var serv = AllServers[ip];
|
|
||||||
if (serv == null) {continue;}
|
|
||||||
var timesGrown = Math.round(0.5 * script.numTimesGrowMap[ip] / script.onlineRunningTime * timePassed);
|
|
||||||
console.log(script.filename + " called grow() on " + serv.hostname + " " + timesGrown + " times while offline");
|
|
||||||
script.log("Called grow() on " + serv.hostname + " " + timesGrown + " times while offline");
|
|
||||||
var growth = processSingleServerGrowth(serv, timesGrown * 450);
|
|
||||||
script.log(serv.hostname + " grown by " + formatNumber(growth * 100 - 100, 6) + "% from grow() calls made while offline");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return totalOfflineProduction;
|
return totalOfflineProduction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1237,7 +1237,10 @@ var Terminal = {
|
|||||||
server.runningScripts.push(script.filename); //Push onto runningScripts
|
server.runningScripts.push(script.filename); //Push onto runningScripts
|
||||||
|
|
||||||
//Initialize the maps for counting grow/hack/weaken
|
//Initialize the maps for counting grow/hack/weaken
|
||||||
//script.moneyStolenMap = new AllServersMap();
|
script.moneyStolenMap = new AllServersMap();
|
||||||
|
script.numTimesHackMap = new AllServersMap();
|
||||||
|
script.numTimesGrowMap = new AllServersMap();
|
||||||
|
script.numTimesWeakenMap = new AllServersMap();
|
||||||
|
|
||||||
addWorkerScript(script, server);
|
addWorkerScript(script, server);
|
||||||
return;
|
return;
|
||||||
|
@ -908,13 +908,17 @@ var Engine = {
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
//Character Overview Save button
|
//Character Overview buttons
|
||||||
var charOverviewSaveButton = document.getElementById("character-overview-save-button");
|
document.getElementById("character-overview-save-button").addEventListener("click", function() {
|
||||||
charOverviewSaveButton.addEventListener("click", function() {
|
|
||||||
saveObject.saveGame();
|
saveObject.saveGame();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.getElementById("character-overview-options-button").addEventListener("click", function() {
|
||||||
|
gameOptionsBoxOpen();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
//Script Editor Netscript documentation button
|
//Script Editor Netscript documentation button
|
||||||
var netscriptDocButton = document.getElementById("script-editor-netscript-doc-button");
|
var netscriptDocButton = document.getElementById("script-editor-netscript-doc-button");
|
||||||
netscriptDocButton.addEventListener("click", function() {
|
netscriptDocButton.addEventListener("click", function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user